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 Function, K, Lambda, Q, V, f, i, j, k, s
from proveit.core_expr_types import Q__b_1_to_j, a_1_to_i, b_1_to_j, c_1_to_k, f__b_1_to_j
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces, VecSum
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Natural, NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = Function(s, sub_expr1)
sub_expr3 = ScalarMult(sub_expr2, f__b_1_to_j)
expr = Lambda([K, f, Q, s], Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(TensorProd(a_1_to_i, sub_expr3, c_1_to_k), V), condition = Q__b_1_to_j), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)), condition = Q__b_1_to_j), TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2)).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domains = [Natural, NaturalPos, Natural]))
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(K, f, Q, s\right) \mapsto \left[\forall_{i \in \mathbb{N}, j \in \mathbb{N}^+, k \in \mathbb{N}}~\left[\begin{array}{l}\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left[\forall_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} f\left(b_{1}, b_{2}, \ldots, b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right)\right] \\  = \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\right) \end{array} \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
0Lambdaparameters: 1
body: 2
1ExprTuple36, 81, 71, 80
2Operationoperator: 39
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple77, 90, 79
6Conditionalvalue: 7
condition: 8
7Operationoperator: 39
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple13, 14, 15
12Lambdaparameter: 58
body: 17
13Operationoperator: 52
operands: 18
14Operationoperator: 52
operands: 19
15Operationoperator: 52
operands: 20
16ExprTuple58
17Conditionalvalue: 21
condition: 22
18ExprTuple77, 24
19ExprTuple90, 23
20ExprTuple79, 24
21Operationoperator: 39
operand: 28
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple58, 29
28Lambdaparameters: 30
body: 31
29Operationoperator: 32
operand: 36
30ExprTuple72, 73
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 39
operand: 43
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43
41Literal
42ExprTuple44, 45
43Lambdaparameters: 82
body: 46
44Operationoperator: 55
operand: 50
45Operationoperator: 67
operands: 48
46Conditionalvalue: 49
condition: 66
47ExprTuple50
48ExprTuple72, 51, 73
49Operationoperator: 52
operands: 53
50Lambdaparameters: 82
body: 54
51Operationoperator: 55
operand: 60
52Literal
53ExprTuple57, 58
54Conditionalvalue: 59
condition: 66
55Literal
56ExprTuple60
57Operationoperator: 67
operands: 61
58Variable
59Operationoperator: 69
operands: 62
60Lambdaparameters: 82
body: 63
61ExprTuple72, 65, 73
62ExprTuple74, 64
63Conditionalvalue: 65
condition: 66
64Operationoperator: 67
operands: 68
65Operationoperator: 69
operands: 70
66Operationoperator: 71
operands: 82
67Literal
68ExprTuple72, 75, 73
69Literal
70ExprTuple74, 75
71Variable
72ExprRangelambda_map: 76
start_index: 89
end_index: 77
73ExprRangelambda_map: 78
start_index: 89
end_index: 79
74Operationoperator: 80
operands: 82
75Operationoperator: 81
operands: 82
76Lambdaparameter: 94
body: 83
77Variable
78Lambdaparameter: 94
body: 84
79Variable
80Variable
81Variable
82ExprTuple85
83IndexedVarvariable: 86
index: 94
84IndexedVarvariable: 87
index: 94
85ExprRangelambda_map: 88
start_index: 89
end_index: 90
86Variable
87Variable
88Lambdaparameter: 94
body: 91
89Literal
90Variable
91IndexedVarvariable: 92
index: 94
92Variable
93ExprTuple94
94Variable