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, b, j
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 Abs, 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([b_1_to_j], Conditional(Equals(Mult(a_1_to_i, Abs(Add(b_1_to_j)), c_1_to_k), Abs(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(b, sub_expr2), Complex), one, j)))))
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(b_{1}, b_{2}, \ldots, b_{j}\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(b_{1} \in \mathbb{C}\right) \land  \left(b_{2} \in \mathbb{C}\right) \land  \ldots \land  \left(b_{j} \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: 27
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11
9Operationoperator: 33
operands: 12
10Operationoperator: 18
operand: 16
11ExprRangelambda_map: 14
start_index: 44
end_index: 32
12ExprTuple36, 15, 38
13ExprTuple16
14Lambdaparameter: 52
body: 17
15Operationoperator: 18
operand: 23
16Operationoperator: 26
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19ExprTuple23
20ExprTuple24
21Literal
22ExprTuple35, 25
23Operationoperator: 26
operands: 27
24ExprRangelambda_map: 28
start_index: 44
end_index: 32
25Literal
26Literal
27ExprTuple29
28Lambdaparameter: 47
body: 30
29ExprRangelambda_map: 31
start_index: 44
end_index: 32
30Operationoperator: 33
operands: 34
31Lambdaparameter: 52
body: 35
32Variable
33Literal
34ExprTuple36, 37, 38
35IndexedVarvariable: 41
index: 52
36ExprRangelambda_map: 39
start_index: 44
end_index: 40
37IndexedVarvariable: 41
index: 47
38ExprRangelambda_map: 43
start_index: 44
end_index: 45
39Lambdaparameter: 52
body: 46
40Variable
41Variable
42ExprTuple47
43Lambdaparameter: 52
body: 48
44Literal
45Variable
46IndexedVarvariable: 49
index: 52
47Variable
48IndexedVarvariable: 50
index: 52
49Variable
50Variable
51ExprTuple52
52Variable