"""Prove a readable chain and discharge a step after writing the calculation."""

from judgment import Session


def main():
    s = Session()
    A = s.declare_type("A")
    proof = s.theorem("equality_chain")
    values = proof.vars("a b c", A)
    a, b, c = values[0], values[1], values[2]
    ab = proof.given("ab", a == b)
    bc = proof.given("bc", b == c)
    proof.goal(a == c)

    chain = proof.calc(a)
    chain.eq(b, using=ab, label="ab")
    last = chain.step("last_step", to=c)
    last.sorry()
    print(chain.format())
    outstanding = chain.obligations()
    last = chain.select(outstanding[0])
    last.resume()
    last.exact(bc)
    print(chain.format())
    proof.exact(chain.finish())
    print(proof.finish())


if __name__ == "__main__":
    main()
