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

from judgment import Session, implies


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

    # In the P case, prove the right side of Q | P.
    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.
    q_case = proof.select("right")
    q_case.choose_left()
    q_case.exact(q_case.fact("hq"))

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


if __name__ == "__main__":
    main()
