logo

Expression of type ExprTuple

from the theory of proveit.numbers.multiplication

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, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Complex, Mult, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([a_1_to_i, b_1_to_j, c_1_to_k], Conditional(Equals(Mult(a_1_to_i, Add(b_1_to_j), c_1_to_k), Add(ExprRange(sub_expr1, Mult(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j))).with_wrapping_at(2), And(ExprRange(sub_expr2, InSet(IndexedVar(a, sub_expr2), Complex), one, i), ExprRange(sub_expr2, InSet(IndexedVar(b, sub_expr2), Complex), one, j), ExprRange(sub_expr2, InSet(IndexedVar(c, sub_expr2), 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_{1}, c_{2}, \ldots, c_{k}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{1}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{2}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \ldots +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{j}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right)\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), \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{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: 2
body: 3
2ExprTuple40, 32, 42
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10Operationoperator: 37
operands: 15
11Operationoperator: 25
operands: 16
12ExprRangelambda_map: 17
start_index: 48
end_index: 44
13ExprRangelambda_map: 18
start_index: 48
end_index: 36
14ExprRangelambda_map: 19
start_index: 48
end_index: 49
15ExprTuple40, 20, 42
16ExprTuple21
17Lambdaparameter: 56
body: 22
18Lambdaparameter: 56
body: 23
19Lambdaparameter: 56
body: 24
20Operationoperator: 25
operands: 26
21ExprRangelambda_map: 27
start_index: 48
end_index: 36
22Operationoperator: 30
operands: 28
23Operationoperator: 30
operands: 29
24Operationoperator: 30
operands: 31
25Literal
26ExprTuple32
27Lambdaparameter: 51
body: 33
28ExprTuple50, 34
29ExprTuple39, 34
30Literal
31ExprTuple52, 34
32ExprRangelambda_map: 35
start_index: 48
end_index: 36
33Operationoperator: 37
operands: 38
34Literal
35Lambdaparameter: 56
body: 39
36Variable
37Literal
38ExprTuple40, 41, 42
39IndexedVarvariable: 45
index: 56
40ExprRangelambda_map: 43
start_index: 48
end_index: 44
41IndexedVarvariable: 45
index: 51
42ExprRangelambda_map: 47
start_index: 48
end_index: 49
43Lambdaparameter: 56
body: 50
44Variable
45Variable
46ExprTuple51
47Lambdaparameter: 56
body: 52
48Literal
49Variable
50IndexedVarvariable: 53
index: 56
51Variable
52IndexedVarvariable: 54
index: 56
53Variable
54Variable
55ExprTuple56
56Variable