logo

Expression of type ExprTuple

from the theory of proveit.numbers.summation

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, c, l
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Complex, Integer, Mult, Sum, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = IndexedVar(a, one)
sub_expr4 = IndexedVar(c, sub_expr1)
sub_expr5 = Add(l, one)
sub_expr6 = ExprRange(sub_expr1, sub_expr4, one, zero)
expr = ExprTuple(Lambda([sub_expr3, sub_expr6], Conditional(Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr2, summand = sub_expr5, domain = Integer), sub_expr6), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr3, sub_expr5, sub_expr6), domain = Integer)).with_wrapping_at(2), And(InSet(sub_expr3, Complex), ExprRange(sub_expr1, InSet(sub_expr4, Complex), one, zero)))))
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}, c_{1}, c_{2}, \ldots, c_{0}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot \left[\sum_{l \in \mathbb{Z}}~\left(l + 1\right)\right]\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right) =  \\ \left[\sum_{l \in \mathbb{Z}}~\left(a_{1} \cdot \left(l + 1\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right)\right] \end{array} \end{array} \textrm{ if } a_{1} \in \mathbb{C}, \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{0} \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
2ExprTuple33, 35
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 30
operands: 14
11Operationoperator: 21
operand: 19
12Operationoperator: 36
operands: 16
13ExprRangelambda_map: 17
start_index: 46
end_index: 43
14ExprTuple33, 18, 35
15ExprTuple19
16ExprTuple33, 27
17Lambdaparameter: 50
body: 20
18Operationoperator: 21
operand: 25
19Lambdaparameter: 45
body: 23
20Operationoperator: 36
operands: 24
21Literal
22ExprTuple25
23Conditionalvalue: 26
condition: 32
24ExprTuple47, 27
25Lambdaparameter: 45
body: 29
26Operationoperator: 30
operands: 31
27Literal
28ExprTuple45
29Conditionalvalue: 34
condition: 32
30Literal
31ExprTuple33, 34, 35
32Operationoperator: 36
operands: 37
33IndexedVarvariable: 38
index: 46
34Operationoperator: 40
operands: 41
35ExprRangelambda_map: 42
start_index: 46
end_index: 43
36Literal
37ExprTuple45, 44
38Variable
39ExprTuple46
40Literal
41ExprTuple45, 46
42Lambdaparameter: 50
body: 47
43Literal
44Literal
45Variable
46Literal
47IndexedVarvariable: 48
index: 50
48Variable
49ExprTuple50
50Variable