logo

Expression of type Lambda

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, 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 = 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(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..
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
1ExprTuple34, 36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 31
operands: 13
10Operationoperator: 21
operand: 18
11ExprRangelambda_map: 15
start_index: 49
end_index: 39
12ExprRangelambda_map: 16
start_index: 49
end_index: 43
13ExprTuple34, 17, 36
14ExprTuple18
15Lambdaparameter: 55
body: 19
16Lambdaparameter: 55
body: 20
17Operationoperator: 21
operand: 27
18Lambdaparameters: 41
body: 23
19Operationoperator: 25
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22ExprTuple27
23Conditionalvalue: 28
condition: 33
24ExprTuple44, 29
25Literal
26ExprTuple46, 29
27Lambdaparameters: 41
body: 30
28Operationoperator: 31
operands: 32
29Literal
30Conditionalvalue: 35
condition: 33
31Literal
32ExprTuple34, 35, 36
33Operationoperator: 37
operands: 41
34ExprRangelambda_map: 38
start_index: 49
end_index: 39
35Operationoperator: 40
operands: 41
36ExprRangelambda_map: 42
start_index: 49
end_index: 43
37Variable
38Lambdaparameter: 55
body: 44
39Variable
40Variable
41ExprTuple45
42Lambdaparameter: 55
body: 46
43Variable
44IndexedVarvariable: 47
index: 55
45ExprRangelambda_map: 48
start_index: 49
end_index: 50
46IndexedVarvariable: 51
index: 55
47Variable
48Lambdaparameter: 55
body: 52
49Literal
50Variable
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable