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, d, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, d_1_to_k
from proveit.logic import And, Equals, InSet
from proveit.numbers import Complex, Mult, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, b_1_to_j, c, d_1_to_k], Conditional(Equals(Mult(a_1_to_i, b_1_to_j, c, d_1_to_k), Mult(a_1_to_i, c, b_1_to_j, d_1_to_k)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j), InSet(c, Complex), ExprRange(sub_expr1, InSet(IndexedVar(d, sub_expr1), 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, d_{1}, d_{2}, \ldots, d_{k}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i}\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j} \cdot c\cdot d_{1} \cdot  d_{2} \cdot  \ldots \cdot  d_{k}\right) =  \\ \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot c\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\cdot d_{1} \cdot  d_{2} \cdot  \ldots \cdot  d_{k}\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) ,  c \in \mathbb{C}, \left(d_{1} \in \mathbb{C}\right) ,  \left(d_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(d_{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: 14
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12, 13
8Operationoperator: 15
operands: 14
9Operationoperator: 15
operands: 16
10ExprRangelambda_map: 17
start_index: 33
end_index: 29
11ExprRangelambda_map: 18
start_index: 33
end_index: 31
12Operationoperator: 37
operands: 19
13ExprRangelambda_map: 20
start_index: 33
end_index: 34
14ExprTuple21, 22, 26, 23
15Literal
16ExprTuple21, 26, 22, 23
17Lambdaparameter: 47
body: 24
18Lambdaparameter: 47
body: 25
19ExprTuple26, 42
20Lambdaparameter: 47
body: 27
21ExprRangelambda_map: 28
start_index: 33
end_index: 29
22ExprRangelambda_map: 30
start_index: 33
end_index: 31
23ExprRangelambda_map: 32
start_index: 33
end_index: 34
24Operationoperator: 37
operands: 35
25Operationoperator: 37
operands: 36
26Variable
27Operationoperator: 37
operands: 38
28Lambdaparameter: 47
body: 39
29Variable
30Lambdaparameter: 47
body: 40
31Variable
32Lambdaparameter: 47
body: 41
33Literal
34Variable
35ExprTuple39, 42
36ExprTuple40, 42
37Literal
38ExprTuple41, 42
39IndexedVarvariable: 43
index: 47
40IndexedVarvariable: 44
index: 47
41IndexedVarvariable: 45
index: 47
42Literal
43Variable
44Variable
45Variable
46ExprTuple47
47Variable