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 Equals, Forall, InSet
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(n, Conditional(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(), InSet(n, 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())
n \mapsto \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} \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 79
body: 2
1ExprTuple79
2Conditionalvalue: 3
condition: 4
3Operationoperator: 29
operand: 7
4Operationoperator: 70
operands: 6
5ExprTuple7
6ExprTuple79, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple11, 12
10Conditionalvalue: 13
condition: 14
11ExprRangelambda_map: 15
start_index: 78
end_index: 79
12ExprRangelambda_map: 16
start_index: 78
end_index: 79
13Operationoperator: 29
operand: 19
14Operationoperator: 48
operands: 18
15Lambdaparameter: 87
body: 76
16Lambdaparameter: 87
body: 65
17ExprTuple19
18ExprTuple20, 21
19Lambdaparameters: 61
body: 22
20ExprRangelambda_map: 23
start_index: 78
end_index: 79
21ExprRangelambda_map: 24
start_index: 78
end_index: 79
22Conditionalvalue: 25
condition: 26
23Lambdaparameter: 87
body: 27
24Lambdaparameter: 87
body: 28
25Operationoperator: 29
operand: 35
26Operationoperator: 48
operands: 31
27Operationoperator: 33
operands: 32
28Operationoperator: 33
operands: 34
29Literal
30ExprTuple35
31ExprTuple36
32ExprTuple76, 37
33Literal
34ExprTuple65, 37
35Lambdaparameters: 68
body: 38
36ExprRangelambda_map: 39
start_index: 78
end_index: 79
37Operationoperator: 40
operand: 45
38Conditionalvalue: 42
condition: 43
39Lambdaparameter: 87
body: 44
40Literal
41ExprTuple45
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operands: 49
44Operationoperator: 70
operands: 50
45Variable
46Literal
47ExprTuple51, 52
48Literal
49ExprTuple53
50ExprTuple80, 54
51Operationoperator: 55
operand: 62
52Operationoperator: 67
operands: 57
53ExprRangelambda_map: 58
start_index: 78
end_index: 79
54Operationoperator: 59
operands: 60
55Operationoperator: 67
operands: 61
56ExprTuple62
57ExprTuple63
58Lambdaparameter: 87
body: 64
59Literal
60ExprTuple76, 65
61ExprTuple66
62Operationoperator: 67
operands: 68
63ExprRangelambda_map: 69
start_index: 78
end_index: 79
64Operationoperator: 70
operands: 71
65IndexedVarvariable: 72
index: 87
66ExprRangelambda_map: 73
start_index: 78
end_index: 79
67Literal
68ExprTuple74
69Lambdaparameter: 87
body: 75
70Literal
71ExprTuple84, 76
72Variable
73Lambdaparameter: 87
body: 80
74ExprRangelambda_map: 77
start_index: 78
end_index: 79
75Operationoperator: 80
operand: 84
76IndexedVarvariable: 82
index: 87
77Lambdaparameter: 87
body: 84
78Literal
79Variable
80IndexedVarvariable: 83
index: 87
81ExprTuple84
82Variable
83Variable
84IndexedVarvariable: 85
index: 87
85Variable
86ExprTuple87
87Variable