"""Swap a disjunction by explicitly choosing what each case proves."""

from judgment import Session, implies


def main() raises:
    var s = Session()
    var P = s.prop("P")
    var Q = s.prop("Q")
    var proof = s.theorem("swap_disjunction", implies(P | Q, Q | P))
    var either = proof.intro("either")
    _ = proof.cases(either, left_name="hp", right_name="hq")

    # In the P case, prove the right side of Q | P.
    var p_case = proof.select("left")
    p_case.choose_right()
    p_case.exact(p_case.fact("hp"))

    # In the Q case, prove the left side of Q | P.
    var q_case = proof.select("right")
    q_case.choose_left()
    q_case.exact(q_case.fact("hq"))

    var theorem = proof.finish()
    print(theorem)
    print("Axiom dependencies:", len(theorem.axioms()))
