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, d, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, d_1_to_k
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Complex, 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, c, d_1_to_k], Conditional(Equals(Add(a_1_to_i, b_1_to_j, c, d_1_to_k), Add(a_1_to_i, c, b_1_to_j, d_1_to_k)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j), InSet(c, Complex), ExprRange(sub_expr1, InSet(IndexedVar(d, sub_expr1), Complex), one, k)))))
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}, c, d_{1}, d_{2}, \ldots, d_{k}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ b_{1} +  b_{2} +  \ldots +  b_{j} + c+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) =  \\ \left(a_{1} +  a_{2} +  \ldots +  a_{i} + c+ b_{1} +  b_{2} +  \ldots +  b_{j}+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) \end{array} \end{array} \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right), \left(b_{1} \in \mathbb{C}\right) ,  \left(b_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(b_{j} \in \mathbb{C}\right) ,  c \in \mathbb{C}, \left(d_{1} \in \mathbb{C}\right) ,  \left(d_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(d_{k} \in \mathbb{C}\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: 15
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14
9Operationoperator: 16
operands: 15
10Operationoperator: 16
operands: 17
11ExprRangelambda_map: 18
start_index: 34
end_index: 30
12ExprRangelambda_map: 19
start_index: 34
end_index: 32
13Operationoperator: 38
operands: 20
14ExprRangelambda_map: 21
start_index: 34
end_index: 35
15ExprTuple22, 23, 27, 24
16Literal
17ExprTuple22, 27, 23, 24
18Lambdaparameter: 48
body: 25
19Lambdaparameter: 48
body: 26
20ExprTuple27, 43
21Lambdaparameter: 48
body: 28
22ExprRangelambda_map: 29
start_index: 34
end_index: 30
23ExprRangelambda_map: 31
start_index: 34
end_index: 32
24ExprRangelambda_map: 33
start_index: 34
end_index: 35
25Operationoperator: 38
operands: 36
26Operationoperator: 38
operands: 37
27Variable
28Operationoperator: 38
operands: 39
29Lambdaparameter: 48
body: 40
30Variable
31Lambdaparameter: 48
body: 41
32Variable
33Lambdaparameter: 48
body: 42
34Literal
35Variable
36ExprTuple40, 43
37ExprTuple41, 43
38Literal
39ExprTuple42, 43
40IndexedVarvariable: 44
index: 48
41IndexedVarvariable: 45
index: 48
42IndexedVarvariable: 46
index: 48
43Literal
44Variable
45Variable
46Variable
47ExprTuple48
48Variable