logo

Expression of type Lambda

from the theory of proveit.linear_algebra.tensors

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, U, V, Variable, W, a, b, c, d, e, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, e_1_to_k
from proveit.linear_algebra import TensorProd
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(U, sub_expr1)
sub_expr3 = IndexedVar(W, sub_expr1)
expr = Lambda([a_1_to_i, c_1_to_k, d_1_to_i, e_1_to_k], Conditional(Forall(instance_param_or_params = [b], instance_expr = Implies(Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, e_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, b, e_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), domain = V), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), sub_expr3), one, k), ExprRange(sub_expr1, InSet(IndexedVar(d, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InSet(IndexedVar(e, sub_expr1), sub_expr3), 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}, d_{1}, d_{2}, \ldots, d_{i}, e_{1}, e_{2}, \ldots, e_{k}\right) \mapsto \left\{\forall_{b \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i} {\otimes} b{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \end{array} \end{array}\right) \textrm{ if } \left(a_{1} \in U_{1}\right) ,  \left(a_{2} \in U_{2}\right) ,  \ldots ,  \left(a_{i} \in U_{i}\right), \left(c_{1} \in W_{1}\right) ,  \left(c_{2} \in W_{2}\right) ,  \ldots ,  \left(c_{k} \in W_{k}\right), \left(d_{1} \in U_{1}\right) ,  \left(d_{2} \in U_{2}\right) ,  \ldots ,  \left(d_{i} \in U_{i}\right), \left(e_{1} \in W_{1}\right) ,  \left(e_{2} \in W_{2}\right) ,  \ldots ,  \left(e_{k} \in W_{k}\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
1ExprTuple53, 54, 55, 57
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12, 13
9Lambdaparameter: 56
body: 15
10ExprRangelambda_map: 16
start_index: 63
end_index: 61
11ExprRangelambda_map: 17
start_index: 63
end_index: 64
12ExprRangelambda_map: 18
start_index: 63
end_index: 61
13ExprRangelambda_map: 19
start_index: 63
end_index: 64
14ExprTuple56
15Conditionalvalue: 20
condition: 21
16Lambdaparameter: 74
body: 22
17Lambdaparameter: 74
body: 23
18Lambdaparameter: 74
body: 24
19Lambdaparameter: 74
body: 25
20Operationoperator: 26
operands: 27
21Operationoperator: 32
operands: 28
22Operationoperator: 32
operands: 29
23Operationoperator: 32
operands: 30
24Operationoperator: 32
operands: 31
25Operationoperator: 32
operands: 33
26Literal
27ExprTuple34, 35
28ExprTuple56, 36
29ExprTuple65, 37
30ExprTuple66, 38
31ExprTuple67, 37
32Literal
33ExprTuple68, 38
34Operationoperator: 40
operands: 39
35Operationoperator: 40
operands: 41
36Variable
37IndexedVarvariable: 42
index: 74
38IndexedVarvariable: 43
index: 74
39ExprTuple44, 45
40Literal
41ExprTuple46, 47
42Variable
43Variable
44Operationoperator: 51
operands: 48
45Operationoperator: 51
operands: 49
46Operationoperator: 51
operands: 50
47Operationoperator: 51
operands: 52
48ExprTuple53, 54
49ExprTuple55, 57
50ExprTuple53, 56, 54
51Literal
52ExprTuple55, 56, 57
53ExprRangelambda_map: 58
start_index: 63
end_index: 61
54ExprRangelambda_map: 59
start_index: 63
end_index: 64
55ExprRangelambda_map: 60
start_index: 63
end_index: 61
56Variable
57ExprRangelambda_map: 62
start_index: 63
end_index: 64
58Lambdaparameter: 74
body: 65
59Lambdaparameter: 74
body: 66
60Lambdaparameter: 74
body: 67
61Variable
62Lambdaparameter: 74
body: 68
63Literal
64Variable
65IndexedVarvariable: 69
index: 74
66IndexedVarvariable: 70
index: 74
67IndexedVarvariable: 71
index: 74
68IndexedVarvariable: 72
index: 74
69Variable
70Variable
71Variable
72Variable
73ExprTuple74
74Variable