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(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, condition = Q__b_1_to_j), TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2)), domain = VecSpaces(K)), 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[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\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[\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] \\  = \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) \end{array} \end{array}\right) \end{array} \end{array}\right)\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
0Lambdaparameters: 1
body: 2
1ExprTuple36, 71, 72
2Operationoperator: 39
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple68, 81, 70
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
18ExprTuple68, 24
19ExprTuple81, 23
20ExprTuple70, 24
21Operationoperator: 39
operand: 28
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple57, 29
28Lambdaparameters: 30
body: 31
29Operationoperator: 32
operand: 36
30ExprTuple63, 64
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 39
operand: 43
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43
41Literal
42ExprTuple44, 45
43Lambdaparameters: 73
body: 46
44Operationoperator: 55
operand: 50
45Operationoperator: 60
operands: 48
46Conditionalvalue: 49
condition: 66
47ExprTuple50
48ExprTuple63, 51, 64
49Operationoperator: 52
operands: 53
50Lambdaparameters: 73
body: 54
51Operationoperator: 55
operand: 59
52Literal
53ExprTuple58, 57
54Conditionalvalue: 58
condition: 66
55Literal
56ExprTuple59
57Variable
58Operationoperator: 60
operands: 61
59Lambdaparameters: 73
body: 62
60Literal
61ExprTuple63, 65, 64
62Conditionalvalue: 65
condition: 66
63ExprRangelambda_map: 67
start_index: 80
end_index: 68
64ExprRangelambda_map: 69
start_index: 80
end_index: 70
65Operationoperator: 71
operands: 73
66Operationoperator: 72
operands: 73
67Lambdaparameter: 85
body: 74
68Variable
69Lambdaparameter: 85
body: 75
70Variable
71Variable
72Variable
73ExprTuple76
74IndexedVarvariable: 77
index: 85
75IndexedVarvariable: 78
index: 85
76ExprRangelambda_map: 79
start_index: 80
end_index: 81
77Variable
78Variable
79Lambdaparameter: 85
body: 82
80Literal
81Variable
82IndexedVarvariable: 83
index: 85
83Variable
84ExprTuple85
85Variable