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, Function, IndexedVar, Lambda, Q, Variable, a, c, f, i, 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 Complex, Mult, Sum, one
from proveit.numbers.summation import summation_b1toj_fQ
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [b_1_to_j]
expr = ExprTuple(Lambda([a_1_to_i, c_1_to_k], Conditional(Equals(Mult(a_1_to_i, summation_b1toj_fQ, c_1_to_k), Sum(index_or_indices = sub_expr2, summand = Mult(a_1_to_i, Function(f, sub_expr2), c_1_to_k), condition = Function(Q, sub_expr2))).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, 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}, 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[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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(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
2ExprTuple35, 37
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 32
operands: 14
11Operationoperator: 22
operand: 19
12ExprRangelambda_map: 16
start_index: 50
end_index: 40
13ExprRangelambda_map: 17
start_index: 50
end_index: 44
14ExprTuple35, 18, 37
15ExprTuple19
16Lambdaparameter: 56
body: 20
17Lambdaparameter: 56
body: 21
18Operationoperator: 22
operand: 28
19Lambdaparameters: 42
body: 24
20Operationoperator: 26
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28
24Conditionalvalue: 29
condition: 34
25ExprTuple45, 30
26Literal
27ExprTuple47, 30
28Lambdaparameters: 42
body: 31
29Operationoperator: 32
operands: 33
30Literal
31Conditionalvalue: 36
condition: 34
32Literal
33ExprTuple35, 36, 37
34Operationoperator: 38
operands: 42
35ExprRangelambda_map: 39
start_index: 50
end_index: 40
36Operationoperator: 41
operands: 42
37ExprRangelambda_map: 43
start_index: 50
end_index: 44
38Variable
39Lambdaparameter: 56
body: 45
40Variable
41Variable
42ExprTuple46
43Lambdaparameter: 56
body: 47
44Variable
45IndexedVarvariable: 48
index: 56
46ExprRangelambda_map: 49
start_index: 50
end_index: 51
47IndexedVarvariable: 52
index: 56
48Variable
49Lambdaparameter: 56
body: 53
50Literal
51Variable
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable