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, sub_expr1)
sub_expr4 = IndexedVar(c, one)
sub_expr5 = Add(l, one)
sub_expr6 = ExprRange(sub_expr1, sub_expr3, one, zero)
expr = ExprTuple(Lambda([sub_expr6, sub_expr4], Conditional(Equals(Mult(sub_expr6, Sum(index_or_indices = sub_expr2, summand = sub_expr5, domain = Integer), sub_expr4), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr6, sub_expr5, sub_expr4), domain = Integer)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(sub_expr3, Complex), one, zero), InSet(sub_expr4, Complex)))))
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_{0}, c_{1}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{0} \cdot \left[\sum_{l \in \mathbb{Z}}~\left(l + 1\right)\right] \cdot c_{1}\right) =  \\ \left[\sum_{l \in \mathbb{Z}}~\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{0} \cdot \left(l + 1\right) \cdot c_{1}\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_{0} \in \mathbb{C}\right) ,  c_{1} \in \mathbb{C}\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
12ExprRangelambda_map: 16
start_index: 47
end_index: 39
13Operationoperator: 36
operands: 17
14ExprTuple33, 18, 35
15ExprTuple19
16Lambdaparameter: 50
body: 20
17ExprTuple35, 27
18Operationoperator: 21
operand: 25
19Lambdaparameter: 46
body: 23
20Operationoperator: 36
operands: 24
21Literal
22ExprTuple25
23Conditionalvalue: 26
condition: 32
24ExprTuple45, 27
25Lambdaparameter: 46
body: 29
26Operationoperator: 30
operands: 31
27Literal
28ExprTuple46
29Conditionalvalue: 34
condition: 32
30Literal
31ExprTuple33, 34, 35
32Operationoperator: 36
operands: 37
33ExprRangelambda_map: 38
start_index: 47
end_index: 39
34Operationoperator: 40
operands: 41
35IndexedVarvariable: 42
index: 47
36Literal
37ExprTuple46, 44
38Lambdaparameter: 50
body: 45
39Literal
40Literal
41ExprTuple46, 47
42Variable
43ExprTuple47
44Literal
45IndexedVarvariable: 48
index: 50
46Variable
47Literal
48Variable
49ExprTuple50
50Variable