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, Forall, InSet
from proveit.numbers import Abs, Add, Complex, Mult, RealNonNeg, 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, c_1_to_k], Conditional(Forall(instance_param_or_params = [b_1_to_j], instance_expr = 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), domain = Complex).with_wrapping(), And(ExprRange(sub_expr2, InSet(IndexedVar(a, sub_expr2), RealNonNeg), one, i), ExprRange(sub_expr2, InSet(IndexedVar(c, sub_expr2), RealNonNeg), 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}{l}\forall_{b_{1}, b_{2}, \ldots, b_{j} \in \mathbb{C}}~\\
\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}\right)\end{array} \textrm{ if } \left(a_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(a_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}^{\ge 0}\right), \left(c_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(c_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(c_{k} \in \mathbb{R}^{\ge 0}\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
1ExprTuple52, 54
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 20
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 43
body: 11
9ExprRangelambda_map: 12
start_index: 60
end_index: 56
10ExprRangelambda_map: 13
start_index: 60
end_index: 61
11Conditionalvalue: 14
condition: 15
12Lambdaparameter: 68
body: 16
13Lambdaparameter: 68
body: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operands: 21
16Operationoperator: 37
operands: 22
17Operationoperator: 37
operands: 23
18Literal
19ExprTuple24, 25
20Literal
21ExprTuple26
22ExprTuple62, 27
23ExprTuple64, 27
24Operationoperator: 49
operands: 28
25Operationoperator: 34
operand: 32
26ExprRangelambda_map: 30
start_index: 60
end_index: 48
27Literal
28ExprTuple52, 31, 54
29ExprTuple32
30Lambdaparameter: 68
body: 33
31Operationoperator: 34
operand: 39
32Operationoperator: 42
operands: 36
33Operationoperator: 37
operands: 38
34Literal
35ExprTuple39
36ExprTuple40
37Literal
38ExprTuple51, 41
39Operationoperator: 42
operands: 43
40ExprRangelambda_map: 44
start_index: 60
end_index: 48
41Literal
42Literal
43ExprTuple45
44Lambdaparameter: 63
body: 46
45ExprRangelambda_map: 47
start_index: 60
end_index: 48
46Operationoperator: 49
operands: 50
47Lambdaparameter: 68
body: 51
48Variable
49Literal
50ExprTuple52, 53, 54
51IndexedVarvariable: 57
index: 68
52ExprRangelambda_map: 55
start_index: 60
end_index: 56
53IndexedVarvariable: 57
index: 63
54ExprRangelambda_map: 59
start_index: 60
end_index: 61
55Lambdaparameter: 68
body: 62
56Variable
57Variable
58ExprTuple63
59Lambdaparameter: 68
body: 64
60Literal
61Variable
62IndexedVarvariable: 65
index: 68
63Variable
64IndexedVarvariable: 66
index: 68
65Variable
66Variable
67ExprTuple68
68Variable