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, f, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, f_1_to_k
from proveit.linear_algebra import TensorProd, VecZero
from proveit.logic import And, Equals, Forall, Implies, InSet, NotEquals
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, f_1_to_k], Conditional(Forall(instance_param_or_params = [b, e], instance_expr = Implies(Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, e, f_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, f_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), domain = V, conditions = [Equals(b, e), NotEquals(b, VecZero(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(f, 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}, f_{1}, f_{2}, \ldots, f_{k}\right) \mapsto \left\{\forall_{b, e \in V~|~b = e, b \neq \vec{0}\left(V\right)}~\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} 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} e{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{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} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{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(f_{1} \in W_{1}\right) ,  \left(f_{2} \in W_{2}\right) ,  \ldots ,  \left(f_{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
1ExprTuple65, 66, 67, 68
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 26
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11, 12
8Lambdaparameters: 46
body: 13
9ExprRangelambda_map: 14
start_index: 75
end_index: 73
10ExprRangelambda_map: 15
start_index: 75
end_index: 76
11ExprRangelambda_map: 16
start_index: 75
end_index: 73
12ExprRangelambda_map: 17
start_index: 75
end_index: 76
13Conditionalvalue: 18
condition: 19
14Lambdaparameter: 86
body: 20
15Lambdaparameter: 86
body: 21
16Lambdaparameter: 86
body: 22
17Lambdaparameter: 86
body: 23
18Operationoperator: 24
operands: 25
19Operationoperator: 26
operands: 27
20Operationoperator: 43
operands: 28
21Operationoperator: 43
operands: 29
22Operationoperator: 43
operands: 30
23Operationoperator: 43
operands: 31
24Literal
25ExprTuple32, 33
26Literal
27ExprTuple34, 35, 36, 37
28ExprTuple77, 38
29ExprTuple78, 39
30ExprTuple79, 38
31ExprTuple80, 39
32Operationoperator: 45
operands: 40
33Operationoperator: 45
operands: 41
34Operationoperator: 43
operands: 42
35Operationoperator: 43
operands: 44
36Operationoperator: 45
operands: 46
37Operationoperator: 47
operands: 48
38IndexedVarvariable: 49
index: 86
39IndexedVarvariable: 50
index: 86
40ExprTuple51, 52
41ExprTuple53, 54
42ExprTuple63, 69
43Literal
44ExprTuple64, 69
45Literal
46ExprTuple63, 64
47Literal
48ExprTuple63, 55
49Variable
50Variable
51Operationoperator: 59
operands: 56
52Operationoperator: 59
operands: 57
53Operationoperator: 59
operands: 58
54Operationoperator: 59
operands: 60
55Operationoperator: 61
operand: 69
56ExprTuple65, 63, 66
57ExprTuple67, 64, 68
58ExprTuple65, 66
59Literal
60ExprTuple67, 68
61Literal
62ExprTuple69
63Variable
64Variable
65ExprRangelambda_map: 70
start_index: 75
end_index: 73
66ExprRangelambda_map: 71
start_index: 75
end_index: 76
67ExprRangelambda_map: 72
start_index: 75
end_index: 73
68ExprRangelambda_map: 74
start_index: 75
end_index: 76
69Variable
70Lambdaparameter: 86
body: 77
71Lambdaparameter: 86
body: 78
72Lambdaparameter: 86
body: 79
73Variable
74Lambdaparameter: 86
body: 80
75Literal
76Variable
77IndexedVarvariable: 81
index: 86
78IndexedVarvariable: 82
index: 86
79IndexedVarvariable: 83
index: 86
80IndexedVarvariable: 84
index: 86
81Variable
82Variable
83Variable
84Variable
85ExprTuple86
86Variable