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, sub_expr1)
sub_expr4 = IndexedVar(c, one)
sub_expr5 = Add(l, one)
sub_expr6 = ExprRange(sub_expr1, sub_expr3, one, zero)
expr = 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(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..
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
11ExprRangelambda_map: 15
start_index: 46
end_index: 38
12Operationoperator: 35
operands: 16
13ExprTuple32, 17, 34
14ExprTuple18
15Lambdaparameter: 49
body: 19
16ExprTuple34, 26
17Operationoperator: 20
operand: 24
18Lambdaparameter: 45
body: 22
19Operationoperator: 35
operands: 23
20Literal
21ExprTuple24
22Conditionalvalue: 25
condition: 31
23ExprTuple44, 26
24Lambdaparameter: 45
body: 28
25Operationoperator: 29
operands: 30
26Literal
27ExprTuple45
28Conditionalvalue: 33
condition: 31
29Literal
30ExprTuple32, 33, 34
31Operationoperator: 35
operands: 36
32ExprRangelambda_map: 37
start_index: 46
end_index: 38
33Operationoperator: 39
operands: 40
34IndexedVarvariable: 41
index: 46
35Literal
36ExprTuple45, 43
37Lambdaparameter: 49
body: 44
38Literal
39Literal
40ExprTuple45, 46
41Variable
42ExprTuple46
43Literal
44IndexedVarvariable: 47
index: 49
45Variable
46Literal
47Variable
48ExprTuple49
49Variable