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 b, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import Forall, InSet
from proveit.numbers import Add, Natural, RealNonNeg, RealPos, greater, zero
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [i, j], instance_expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_j], instance_expr = InSet(Add(a_1_to_i, b, c_1_to_j), RealPos), domain = RealNonNeg, condition = greater(b, zero)), 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_{i, j \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j} \in \mathbb{R}^{\ge 0}~|~b > 0}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{R}^+\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
2Lambdaparameters: 3
body: 4
3ExprTuple42, 45
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 20
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 29
body: 13
11Operationoperator: 47
operands: 14
12Operationoperator: 47
operands: 15
13Conditionalvalue: 16
condition: 17
14ExprTuple42, 18
15ExprTuple45, 18
16Operationoperator: 47
operands: 19
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24, 25, 26, 27
22Operationoperator: 28
operands: 29
23Literal
24ExprRangelambda_map: 30
start_index: 44
end_index: 42
25Operationoperator: 47
operands: 31
26ExprRangelambda_map: 32
start_index: 44
end_index: 45
27Operationoperator: 33
operands: 34
28Literal
29ExprTuple35, 40, 36
30Lambdaparameter: 55
body: 37
31ExprTuple40, 51
32Lambdaparameter: 55
body: 38
33Literal
34ExprTuple39, 40
35ExprRangelambda_map: 41
start_index: 44
end_index: 42
36ExprRangelambda_map: 43
start_index: 44
end_index: 45
37Operationoperator: 47
operands: 46
38Operationoperator: 47
operands: 48
39Literal
40Variable
41Lambdaparameter: 55
body: 49
42Variable
43Lambdaparameter: 55
body: 50
44Literal
45Variable
46ExprTuple49, 51
47Literal
48ExprTuple50, 51
49IndexedVarvariable: 52
index: 55
50IndexedVarvariable: 53
index: 55
51Literal
52Variable
53Variable
54ExprTuple55
55Variable