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 A, Conditional, ExprRange, Function, IndexedVar, K, Lambda, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, W_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, TensorProd, VecSpaces
from proveit.logic import And, Equals, Forall, InClass
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(V, sub_expr1)
sub_expr3 = IndexedVar(W, sub_expr1)
sub_expr4 = VecSpaces(K)
expr = Lambda([V_1_to_n, W_1_to_n], Conditional(Forall(instance_param_or_params = [A_1_to_n], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(IndexedVar(A, sub_expr1), [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), domains = [ExprRange(sub_expr1, LinMap(sub_expr2, sub_expr3), one, n)]).with_wrapping(), And(ExprRange(sub_expr1, InClass(sub_expr2, sub_expr4), one, n), ExprRange(sub_expr1, InClass(sub_expr3, sub_expr4), one, n))))
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(V_{1}, V_{2}, \ldots, V_{n}, W_{1}, W_{2}, \ldots, W_{n}\right) \mapsto \left\{\begin{array}{l}\forall_{\left(A_{1} \in \mathcal{L}\left(V_{1}, W_{1}\right)\right), \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right), \ldots, \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\right)\right)}~\\
\left[\begin{array}{l}\forall_{\left(v_{1} \in V_{1}\right), \left(v_{2} \in V_{2}\right), \ldots, \left(v_{n} \in V_{n}\right)}~\\
\left(\left(A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{n}\right)\left(v_{1} {\otimes}  v_{2} {\otimes}  \ldots {\otimes}  v_{n}\right) = \left(A_{1}\left(v_{1}\right) {\otimes}  A_{2}\left(v_{2}\right) {\otimes}  \ldots {\otimes}  A_{n}\left(v_{n}\right)\right)\right)\end{array}\right]\end{array} \textrm{ if } \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(V_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right), \left(W_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(W_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(W_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\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
1ExprTuple3, 4
2Conditionalvalue: 5
condition: 6
3ExprRangelambda_map: 7
start_index: 70
end_index: 71
4ExprRangelambda_map: 8
start_index: 70
end_index: 71
5Operationoperator: 21
operand: 11
6Operationoperator: 40
operands: 10
7Lambdaparameter: 79
body: 68
8Lambdaparameter: 79
body: 57
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 53
body: 14
12ExprRangelambda_map: 15
start_index: 70
end_index: 71
13ExprRangelambda_map: 16
start_index: 70
end_index: 71
14Conditionalvalue: 17
condition: 18
15Lambdaparameter: 79
body: 19
16Lambdaparameter: 79
body: 20
17Operationoperator: 21
operand: 27
18Operationoperator: 40
operands: 23
19Operationoperator: 25
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22ExprTuple27
23ExprTuple28
24ExprTuple68, 29
25Literal
26ExprTuple57, 29
27Lambdaparameters: 60
body: 30
28ExprRangelambda_map: 31
start_index: 70
end_index: 71
29Operationoperator: 32
operand: 37
30Conditionalvalue: 34
condition: 35
31Lambdaparameter: 79
body: 36
32Literal
33ExprTuple37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operands: 41
36Operationoperator: 62
operands: 42
37Variable
38Literal
39ExprTuple43, 44
40Literal
41ExprTuple45
42ExprTuple72, 46
43Operationoperator: 47
operand: 54
44Operationoperator: 59
operands: 49
45ExprRangelambda_map: 50
start_index: 70
end_index: 71
46Operationoperator: 51
operands: 52
47Operationoperator: 59
operands: 53
48ExprTuple54
49ExprTuple55
50Lambdaparameter: 79
body: 56
51Literal
52ExprTuple68, 57
53ExprTuple58
54Operationoperator: 59
operands: 60
55ExprRangelambda_map: 61
start_index: 70
end_index: 71
56Operationoperator: 62
operands: 63
57IndexedVarvariable: 64
index: 79
58ExprRangelambda_map: 65
start_index: 70
end_index: 71
59Literal
60ExprTuple66
61Lambdaparameter: 79
body: 67
62Literal
63ExprTuple76, 68
64Variable
65Lambdaparameter: 79
body: 72
66ExprRangelambda_map: 69
start_index: 70
end_index: 71
67Operationoperator: 72
operand: 76
68IndexedVarvariable: 74
index: 79
69Lambdaparameter: 79
body: 76
70Literal
71Variable
72IndexedVarvariable: 75
index: 79
73ExprTuple76
74Variable
75Variable
76IndexedVarvariable: 77
index: 79
77Variable
78ExprTuple79
79Variable