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, Function, K, Lambda, V, 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 And, 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([i, j, k], Conditional(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(), And(InSet(i, Natural), InSet(j, NaturalPos), InSet(k, 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(i, j, k\right) \mapsto \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} \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N}^+ ,  k \in \mathbb{N}\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
1ExprTuple74, 85, 78
2Conditionalvalue: 3
condition: 4
3Operationoperator: 35
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10, 11
8Lambdaparameter: 54
body: 13
9Operationoperator: 48
operands: 14
10Operationoperator: 48
operands: 15
11Operationoperator: 48
operands: 16
12ExprTuple54
13Conditionalvalue: 17
condition: 18
14ExprTuple74, 20
15ExprTuple85, 19
16ExprTuple78, 20
17Operationoperator: 35
operand: 24
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24
22Literal
23ExprTuple54, 25
24Lambdaparameters: 26
body: 27
25Operationoperator: 28
operand: 32
26ExprTuple69, 71
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32
30Literal
31ExprTuple33, 34
32Variable
33Operationoperator: 35
operand: 39
34Operationoperator: 37
operands: 38
35Literal
36ExprTuple39
37Literal
38ExprTuple40, 41
39Lambdaparameters: 76
body: 42
40Operationoperator: 66
operands: 43
41Operationoperator: 50
operand: 47
42Conditionalvalue: 45
condition: 61
43ExprTuple69, 46, 71
44ExprTuple47
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operand: 55
47Lambdaparameters: 76
body: 52
48Literal
49ExprTuple53, 54
50Literal
51ExprTuple55
52Conditionalvalue: 56
condition: 61
53Operationoperator: 66
operands: 57
54Variable
55Lambdaparameters: 76
body: 58
56Operationoperator: 63
operands: 59
57ExprTuple69, 60, 71
58Conditionalvalue: 60
condition: 61
59ExprTuple68, 62
60Operationoperator: 63
operands: 64
61Operationoperator: 65
operands: 76
62Operationoperator: 66
operands: 67
63Literal
64ExprTuple68, 70
65Variable
66Literal
67ExprTuple69, 70, 71
68Operationoperator: 72
operands: 76
69ExprRangelambda_map: 73
start_index: 84
end_index: 74
70Operationoperator: 75
operands: 76
71ExprRangelambda_map: 77
start_index: 84
end_index: 78
72Variable
73Lambdaparameter: 90
body: 79
74Variable
75Variable
76ExprTuple80
77Lambdaparameter: 90
body: 81
78Variable
79IndexedVarvariable: 82
index: 90
80ExprRangelambda_map: 83
start_index: 84
end_index: 85
81IndexedVarvariable: 86
index: 90
82Variable
83Lambdaparameter: 90
body: 87
84Literal
85Variable
86Variable
87IndexedVarvariable: 88
index: 90
88Variable
89ExprTuple90
90Variable