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, 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, InSet
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(alpha, Conditional(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), InSet(alpha, 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())
\alpha \mapsto \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] \textrm{ if } \alpha \in K\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 76
body: 2
1ExprTuple76
2Conditionalvalue: 3
condition: 4
3Operationoperator: 28
operand: 7
4Operationoperator: 74
operands: 6
5ExprTuple7
6ExprTuple76, 68
7Lambdaparameters: 8
body: 9
8ExprTuple83, 86
9Conditionalvalue: 10
condition: 11
10Operationoperator: 28
operand: 14
11Operationoperator: 45
operands: 13
12ExprTuple14
13ExprTuple15, 16
14Lambdaparameters: 17
body: 18
15Operationoperator: 74
operands: 19
16Operationoperator: 74
operands: 20
17ExprTuple21, 66, 22
18Conditionalvalue: 23
condition: 24
19ExprTuple83, 25
20ExprTuple86, 25
21ExprRangelambda_map: 26
start_index: 85
end_index: 83
22ExprRangelambda_map: 27
start_index: 85
end_index: 86
23Operationoperator: 28
operand: 31
24Operationoperator: 45
operands: 30
25Literal
26Lambdaparameter: 94
body: 80
27Lambdaparameter: 94
body: 81
28Literal
29ExprTuple31
30ExprTuple32, 33, 34
31Lambdaparameters: 72
body: 35
32ExprRangelambda_map: 36
start_index: 85
end_index: 83
33Operationoperator: 48
operands: 37
34ExprRangelambda_map: 38
start_index: 85
end_index: 86
35Conditionalvalue: 39
condition: 40
36Lambdaparameter: 94
body: 41
37ExprTuple66, 55
38Lambdaparameter: 94
body: 42
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41Operationoperator: 48
operands: 47
42Operationoperator: 48
operands: 49
43Literal
44ExprTuple50, 51
45Literal
46ExprTuple52, 53, 54
47ExprTuple80, 55
48Literal
49ExprTuple81, 55
50Operationoperator: 71
operands: 56
51Operationoperator: 69
operands: 57
52ExprRangelambda_map: 58
start_index: 85
end_index: 83
53Operationoperator: 74
operands: 59
54ExprRangelambda_map: 60
start_index: 85
end_index: 86
55Operationoperator: 61
operand: 68
56ExprTuple77, 63, 79
57ExprTuple76, 64
58Lambdaparameter: 94
body: 65
59ExprTuple78, 66
60Lambdaparameter: 94
body: 67
61Literal
62ExprTuple68
63Operationoperator: 69
operands: 70
64Operationoperator: 71
operands: 72
65Operationoperator: 74
operands: 73
66Variable
67Operationoperator: 74
operands: 75
68Variable
69Literal
70ExprTuple76, 78
71Literal
72ExprTuple77, 78, 79
73ExprTuple89, 80
74Literal
75ExprTuple90, 81
76Variable
77ExprRangelambda_map: 82
start_index: 85
end_index: 83
78Variable
79ExprRangelambda_map: 84
start_index: 85
end_index: 86
80IndexedVarvariable: 87
index: 94
81IndexedVarvariable: 88
index: 94
82Lambdaparameter: 94
body: 89
83Variable
84Lambdaparameter: 94
body: 90
85Literal
86Variable
87Variable
88Variable
89IndexedVarvariable: 91
index: 94
90IndexedVarvariable: 92
index: 94
91Variable
92Variable
93ExprTuple94
94Variable