logo

Expression of type ExprTuple

from the theory of proveit.numbers.addition.subtraction

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, e, i, j, k
from proveit.core_expr_types import a_1_to_i, c_1_to_j, e_1_to_k
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Complex, Neg, 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, c_1_to_j, d, e_1_to_k], Conditional(Equals(Add(a_1_to_i, b, c_1_to_j, Neg(d), e_1_to_k), Add(a_1_to_i, c_1_to_j, e_1_to_k)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), InSet(b, Complex), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), Complex), one, j), InSet(d, Complex), ExprRange(sub_expr1, InSet(IndexedVar(e, sub_expr1), Complex), one, k), Equals(b, d)))))
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}, d, e_{1}, e_{2}, \ldots, e_{k}\right) \mapsto \left\{\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j} - d+ e_{1} +  e_{2} +  \ldots +  e_{k}\right) = \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ c_{1} +  c_{2} +  \ldots +  c_{j}+ e_{1} +  e_{2} +  \ldots +  e_{k}\right) \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right) ,  b \in \mathbb{C}, \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{C}\right) ,  d \in \mathbb{C}, \left(e_{1} \in \mathbb{C}\right) ,  \left(e_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(e_{k} \in \mathbb{C}\right) ,  b = d\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
2ExprTuple28, 34, 29, 48, 30
3Conditionalvalue: 4
condition: 5
4Operationoperator: 25
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14, 15, 16
9Operationoperator: 18
operands: 17
10Operationoperator: 18
operands: 19
11ExprRangelambda_map: 20
start_index: 42
end_index: 38
12Operationoperator: 46
operands: 21
13ExprRangelambda_map: 22
start_index: 42
end_index: 40
14Operationoperator: 46
operands: 23
15ExprRangelambda_map: 24
start_index: 42
end_index: 43
16Operationoperator: 25
operands: 26
17ExprTuple28, 34, 29, 27, 30
18Literal
19ExprTuple28, 29, 30
20Lambdaparameter: 57
body: 31
21ExprTuple34, 52
22Lambdaparameter: 57
body: 32
23ExprTuple48, 52
24Lambdaparameter: 57
body: 33
25Literal
26ExprTuple34, 48
27Operationoperator: 35
operand: 48
28ExprRangelambda_map: 37
start_index: 42
end_index: 38
29ExprRangelambda_map: 39
start_index: 42
end_index: 40
30ExprRangelambda_map: 41
start_index: 42
end_index: 43
31Operationoperator: 46
operands: 44
32Operationoperator: 46
operands: 45
33Operationoperator: 46
operands: 47
34Variable
35Literal
36ExprTuple48
37Lambdaparameter: 57
body: 49
38Variable
39Lambdaparameter: 57
body: 50
40Variable
41Lambdaparameter: 57
body: 51
42Literal
43Variable
44ExprTuple49, 52
45ExprTuple50, 52
46Literal
47ExprTuple51, 52
48Variable
49IndexedVarvariable: 53
index: 57
50IndexedVarvariable: 54
index: 57
51IndexedVarvariable: 55
index: 57
52Literal
53Variable
54Variable
55Variable
56ExprTuple57
57Variable