logo

Expression of type Forall

from the theory of proveit.logic.booleans.disjunction

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import A, B, ExprRange, IndexedVar, Variable, m
from proveit.core_expr_types import A_1_to_m, B_1_to_m
from proveit.logic import Boolean, Forall, Implies, Not, Or
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(B, sub_expr1)
sub_expr3 = IndexedVar(A, sub_expr1)
expr = Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [A_1_to_m, B_1_to_m], instance_expr = Or(ExprRange(sub_expr1, Not(sub_expr2), one, m)), domain = Boolean, conditions = [Or(ExprRange(sub_expr1, Not(sub_expr3), one, m)), ExprRange(sub_expr1, Implies(sub_expr3, sub_expr2), one, m)]), domain = Natural)
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\forall_{m \in \mathbb{N}}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{m}, B_{1}, B_{2}, \ldots, B_{m} \in \mathbb{B}~|~(\lnot A_{1}) \lor  (\lnot A_{2}) \lor  \ldots \lor  (\lnot A_{m}),\left(A_{1} \Rightarrow B_{1}\right), \left(A_{2} \Rightarrow B_{2}\right), \ldots, \left(A_{m} \Rightarrow B_{m}\right)}~\left((\lnot B_{1}) \lor  (\lnot B_{2}) \lor  \ldots \lor  (\lnot B_{m})\right)\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 45
body: 4
3ExprTuple45
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 41
operands: 9
7Literal
8ExprTuple10
9ExprTuple45, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple14, 15
13Conditionalvalue: 16
condition: 17
14ExprRangelambda_map: 18
start_index: 44
end_index: 45
15ExprRangelambda_map: 19
start_index: 44
end_index: 45
16Operationoperator: 31
operands: 20
17Operationoperator: 21
operands: 22
18Lambdaparameter: 57
body: 54
19Lambdaparameter: 57
body: 50
20ExprTuple23
21Literal
22ExprTuple24, 25, 26, 27
23ExprRangelambda_map: 28
start_index: 44
end_index: 45
24ExprRangelambda_map: 29
start_index: 44
end_index: 45
25ExprRangelambda_map: 30
start_index: 44
end_index: 45
26Operationoperator: 31
operands: 32
27ExprRangelambda_map: 33
start_index: 44
end_index: 45
28Lambdaparameter: 57
body: 34
29Lambdaparameter: 57
body: 35
30Lambdaparameter: 57
body: 36
31Literal
32ExprTuple37
33Lambdaparameter: 57
body: 38
34Operationoperator: 51
operand: 50
35Operationoperator: 41
operands: 40
36Operationoperator: 41
operands: 42
37ExprRangelambda_map: 43
start_index: 44
end_index: 45
38Operationoperator: 46
operands: 47
39ExprTuple50
40ExprTuple54, 48
41Literal
42ExprTuple50, 48
43Lambdaparameter: 57
body: 49
44Literal
45Variable
46Literal
47ExprTuple54, 50
48Literal
49Operationoperator: 51
operand: 54
50IndexedVarvariable: 53
index: 57
51Literal
52ExprTuple54
53Variable
54IndexedVarvariable: 55
index: 57
55Variable
56ExprTuple57
57Variable