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, IndexedVar, Lambda, Variable, a, b, c, i, j, 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 Add, Complex, Mult, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, b_1_to_j, c_1_to_k], Conditional(Equals(Mult(a_1_to_i, Add(b_1_to_j), c_1_to_k), Add(ExprRange(sub_expr1, Mult(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j))).with_wrapping_at(2), And(ExprRange(sub_expr2, InSet(IndexedVar(a, sub_expr2), Complex), one, i), ExprRange(sub_expr2, InSet(IndexedVar(b, sub_expr2), Complex), one, j), ExprRange(sub_expr2, InSet(IndexedVar(c, sub_expr2), 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}, b_{1}, b_{2}, \ldots, b_{j}, 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(b_{1} +  b_{2} +  \ldots +  b_{j}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{1}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{2}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \ldots +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{j}\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(b_{1} \in \mathbb{C}\right) ,  \left(b_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(b_{j} \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
1ExprTuple39, 31, 41
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Operationoperator: 36
operands: 14
10Operationoperator: 24
operands: 15
11ExprRangelambda_map: 16
start_index: 47
end_index: 43
12ExprRangelambda_map: 17
start_index: 47
end_index: 35
13ExprRangelambda_map: 18
start_index: 47
end_index: 48
14ExprTuple39, 19, 41
15ExprTuple20
16Lambdaparameter: 55
body: 21
17Lambdaparameter: 55
body: 22
18Lambdaparameter: 55
body: 23
19Operationoperator: 24
operands: 25
20ExprRangelambda_map: 26
start_index: 47
end_index: 35
21Operationoperator: 29
operands: 27
22Operationoperator: 29
operands: 28
23Operationoperator: 29
operands: 30
24Literal
25ExprTuple31
26Lambdaparameter: 50
body: 32
27ExprTuple49, 33
28ExprTuple38, 33
29Literal
30ExprTuple51, 33
31ExprRangelambda_map: 34
start_index: 47
end_index: 35
32Operationoperator: 36
operands: 37
33Literal
34Lambdaparameter: 55
body: 38
35Variable
36Literal
37ExprTuple39, 40, 41
38IndexedVarvariable: 44
index: 55
39ExprRangelambda_map: 42
start_index: 47
end_index: 43
40IndexedVarvariable: 44
index: 50
41ExprRangelambda_map: 46
start_index: 47
end_index: 48
42Lambdaparameter: 55
body: 49
43Variable
44Variable
45ExprTuple50
46Lambdaparameter: 55
body: 51
47Literal
48Variable
49IndexedVarvariable: 52
index: 55
50Variable
51IndexedVarvariable: 53
index: 55
52Variable
53Variable
54ExprTuple55
55Variable