logo

Expression of type Forall

from the theory of proveit.numbers.addition

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 x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import Forall
from proveit.numbers import Add, LessEq, Real
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [x, y], instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j], instance_expr = LessEq(Add(a_1_to_i, x, b_1_to_j), Add(a_1_to_i, y, b_1_to_j)), domain = Real, condition = LessEq(x, y)))
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_{x, y}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j} \in \mathbb{R}~|~x \leq y}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + x+ b_{1} +  b_{2} +  \ldots +  b_{j}\right) \leq \left(a_{1} +  a_{2} +  \ldots +  a_{i} + y+ b_{1} +  b_{2} +  \ldots +  b_{j}\right)\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: 4
operand: 2
1ExprTuple2
2Lambdaparameters: 25
body: 3
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple26, 27
8Conditionalvalue: 9
condition: 10
9Operationoperator: 24
operands: 11
10Operationoperator: 12
operands: 13
11ExprTuple14, 15
12Literal
13ExprTuple16, 17, 18
14Operationoperator: 20
operands: 19
15Operationoperator: 20
operands: 21
16ExprRangelambda_map: 22
start_index: 35
end_index: 33
17ExprRangelambda_map: 23
start_index: 35
end_index: 36
18Operationoperator: 24
operands: 25
19ExprTuple26, 30, 27
20Literal
21ExprTuple26, 31, 27
22Lambdaparameter: 46
body: 28
23Lambdaparameter: 46
body: 29
24Literal
25ExprTuple30, 31
26ExprRangelambda_map: 32
start_index: 35
end_index: 33
27ExprRangelambda_map: 34
start_index: 35
end_index: 36
28Operationoperator: 38
operands: 37
29Operationoperator: 38
operands: 39
30Variable
31Variable
32Lambdaparameter: 46
body: 40
33Variable
34Lambdaparameter: 46
body: 41
35Literal
36Variable
37ExprTuple40, 42
38Literal
39ExprTuple41, 42
40IndexedVarvariable: 43
index: 46
41IndexedVarvariable: 44
index: 46
42Literal
43Variable
44Variable
45ExprTuple46
46Variable