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, 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 Equals, Forall
from proveit.numbers import NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(K, Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [V_1_to_n, W_1_to_n], instance_expr = 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(IndexedVar(V, sub_expr1), IndexedVar(W, sub_expr1)), one, n)]).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domain = NaturalPos))
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())
K \mapsto \left[\forall_{n \in \mathbb{N}^+}~\left[\begin{array}{l}\forall_{V_{1}, V_{2}, \ldots, V_{n}, W_{1}, W_{2}, \ldots, W_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\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}\right]\end{array}\right]\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 48
body: 1
1Operationoperator: 32
operand: 3
2ExprTuple3
3Lambdaparameter: 82
body: 5
4ExprTuple82
5Conditionalvalue: 6
condition: 7
6Operationoperator: 32
operand: 10
7Operationoperator: 73
operands: 9
8ExprTuple10
9ExprTuple82, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple14, 15
13Conditionalvalue: 16
condition: 17
14ExprRangelambda_map: 18
start_index: 81
end_index: 82
15ExprRangelambda_map: 19
start_index: 81
end_index: 82
16Operationoperator: 32
operand: 22
17Operationoperator: 51
operands: 21
18Lambdaparameter: 90
body: 79
19Lambdaparameter: 90
body: 68
20ExprTuple22
21ExprTuple23, 24
22Lambdaparameters: 64
body: 25
23ExprRangelambda_map: 26
start_index: 81
end_index: 82
24ExprRangelambda_map: 27
start_index: 81
end_index: 82
25Conditionalvalue: 28
condition: 29
26Lambdaparameter: 90
body: 30
27Lambdaparameter: 90
body: 31
28Operationoperator: 32
operand: 38
29Operationoperator: 51
operands: 34
30Operationoperator: 36
operands: 35
31Operationoperator: 36
operands: 37
32Literal
33ExprTuple38
34ExprTuple39
35ExprTuple79, 40
36Literal
37ExprTuple68, 40
38Lambdaparameters: 71
body: 41
39ExprRangelambda_map: 42
start_index: 81
end_index: 82
40Operationoperator: 43
operand: 48
41Conditionalvalue: 45
condition: 46
42Lambdaparameter: 90
body: 47
43Literal
44ExprTuple48
45Operationoperator: 49
operands: 50
46Operationoperator: 51
operands: 52
47Operationoperator: 73
operands: 53
48Variable
49Literal
50ExprTuple54, 55
51Literal
52ExprTuple56
53ExprTuple83, 57
54Operationoperator: 58
operand: 65
55Operationoperator: 70
operands: 60
56ExprRangelambda_map: 61
start_index: 81
end_index: 82
57Operationoperator: 62
operands: 63
58Operationoperator: 70
operands: 64
59ExprTuple65
60ExprTuple66
61Lambdaparameter: 90
body: 67
62Literal
63ExprTuple79, 68
64ExprTuple69
65Operationoperator: 70
operands: 71
66ExprRangelambda_map: 72
start_index: 81
end_index: 82
67Operationoperator: 73
operands: 74
68IndexedVarvariable: 75
index: 90
69ExprRangelambda_map: 76
start_index: 81
end_index: 82
70Literal
71ExprTuple77
72Lambdaparameter: 90
body: 78
73Literal
74ExprTuple87, 79
75Variable
76Lambdaparameter: 90
body: 83
77ExprRangelambda_map: 80
start_index: 81
end_index: 82
78Operationoperator: 83
operand: 87
79IndexedVarvariable: 85
index: 90
80Lambdaparameter: 90
body: 87
81Literal
82Variable
83IndexedVarvariable: 86
index: 90
84ExprTuple87
85Variable
86Variable
87IndexedVarvariable: 88
index: 90
88Variable
89ExprTuple90
90Variable