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 Boolean, TRUE, FALSE, in_bool, Implies, Not, And, Or, Forall
from proveit.logic import Equals, NotEquals, InSet
from proveit import A, C, P, Q, PofA, QofA
from proveit.logic import PofTrue, PofFalse, QimplPofTrue, QimplPofFalse
%begin theorems
true_eq_true = Equals(TRUE, TRUE)
false_eq_false = Equals(FALSE, FALSE)
true_not_false = NotEquals(TRUE, FALSE)
TRUE
and FALSE
are in the Boolean set:¶fold_is_bool = Forall(A, in_bool(A),
conditions=[Or(Equals(A, TRUE), Equals(A, FALSE))])
true_is_bool = InSet(TRUE, Boolean)
false_is_bool = InSet(FALSE, Boolean)
in_bool_if_true = Forall(A, in_bool(A), conditions=[A])
in_bool_if_false = Forall(A, in_bool(A), conditions=[Not(A)])
not_equals_false = Forall(A, NotEquals(A, FALSE), conditions=[A])
not_equals_true = Forall(A, NotEquals(A, TRUE), conditions=[Not(A)])
TRUE
or FALSE
if in the Boolean set:¶The first form of 'unfold' is a more direct consequence of the Boolean definition. See also 'unfold_is_bool'.
unfold_is_bool_explicit = Forall(A, Or(Equals(A, TRUE), Equals(A, FALSE)), domain=Boolean)
forall_over_bool_by_cases = Forall(P, Forall(A, PofA, domain=Boolean), conditions=[PofTrue, PofFalse])
conditioned_forall_over_bool_by_cases = Forall((P, Q), Forall(A, PofA, domain=Boolean,
conditions=[QofA]),
conditions=[QimplPofTrue, QimplPofFalse])
from_not_false = Forall(A, A, conditions=[NotEquals(A, FALSE)], domain=Boolean)
forall_bool_eval_true = Forall(P, Equals(Forall(A, PofA, domain=Boolean), TRUE),
conditions=[Equals(PofTrue, TRUE), Equals(PofFalse, TRUE)])
unfold_forall_over_bool = Forall(P, Implies(Forall(A, PofA, domain=Boolean),
And(PofTrue, PofFalse)))
Various ways for a $\forall$ expression over the Boolean set to evaluate to FALSE
:
def _forallBoolEvalFalse(PofTrueVal, PofFalseVal):
return Forall(P, Implies(And(Equals(PofTrue, PofTrueVal), Equals(PofFalse, PofFalseVal)),
Equals(Forall(A, PofA, domain=Boolean), FALSE)))
forall_bool_eval_false_via_f_f = _forallBoolEvalFalse(FALSE, FALSE)
forall_bool_eval_false_via_f_t = _forallBoolEvalFalse(FALSE, TRUE)
forall_bool_eval_false_via_t_f = _forallBoolEvalFalse(TRUE, FALSE)
The second form, known as the 'law of excluded middle' can be more useful for unfolding the meaning of being in the Boolean set
in_bool_def = Forall(A, Equals(in_bool(A), Or(Equals(A, TRUE), Equals(A, FALSE))))
unfold_is_bool = Forall(A, Or(A, Not(A)), domain=Boolean)
from_excluded_middle = Forall(C, Forall(A, C, domain=Boolean,
conditions=[Implies(A, C),
Implies(Not(A), C)]))
New facts may be derived via the 'law of excluded middle' through dual implications
in_bool_is_bool = Forall(A, in_bool(in_bool(A)))
%end theorems