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, C, ExprRange, IndexedVar, Variable, m
from proveit.core_expr_types import A_1_to_m
from proveit.logic import Boolean, Forall, Implies, Or
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [A_1_to_m], instance_expr = Forall(instance_param_or_params = [C], instance_expr = C, condition = ExprRange(sub_expr1, Implies(IndexedVar(A, sub_expr1), C), one, m)), domain = Boolean, condition = Or(A_1_to_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} \in \mathbb{B}~|~A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m}}~\left[\forall_{C~|~\left(A_{1} \Rightarrow C\right), \left(A_{2} \Rightarrow C\right), \ldots, \left(A_{m} \Rightarrow C\right)}~C\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: 14
operand: 2
1ExprTuple2
2Lambdaparameter: 37
body: 4
3ExprTuple37
4Conditionalvalue: 5
condition: 6
5Operationoperator: 14
operand: 9
6Operationoperator: 30
operands: 8
7ExprTuple9
8ExprTuple37, 10
9Lambdaparameters: 24
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 17
13Operationoperator: 28
operands: 16
14Literal
15ExprTuple17
16ExprTuple18, 19
17Lambdaparameter: 42
body: 21
18ExprRangelambda_map: 22
start_index: 36
end_index: 37
19Operationoperator: 23
operands: 24
20ExprTuple42
21Conditionalvalue: 42
condition: 25
22Lambdaparameter: 45
body: 26
23Literal
24ExprTuple27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprRangelambda_map: 32
start_index: 36
end_index: 37
28Literal
29ExprTuple33
30Literal
31ExprTuple41, 34
32Lambdaparameter: 45
body: 41
33ExprRangelambda_map: 35
start_index: 36
end_index: 37
34Literal
35Lambdaparameter: 45
body: 38
36Literal
37Variable
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41IndexedVarvariable: 43
index: 45
42Variable
43Variable
44ExprTuple45
45Variable