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 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 = [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)])
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_{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)
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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple6, 7
5Conditionalvalue: 8
condition: 9
6ExprRangelambda_map: 10
start_index: 36
end_index: 37
7ExprRangelambda_map: 11
start_index: 36
end_index: 37
8Operationoperator: 23
operands: 12
9Operationoperator: 13
operands: 14
10Lambdaparameter: 49
body: 46
11Lambdaparameter: 49
body: 42
12ExprTuple15
13Literal
14ExprTuple16, 17, 18, 19
15ExprRangelambda_map: 20
start_index: 36
end_index: 37
16ExprRangelambda_map: 21
start_index: 36
end_index: 37
17ExprRangelambda_map: 22
start_index: 36
end_index: 37
18Operationoperator: 23
operands: 24
19ExprRangelambda_map: 25
start_index: 36
end_index: 37
20Lambdaparameter: 49
body: 26
21Lambdaparameter: 49
body: 27
22Lambdaparameter: 49
body: 28
23Literal
24ExprTuple29
25Lambdaparameter: 49
body: 30
26Operationoperator: 43
operand: 42
27Operationoperator: 33
operands: 32
28Operationoperator: 33
operands: 34
29ExprRangelambda_map: 35
start_index: 36
end_index: 37
30Operationoperator: 38
operands: 39
31ExprTuple42
32ExprTuple46, 40
33Literal
34ExprTuple42, 40
35Lambdaparameter: 49
body: 41
36Literal
37Variable
38Literal
39ExprTuple46, 42
40Literal
41Operationoperator: 43
operand: 46
42IndexedVarvariable: 45
index: 49
43Literal
44ExprTuple46
45Variable
46IndexedVarvariable: 47
index: 49
47Variable
48ExprTuple49
49Variable