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, 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, Natural, RealNonNeg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
expr = Lambda([i, j, k], Conditional(Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = 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(), domain = RealNonNeg).with_wrapping(), And(InSet(i, Natural), InSet(j, Natural), InSet(k, Natural))))
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(i, j, k\right) \mapsto \left\{\begin{array}{l}\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k} \in \mathbb{R}^{\ge 0}}~\\
\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}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \in \mathbb{N}\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
1ExprTuple70, 62, 75
2Conditionalvalue: 3
condition: 4
3Operationoperator: 19
operand: 7
4Operationoperator: 34
operands: 6
5ExprTuple7
6ExprTuple8, 9, 10
7Lambdaparameters: 11
body: 12
8Operationoperator: 51
operands: 13
9Operationoperator: 51
operands: 14
10Operationoperator: 51
operands: 15
11ExprTuple66, 68
12Conditionalvalue: 16
condition: 17
13ExprTuple70, 18
14ExprTuple62, 18
15ExprTuple75, 18
16Operationoperator: 19
operand: 22
17Operationoperator: 34
operands: 21
18Literal
19Literal
20ExprTuple22
21ExprTuple23, 24
22Lambdaparameters: 57
body: 25
23ExprRangelambda_map: 26
start_index: 74
end_index: 70
24ExprRangelambda_map: 27
start_index: 74
end_index: 75
25Conditionalvalue: 28
condition: 29
26Lambdaparameter: 82
body: 30
27Lambdaparameter: 82
body: 31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operands: 35
30Operationoperator: 51
operands: 36
31Operationoperator: 51
operands: 37
32Literal
33ExprTuple38, 39
34Literal
35ExprTuple40
36ExprTuple76, 41
37ExprTuple78, 41
38Operationoperator: 63
operands: 42
39Operationoperator: 48
operand: 46
40ExprRangelambda_map: 44
start_index: 74
end_index: 62
41Literal
42ExprTuple66, 45, 68
43ExprTuple46
44Lambdaparameter: 82
body: 47
45Operationoperator: 48
operand: 53
46Operationoperator: 56
operands: 50
47Operationoperator: 51
operands: 52
48Literal
49ExprTuple53
50ExprTuple54
51Literal
52ExprTuple65, 55
53Operationoperator: 56
operands: 57
54ExprRangelambda_map: 58
start_index: 74
end_index: 62
55Literal
56Literal
57ExprTuple59
58Lambdaparameter: 77
body: 60
59ExprRangelambda_map: 61
start_index: 74
end_index: 62
60Operationoperator: 63
operands: 64
61Lambdaparameter: 82
body: 65
62Variable
63Literal
64ExprTuple66, 67, 68
65IndexedVarvariable: 71
index: 82
66ExprRangelambda_map: 69
start_index: 74
end_index: 70
67IndexedVarvariable: 71
index: 77
68ExprRangelambda_map: 73
start_index: 74
end_index: 75
69Lambdaparameter: 82
body: 76
70Variable
71Variable
72ExprTuple77
73Lambdaparameter: 82
body: 78
74Literal
75Variable
76IndexedVarvariable: 79
index: 82
77Variable
78IndexedVarvariable: 80
index: 82
79Variable
80Variable
81ExprTuple82
82Variable