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(TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k), 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)).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(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) \\  = \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] \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, 79, 69, 76
2Operationoperator: 39
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple78, 89, 82
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
18ExprTuple78, 24
19ExprTuple89, 23
20ExprTuple82, 24
21Operationoperator: 39
operand: 28
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple58, 29
28Lambdaparameters: 30
body: 31
29Operationoperator: 32
operand: 36
30ExprTuple73, 75
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 39
operand: 43
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43
41Literal
42ExprTuple44, 45
43Lambdaparameters: 80
body: 46
44Operationoperator: 70
operands: 47
45Operationoperator: 54
operand: 51
46Conditionalvalue: 49
condition: 65
47ExprTuple73, 50, 75
48ExprTuple51
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operand: 59
51Lambdaparameters: 80
body: 56
52Literal
53ExprTuple57, 58
54Literal
55ExprTuple59
56Conditionalvalue: 60
condition: 65
57Operationoperator: 70
operands: 61
58Variable
59Lambdaparameters: 80
body: 62
60Operationoperator: 67
operands: 63
61ExprTuple73, 64, 75
62Conditionalvalue: 64
condition: 65
63ExprTuple72, 66
64Operationoperator: 67
operands: 68
65Operationoperator: 69
operands: 80
66Operationoperator: 70
operands: 71
67Literal
68ExprTuple72, 74
69Variable
70Literal
71ExprTuple73, 74, 75
72Operationoperator: 76
operands: 80
73ExprRangelambda_map: 77
start_index: 88
end_index: 78
74Operationoperator: 79
operands: 80
75ExprRangelambda_map: 81
start_index: 88
end_index: 82
76Variable
77Lambdaparameter: 94
body: 83
78Variable
79Variable
80ExprTuple84
81Lambdaparameter: 94
body: 85
82Variable
83IndexedVarvariable: 86
index: 94
84ExprRangelambda_map: 87
start_index: 88
end_index: 89
85IndexedVarvariable: 90
index: 94
86Variable
87Lambdaparameter: 94
body: 91
88Literal
89Variable
90Variable
91IndexedVarvariable: 92
index: 94
92Variable
93ExprTuple94
94Variable