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 Add, Complex, Mult, Natural, 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, b_1_to_j, c_1_to_k], instance_expr = 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), domain = Complex).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}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k} \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 } 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
1ExprTuple58, 50, 63
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 22
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 12
body: 13
9Operationoperator: 44
operands: 14
10Operationoperator: 44
operands: 15
11Operationoperator: 44
operands: 16
12ExprTuple54, 46, 56
13Conditionalvalue: 17
condition: 18
14ExprTuple58, 19
15ExprTuple50, 19
16ExprTuple63, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple26, 27, 28
24Operationoperator: 51
operands: 29
25Operationoperator: 39
operands: 30
26ExprRangelambda_map: 31
start_index: 62
end_index: 58
27ExprRangelambda_map: 32
start_index: 62
end_index: 50
28ExprRangelambda_map: 33
start_index: 62
end_index: 63
29ExprTuple54, 34, 56
30ExprTuple35
31Lambdaparameter: 70
body: 36
32Lambdaparameter: 70
body: 37
33Lambdaparameter: 70
body: 38
34Operationoperator: 39
operands: 40
35ExprRangelambda_map: 41
start_index: 62
end_index: 50
36Operationoperator: 44
operands: 42
37Operationoperator: 44
operands: 43
38Operationoperator: 44
operands: 45
39Literal
40ExprTuple46
41Lambdaparameter: 65
body: 47
42ExprTuple64, 48
43ExprTuple53, 48
44Literal
45ExprTuple66, 48
46ExprRangelambda_map: 49
start_index: 62
end_index: 50
47Operationoperator: 51
operands: 52
48Literal
49Lambdaparameter: 70
body: 53
50Variable
51Literal
52ExprTuple54, 55, 56
53IndexedVarvariable: 59
index: 70
54ExprRangelambda_map: 57
start_index: 62
end_index: 58
55IndexedVarvariable: 59
index: 65
56ExprRangelambda_map: 61
start_index: 62
end_index: 63
57Lambdaparameter: 70
body: 64
58Variable
59Variable
60ExprTuple65
61Lambdaparameter: 70
body: 66
62Literal
63Variable
64IndexedVarvariable: 67
index: 70
65Variable
66IndexedVarvariable: 68
index: 70
67Variable
68Variable
69ExprTuple70
70Variable