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, i, j, x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, InSet
from proveit.numbers import Add, Less, Real, 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, b_1_to_j], Conditional(Less(Add(a_1_to_i, x, b_1_to_j), Add(a_1_to_i, y, b_1_to_j)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Real), one, i), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Real), one, j), Less(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())
\left(\left(a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}\right) \mapsto \left\{\left(a_{1} +  a_{2} +  \ldots +  a_{i} + x+ b_{1} +  b_{2} +  \ldots +  b_{j}\right) < \left(a_{1} +  a_{2} +  \ldots +  a_{i} + y+ b_{1} +  b_{2} +  \ldots +  b_{j}\right) \textrm{ if } \left(a_{1} \in \mathbb{R}\right) ,  \left(a_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}\right), \left(b_{1} \in \mathbb{R}\right) ,  \left(b_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(b_{j} \in \mathbb{R}\right) ,  x < y\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
2ExprTuple21, 22
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11ExprRangelambda_map: 17
start_index: 30
end_index: 28
12ExprRangelambda_map: 18
start_index: 30
end_index: 31
13Operationoperator: 19
operands: 20
14ExprTuple21, 25, 22
15Literal
16ExprTuple21, 26, 22
17Lambdaparameter: 41
body: 23
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
26Variable
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