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, b, j
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 Abs, 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([b_1_to_j], Conditional(Equals(Mult(a_1_to_i, Abs(Add(b_1_to_j)), c_1_to_k), Abs(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(b, sub_expr2), Complex), one, j))))
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(b_{1}, b_{2}, \ldots, b_{j}\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(b_{1} \in \mathbb{C}\right) \land  \left(b_{2} \in \mathbb{C}\right) \land  \ldots \land  \left(b_{j} \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: 26
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10
8Operationoperator: 32
operands: 11
9Operationoperator: 17
operand: 15
10ExprRangelambda_map: 13
start_index: 43
end_index: 31
11ExprTuple35, 14, 37
12ExprTuple15
13Lambdaparameter: 51
body: 16
14Operationoperator: 17
operand: 22
15Operationoperator: 25
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18ExprTuple22
19ExprTuple23
20Literal
21ExprTuple34, 24
22Operationoperator: 25
operands: 26
23ExprRangelambda_map: 27
start_index: 43
end_index: 31
24Literal
25Literal
26ExprTuple28
27Lambdaparameter: 46
body: 29
28ExprRangelambda_map: 30
start_index: 43
end_index: 31
29Operationoperator: 32
operands: 33
30Lambdaparameter: 51
body: 34
31Variable
32Literal
33ExprTuple35, 36, 37
34IndexedVarvariable: 40
index: 51
35ExprRangelambda_map: 38
start_index: 43
end_index: 39
36IndexedVarvariable: 40
index: 46
37ExprRangelambda_map: 42
start_index: 43
end_index: 44
38Lambdaparameter: 51
body: 45
39Variable
40Variable
41ExprTuple46
42Lambdaparameter: 51
body: 47
43Literal
44Variable
45IndexedVarvariable: 48
index: 51
46Variable
47IndexedVarvariable: 49
index: 51
48Variable
49Variable
50ExprTuple51
51Variable