import proveit
# Prepare this notebook for defining the theorems of a theory:
%theorems_notebook # Keep this at the top following 'import proveit'.
from proveit.logic import Forall, Iff, InSet, NotInSet, Set, Difference, And, Or, Equals, NotEquals
from proveit import x, y, S, A, B
%begin theorems
membership_unfolding = Forall((x, A, B), And(InSet(x, A), NotInSet(x, B)),
conditions=[InSet(x, Difference(A, B))])
membership_folding = Forall((x, A, B), InSet(x, Difference(A, B)),
conditions=[InSet(x, A), NotInSet(x, B)])
nonmembership_equiv = Forall((x, A, B), Equals(NotInSet(x, Difference(A, B)),
Or(NotInSet(x, A), InSet(x, B))))
nonmembership_folding = Forall((x, A, B), NotInSet(x, Difference(A, B)),
conditions=[Or(NotInSet(x, A), InSet(x, B))])
nonmembership_unfolding = Forall((x, A, B), Or(NotInSet(x, A), InSet(x, B)),
condition=NotInSet(x, Difference(A, B)))
all_but_one_membership_unfolding = Forall((S, y), Forall(x, And(InSet(x, S), NotEquals(x, y)),
domain=Difference(S, Set(y))))
all_but_one_membership_folding = Forall((S, y), Forall(x, InSet(x, Difference(S, Set(y))),
domain=S, condition=NotEquals(x, y)))
all_but_one_nonmembership_unfolding = Forall((S, y), Forall(x, Or(NotInSet(x, S), Equals(x, y)),
condition=NotInSet(x, Difference(S, Set(y)))))
all_but_one_nonmembership_folding = Forall((S, y), Forall(x, NotInSet(x, Difference(S, Set(y))),
conditions=Or(NotInSet(x, S), Equals(x, y))))
%end theorems