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, Q, V, f, i, j, k
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 TensorProd, VecSpaces, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
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 = TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)
expr = Lambda([K, f, Q], 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(sub_expr2, V), condition = Q__b_1_to_j), Equals(TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k), VecSum(index_or_indices = sub_expr1, summand = sub_expr2, 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\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} f\left(b_{1}, b_{2}, \ldots, b_{j}\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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\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(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] \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, 70, 67
2Operationoperator: 39
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple69, 80, 73
6Conditionalvalue: 7
condition: 8
7Operationoperator: 39
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple13, 14, 15
12Lambdaparameter: 57
body: 17
13Operationoperator: 52
operands: 18
14Operationoperator: 52
operands: 19
15Operationoperator: 52
operands: 20
16ExprTuple57
17Conditionalvalue: 21
condition: 22
18ExprTuple69, 24
19ExprTuple80, 23
20ExprTuple73, 24
21Operationoperator: 39
operand: 28
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple57, 29
28Lambdaparameters: 30
body: 31
29Operationoperator: 32
operand: 36
30ExprTuple64, 66
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 39
operand: 43
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43
41Literal
42ExprTuple44, 45
43Lambdaparameters: 71
body: 46
44Operationoperator: 61
operands: 47
45Operationoperator: 54
operand: 51
46Conditionalvalue: 49
condition: 63
47ExprTuple64, 50, 66
48ExprTuple51
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operand: 58
51Lambdaparameters: 71
body: 56
52Literal
53ExprTuple59, 57
54Literal
55ExprTuple58
56Conditionalvalue: 59
condition: 63
57Variable
58Lambdaparameters: 71
body: 60
59Operationoperator: 61
operands: 62
60Conditionalvalue: 65
condition: 63
61Literal
62ExprTuple64, 65, 66
63Operationoperator: 67
operands: 71
64ExprRangelambda_map: 68
start_index: 79
end_index: 69
65Operationoperator: 70
operands: 71
66ExprRangelambda_map: 72
start_index: 79
end_index: 73
67Variable
68Lambdaparameter: 85
body: 74
69Variable
70Variable
71ExprTuple75
72Lambdaparameter: 85
body: 76
73Variable
74IndexedVarvariable: 77
index: 85
75ExprRangelambda_map: 78
start_index: 79
end_index: 80
76IndexedVarvariable: 81
index: 85
77Variable
78Lambdaparameter: 85
body: 82
79Literal
80Variable
81Variable
82IndexedVarvariable: 83
index: 85
83Variable
84ExprTuple85
85Variable