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, Forall, InSet
from proveit.numbers import Abs, Add, Complex, Mult, RealNonNeg, 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, c_1_to_k], Conditional(Forall(instance_param_or_params = [b_1_to_j], instance_expr = 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), domain = Complex).with_wrapping(), And(ExprRange(sub_expr2, InSet(IndexedVar(a, sub_expr2), RealNonNeg), one, i), ExprRange(sub_expr2, InSet(IndexedVar(c, sub_expr2), RealNonNeg), 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}, c_{1}, c_{2}, \ldots, c_{k}\right) \mapsto \left\{\begin{array}{l}\forall_{b_{1}, b_{2}, \ldots, b_{j} \in \mathbb{C}}~\\
\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}\right)\end{array} \textrm{ if } \left(a_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(a_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}^{\ge 0}\right), \left(c_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(c_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(c_{k} \in \mathbb{R}^{\ge 0}\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
2ExprTuple53, 55
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 21
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 44
body: 12
10ExprRangelambda_map: 13
start_index: 61
end_index: 57
11ExprRangelambda_map: 14
start_index: 61
end_index: 62
12Conditionalvalue: 15
condition: 16
13Lambdaparameter: 69
body: 17
14Lambdaparameter: 69
body: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operands: 22
17Operationoperator: 38
operands: 23
18Operationoperator: 38
operands: 24
19Literal
20ExprTuple25, 26
21Literal
22ExprTuple27
23ExprTuple63, 28
24ExprTuple65, 28
25Operationoperator: 50
operands: 29
26Operationoperator: 35
operand: 33
27ExprRangelambda_map: 31
start_index: 61
end_index: 49
28Literal
29ExprTuple53, 32, 55
30ExprTuple33
31Lambdaparameter: 69
body: 34
32Operationoperator: 35
operand: 40
33Operationoperator: 43
operands: 37
34Operationoperator: 38
operands: 39
35Literal
36ExprTuple40
37ExprTuple41
38Literal
39ExprTuple52, 42
40Operationoperator: 43
operands: 44
41ExprRangelambda_map: 45
start_index: 61
end_index: 49
42Literal
43Literal
44ExprTuple46
45Lambdaparameter: 64
body: 47
46ExprRangelambda_map: 48
start_index: 61
end_index: 49
47Operationoperator: 50
operands: 51
48Lambdaparameter: 69
body: 52
49Variable
50Literal
51ExprTuple53, 54, 55
52IndexedVarvariable: 58
index: 69
53ExprRangelambda_map: 56
start_index: 61
end_index: 57
54IndexedVarvariable: 58
index: 64
55ExprRangelambda_map: 60
start_index: 61
end_index: 62
56Lambdaparameter: 69
body: 63
57Variable
58Variable
59ExprTuple64
60Lambdaparameter: 69
body: 65
61Literal
62Variable
63IndexedVarvariable: 66
index: 69
64Variable
65IndexedVarvariable: 67
index: 69
66Variable
67Variable
68ExprTuple69
69Variable