"""State a generic theorem with typed parameters and rewrite an argument."""

from std.testing import assert_true
from judgment import Session, arrow


def main() raises:
    var s = Session()
    var proof = s.theorem("congruence")
    var A = proof.type_var("A")
    var a = proof.var("a", A)
    var b = proof.var("b", A)
    var f = proof.var("f", arrow(A, A))
    var h = proof.given("h", a == b)
    proof.goal(f(a) == f(b))

    _ = proof.lhs().at(a).rw(h)
    proof.rfl()
    var theorem = proof.finish()
    assert_true(theorem.type_params()[0].same_as(A))
    assert_true(theorem.statement().format() == "∀a:A. ∀b:A. ∀f:(A → A). a = b → f(a) = f(b)")
    print(theorem)
