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, K, Lambda, V, 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 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 = TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)
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(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)), 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\{\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] \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
1ExprTuple64, 77, 66
2Conditionalvalue: 3
condition: 4
3Operationoperator: 35
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10, 11
8Lambdaparameter: 53
body: 13
9Operationoperator: 48
operands: 14
10Operationoperator: 48
operands: 15
11Operationoperator: 48
operands: 16
12ExprTuple53
13Conditionalvalue: 17
condition: 18
14ExprTuple64, 20
15ExprTuple77, 19
16ExprTuple66, 20
17Operationoperator: 35
operand: 24
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24
22Literal
23ExprTuple53, 25
24Lambdaparameters: 26
body: 27
25Operationoperator: 28
operand: 32
26ExprTuple59, 60
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32
30Literal
31ExprTuple33, 34
32Variable
33Operationoperator: 35
operand: 39
34Operationoperator: 37
operands: 38
35Literal
36ExprTuple39
37Literal
38ExprTuple40, 41
39Lambdaparameters: 69
body: 42
40Operationoperator: 51
operand: 46
41Operationoperator: 56
operands: 44
42Conditionalvalue: 45
condition: 62
43ExprTuple46
44ExprTuple59, 47, 60
45Operationoperator: 48
operands: 49
46Lambdaparameters: 69
body: 50
47Operationoperator: 51
operand: 55
48Literal
49ExprTuple54, 53
50Conditionalvalue: 54
condition: 62
51Literal
52ExprTuple55
53Variable
54Operationoperator: 56
operands: 57
55Lambdaparameters: 69
body: 58
56Literal
57ExprTuple59, 61, 60
58Conditionalvalue: 61
condition: 62
59ExprRangelambda_map: 63
start_index: 76
end_index: 64
60ExprRangelambda_map: 65
start_index: 76
end_index: 66
61Operationoperator: 67
operands: 69
62Operationoperator: 68
operands: 69
63Lambdaparameter: 81
body: 70
64Variable
65Lambdaparameter: 81
body: 71
66Variable
67Variable
68Variable
69ExprTuple72
70IndexedVarvariable: 73
index: 81
71IndexedVarvariable: 74
index: 81
72ExprRangelambda_map: 75
start_index: 76
end_index: 77
73Variable
74Variable
75Lambdaparameter: 81
body: 78
76Literal
77Variable
78IndexedVarvariable: 79
index: 81
79Variable
80ExprTuple81
81Variable