logo

Expression of type ExprTuple

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 Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, a, b, c, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import And, Forall, InSet
from proveit.numbers import Add, Real, RealNonNeg, greater_eq, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([a_1_to_i, c_1_to_j], Conditional(Forall(instance_param_or_params = [b], instance_expr = greater_eq(Add(a_1_to_i, b, c_1_to_j), b), domain = Real), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), RealNonNeg), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), RealNonNeg), one, j)))))
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())
\left(\left(a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{j}\right) \mapsto \left\{\forall_{b \in \mathbb{R}}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \geq b\right) \textrm{ if } \left(a_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(a_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}^{\ge 0}\right), \left(c_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(c_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{R}^{\ge 0}\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple32, 34
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12
10Lambdaparameter: 33
body: 14
11ExprRangelambda_map: 15
start_index: 38
end_index: 36
12ExprRangelambda_map: 16
start_index: 38
end_index: 39
13ExprTuple33
14Conditionalvalue: 17
condition: 18
15Lambdaparameter: 45
body: 19
16Lambdaparameter: 45
body: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 25
operands: 23
19Operationoperator: 25
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22ExprTuple33, 27
23ExprTuple33, 28
24ExprTuple40, 29
25Literal
26ExprTuple41, 29
27Operationoperator: 30
operands: 31
28Literal
29Literal
30Literal
31ExprTuple32, 33, 34
32ExprRangelambda_map: 35
start_index: 38
end_index: 36
33Variable
34ExprRangelambda_map: 37
start_index: 38
end_index: 39
35Lambdaparameter: 45
body: 40
36Variable
37Lambdaparameter: 45
body: 41
38Literal
39Variable
40IndexedVarvariable: 42
index: 45
41IndexedVarvariable: 43
index: 45
42Variable
43Variable
44ExprTuple45
45Variable