"""Check a proof against its promised conclusion and reject a mismatch."""

from std.testing import assert_true
from judgment import Fact, Proof, Session, Step
from judgment_shell import LibErrorKind


def main() raises:
    var s = Session()
    var root = s.base()
    var truth = s.true_()
    var falsehood = s.false_()
    var expected = truth & truth

    var leaf: Step = s.truth(root)
    var both: Step = s.and_intro(leaf, leaf)
    assert_true(both.statement().same_as(expected))
    assert_true(len(both.hypotheses()) == 0)

    var proof: Proof = s.theorem("both_true", expected)
    proof.exact(both)
    var checked: Fact = proof.finish()
    assert_true(checked.statement().same_as(expected))
    assert_true(len(checked.axioms()) == 0)

    var rejected = False
    try:
        var wrong = s.theorem("wrong_goal", falsehood)
        wrong.exact(both)
    except e:
        rejected = e.kind == LibErrorKind.KERNEL or e.kind == LibErrorKind.SHAPE
    assert_true(rejected)
    print("Accepted theorem: True and True")
    print("Rejected promised conclusion: False")
