"""Use compact exact literals with an explicitly registered arithmetic profile."""

from judgment import Session
from exact_arithmetic_setup import numeric_setup


def main() raises:
    var s = Session()
    var setup = numeric_setup(s, "Q", rational=True)
    var q = setup.register_rationals("rational_literals")
    var half = q.rational(1, 2)
    var third = q.rational(1, 3)
    var proof = s.theorem("fraction_sum", half + third == q.rational(5, 6))
    proof.rfl()
    var theorem = proof.finish()
    print(theorem)

    # Retrieve the same profile by carrier; its large numeral remains one node.
    var again = s.arithmetic(setup.kind)
    var large = again.number("123456789012345678901234567890")
    var arithmetic = s.theorem("large_sum", large + 1 == q.number("123456789012345678901234567891"))
    arithmetic.rfl()
    print(arithmetic.finish())
    print("Reduced fraction:", q.rational(-10, -12).format())
    print("Inverse of zero:", q.inverse(q.number(0)).format())
