logo

Theorems (or conjectures) for the theory of proveit.logic.booleans

In [1]:
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
In [2]:
%begin theorems
Defining theorems for theory 'proveit.logic.booleans'
Subsequent end-of-cell assignments will define theorems
'%end theorems' will finalize the definitions

Comparisons between Boolean values

In [3]:
true_eq_true = Equals(TRUE, TRUE)
true_eq_true (established theorem):

In [4]:
false_eq_false = Equals(FALSE, FALSE)
false_eq_false (established theorem):

In [5]:
true_not_false = NotEquals(TRUE, FALSE)
true_not_false (established theorem):

TRUE and FALSE are in the Boolean set:

In [6]:
fold_is_bool = Forall(A, in_bool(A), 
                    conditions=[Or(Equals(A, TRUE), Equals(A, FALSE))])
fold_is_bool (conjecture with conjecture-based proof):

In [7]:
true_is_bool = InSet(TRUE, Boolean)
true_is_bool (conjecture with conjecture-based proof):

In [8]:
false_is_bool = InSet(FALSE, Boolean)
false_is_bool (conjecture with conjecture-based proof):

In [9]:
in_bool_if_true = Forall(A, in_bool(A), conditions=[A])
in_bool_if_true (conjecture with conjecture-based proof):

In [10]:
in_bool_if_false = Forall(A, in_bool(A), conditions=[Not(A)])
in_bool_if_false (conjecture with conjecture-based proof):

In [11]:
not_equals_false = Forall(A, NotEquals(A, FALSE), conditions=[A])
not_equals_false (established theorem):

In [12]:
not_equals_true = Forall(A, NotEquals(A, TRUE), conditions=[Not(A)])
not_equals_true (established theorem):

Must equal 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'.

In [13]:
unfold_is_bool_explicit = Forall(A, Or(Equals(A, TRUE), Equals(A, FALSE)), domain=Boolean)
unfold_is_bool_explicit (conjecture with conjecture-based proof):

Folding $\forall$ over the Boolean domain

In [14]:
forall_over_bool_by_cases = Forall(P, Forall(A, PofA, domain=Boolean), conditions=[PofTrue, PofFalse])
forall_over_bool_by_cases (conjecture with conjecture-based proof):

In [15]:
conditioned_forall_over_bool_by_cases = Forall((P, Q), Forall(A, PofA, domain=Boolean, 
                                                              conditions=[QofA]), 
                                               conditions=[QimplPofTrue, QimplPofFalse])
conditioned_forall_over_bool_by_cases (conjecture with conjecture-based proof):

In [ ]:
 
In [ ]:
 
In [16]:
from_not_false = Forall(A, A, conditions=[NotEquals(A, FALSE)], domain=Boolean)
from_not_false (established theorem):

In [ ]:
 
In [ ]:
 

Evaluation of $\forall$ over the Boolean domain

In [17]:
forall_bool_eval_true = Forall(P, Equals(Forall(A, PofA, domain=Boolean), TRUE),
                           conditions=[Equals(PofTrue, TRUE), Equals(PofFalse, TRUE)])
forall_bool_eval_true (conjecture without proof):

In [18]:
unfold_forall_over_bool = Forall(P, Implies(Forall(A, PofA, domain=Boolean), 
                                         And(PofTrue, PofFalse)))
unfold_forall_over_bool (conjecture without proof):

Various ways for a $\forall$ expression over the Boolean set to evaluate to FALSE:

In [19]:
def _forallBoolEvalFalse(PofTrueVal, PofFalseVal):
    return Forall(P, Implies(And(Equals(PofTrue, PofTrueVal), Equals(PofFalse, PofFalseVal)), 
                             Equals(Forall(A, PofA, domain=Boolean), FALSE)))
In [20]:
forall_bool_eval_false_via_f_f = _forallBoolEvalFalse(FALSE, FALSE)
forall_bool_eval_false_via_f_f (conjecture without proof):

In [21]:
forall_bool_eval_false_via_f_t = _forallBoolEvalFalse(FALSE, TRUE)
forall_bool_eval_false_via_f_t (conjecture without proof):

In [22]:
forall_bool_eval_false_via_t_f = _forallBoolEvalFalse(TRUE, FALSE)
forall_bool_eval_false_via_t_f (conjecture without proof):

Must be a true statement or a false statement if in the Boolean set:

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 [23]:
in_bool_def = Forall(A, Equals(in_bool(A), Or(Equals(A, TRUE), Equals(A, FALSE))))
in_bool_def (conjecture with conjecture-based proof):

In [24]:
unfold_is_bool = Forall(A, Or(A, Not(A)), domain=Boolean)
unfold_is_bool (conjecture with conjecture-based proof):

In [25]:
from_excluded_middle = Forall(C, Forall(A, C, domain=Boolean,
                                            conditions=[Implies(A, C),
                                                        Implies(Not(A), C)]))
from_excluded_middle (conjecture with conjecture-based proof):

New facts may be derived via the 'law of excluded middle' through dual implications

The claim that $x\in \mathbb{B}$ should itself be in $\mathbb{B}$

In [26]:
in_bool_is_bool = Forall(A, in_bool(in_bool(A)))
in_bool_is_bool (conjecture with conjecture-based proof):

In [27]:
%end theorems
These theorems may now be imported from the theory package: proveit.logic.booleans