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

from judgment import Fact, Proof, Session, Step, JudgmentError
from judgment import LibErrorKind


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

    leaf = s.truth(root)
    both = s.and_intro(leaf, leaf)
    assert both.statement().same_as(expected)
    assert len(both.hypotheses()) == 0

    proof = s.theorem("both_true", expected)
    proof.exact(both)
    checked = proof.finish()
    assert checked.statement().same_as(expected)
    assert len(checked.axioms()) == 0

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


if __name__ == "__main__":
    main()
