logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple32, 34
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 29
operands: 13
10Operationoperator: 20
operand: 18
11Operationoperator: 35
operands: 15
12ExprRangelambda_map: 16
start_index: 45
end_index: 42
13ExprTuple32, 17, 34
14ExprTuple18
15ExprTuple32, 26
16Lambdaparameter: 49
body: 19
17Operationoperator: 20
operand: 24
18Lambdaparameter: 44
body: 22
19Operationoperator: 35
operands: 23
20Literal
21ExprTuple24
22Conditionalvalue: 25
condition: 31
23ExprTuple46, 26
24Lambdaparameter: 44
body: 28
25Operationoperator: 29
operands: 30
26Literal
27ExprTuple44
28Conditionalvalue: 33
condition: 31
29Literal
30ExprTuple32, 33, 34
31Operationoperator: 35
operands: 36
32IndexedVarvariable: 37
index: 45
33Operationoperator: 39
operands: 40
34ExprRangelambda_map: 41
start_index: 45
end_index: 42
35Literal
36ExprTuple44, 43
37Variable
38ExprTuple45
39Literal
40ExprTuple44, 45
41Lambdaparameter: 49
body: 46
42Literal
43Literal
44Variable
45Literal
46IndexedVarvariable: 47
index: 49
47Variable
48ExprTuple49
49Variable