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 K, Lambda, V, alpha, b, i, k
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V, W_1_to_k]
expr = Lambda(K, Forall(instance_param_or_params = [alpha], instance_expr = Forall(instance_param_or_params = [i, k], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), domains = sub_expr1).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domain = Natural), domain = 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())
K \mapsto \left[\forall_{\alpha \in K}~\left[\forall_{i, k \in \mathbb{N}}~\left[\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V, W_{1}, W_{2}, \ldots, W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(a_{1} \in U_{1}\right), \left(a_{2} \in U_{2}\right), \ldots, \left(a_{i} \in U_{i}\right), b \in V,\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \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)\right) \end{array} \end{array}\right)\end{array}\right]\end{array}\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
0Lambdaparameter: 71
body: 1
1Operationoperator: 31
operand: 3
2ExprTuple3
3Lambdaparameter: 79
body: 5
4ExprTuple79
5Conditionalvalue: 6
condition: 7
6Operationoperator: 31
operand: 10
7Operationoperator: 77
operands: 9
8ExprTuple10
9ExprTuple79, 71
10Lambdaparameters: 11
body: 12
11ExprTuple86, 89
12Conditionalvalue: 13
condition: 14
13Operationoperator: 31
operand: 17
14Operationoperator: 48
operands: 16
15ExprTuple17
16ExprTuple18, 19
17Lambdaparameters: 20
body: 21
18Operationoperator: 77
operands: 22
19Operationoperator: 77
operands: 23
20ExprTuple24, 69, 25
21Conditionalvalue: 26
condition: 27
22ExprTuple86, 28
23ExprTuple89, 28
24ExprRangelambda_map: 29
start_index: 88
end_index: 86
25ExprRangelambda_map: 30
start_index: 88
end_index: 89
26Operationoperator: 31
operand: 34
27Operationoperator: 48
operands: 33
28Literal
29Lambdaparameter: 97
body: 83
30Lambdaparameter: 97
body: 84
31Literal
32ExprTuple34
33ExprTuple35, 36, 37
34Lambdaparameters: 75
body: 38
35ExprRangelambda_map: 39
start_index: 88
end_index: 86
36Operationoperator: 51
operands: 40
37ExprRangelambda_map: 41
start_index: 88
end_index: 89
38Conditionalvalue: 42
condition: 43
39Lambdaparameter: 97
body: 44
40ExprTuple69, 58
41Lambdaparameter: 97
body: 45
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operands: 49
44Operationoperator: 51
operands: 50
45Operationoperator: 51
operands: 52
46Literal
47ExprTuple53, 54
48Literal
49ExprTuple55, 56, 57
50ExprTuple83, 58
51Literal
52ExprTuple84, 58
53Operationoperator: 74
operands: 59
54Operationoperator: 72
operands: 60
55ExprRangelambda_map: 61
start_index: 88
end_index: 86
56Operationoperator: 77
operands: 62
57ExprRangelambda_map: 63
start_index: 88
end_index: 89
58Operationoperator: 64
operand: 71
59ExprTuple80, 66, 82
60ExprTuple79, 67
61Lambdaparameter: 97
body: 68
62ExprTuple81, 69
63Lambdaparameter: 97
body: 70
64Literal
65ExprTuple71
66Operationoperator: 72
operands: 73
67Operationoperator: 74
operands: 75
68Operationoperator: 77
operands: 76
69Variable
70Operationoperator: 77
operands: 78
71Variable
72Literal
73ExprTuple79, 81
74Literal
75ExprTuple80, 81, 82
76ExprTuple92, 83
77Literal
78ExprTuple93, 84
79Variable
80ExprRangelambda_map: 85
start_index: 88
end_index: 86
81Variable
82ExprRangelambda_map: 87
start_index: 88
end_index: 89
83IndexedVarvariable: 90
index: 97
84IndexedVarvariable: 91
index: 97
85Lambdaparameter: 97
body: 92
86Variable
87Lambdaparameter: 97
body: 93
88Literal
89Variable
90Variable
91Variable
92IndexedVarvariable: 94
index: 97
93IndexedVarvariable: 95
index: 97
94Variable
95Variable
96ExprTuple97
97Variable