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, InSet
from proveit.numbers import Add, Less, RealNeg, RealNonPos, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([a_1_to_i, b, c_1_to_j], Conditional(InSet(Add(a_1_to_i, b, c_1_to_j), RealNeg), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), RealNonPos), one, i), InSet(b, RealNonPos), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), RealNonPos), one, j), Less(b, zero)))))
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}, b, c_{1}, c_{2}, \ldots, c_{j}\right) \mapsto \left\{\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{R}^- \textrm{ if } \left(a_{1} \in \mathbb{R}^{\le 0}\right) ,  \left(a_{2} \in \mathbb{R}^{\le 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}^{\le 0}\right) ,  b \in \mathbb{R}^{\le 0}, \left(c_{1} \in \mathbb{R}^{\le 0}\right) ,  \left(c_{2} \in \mathbb{R}^{\le 0}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{R}^{\le 0}\right) ,  b < 0\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: 15
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 33
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12, 13
8Operationoperator: 14
operands: 15
9Literal
10ExprRangelambda_map: 16
start_index: 30
end_index: 28
11Operationoperator: 33
operands: 17
12ExprRangelambda_map: 18
start_index: 30
end_index: 31
13Operationoperator: 19
operands: 20
14Literal
15ExprTuple21, 25, 22
16Lambdaparameter: 41
body: 23
17ExprTuple25, 37
18Lambdaparameter: 41
body: 24
19Literal
20ExprTuple25, 26
21ExprRangelambda_map: 27
start_index: 30
end_index: 28
22ExprRangelambda_map: 29
start_index: 30
end_index: 31
23Operationoperator: 33
operands: 32
24Operationoperator: 33
operands: 34
25Variable
26Literal
27Lambdaparameter: 41
body: 35
28Variable
29Lambdaparameter: 41
body: 36
30Literal
31Variable
32ExprTuple35, 37
33Literal
34ExprTuple36, 37
35IndexedVarvariable: 38
index: 41
36IndexedVarvariable: 39
index: 41
37Literal
38Variable
39Variable
40ExprTuple41
41Variable