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(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(), 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} 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} \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
1ExprTuple65, 76, 69
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
14ExprTuple65, 20
15ExprTuple76, 19
16ExprTuple69, 20
17Operationoperator: 35
operand: 24
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24
22Literal
23ExprTuple53, 25
24Lambdaparameters: 26
body: 27
25Operationoperator: 28
operand: 32
26ExprTuple60, 62
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32
30Literal
31ExprTuple33, 34
32Variable
33Operationoperator: 35
operand: 39
34Operationoperator: 37
operands: 38
35Literal
36ExprTuple39
37Literal
38ExprTuple40, 41
39Lambdaparameters: 67
body: 42
40Operationoperator: 57
operands: 43
41Operationoperator: 50
operand: 47
42Conditionalvalue: 45
condition: 59
43ExprTuple60, 46, 62
44ExprTuple47
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operand: 54
47Lambdaparameters: 67
body: 52
48Literal
49ExprTuple55, 53
50Literal
51ExprTuple54
52Conditionalvalue: 55
condition: 59
53Variable
54Lambdaparameters: 67
body: 56
55Operationoperator: 57
operands: 58
56Conditionalvalue: 61
condition: 59
57Literal
58ExprTuple60, 61, 62
59Operationoperator: 63
operands: 67
60ExprRangelambda_map: 64
start_index: 75
end_index: 65
61Operationoperator: 66
operands: 67
62ExprRangelambda_map: 68
start_index: 75
end_index: 69
63Variable
64Lambdaparameter: 81
body: 70
65Variable
66Variable
67ExprTuple71
68Lambdaparameter: 81
body: 72
69Variable
70IndexedVarvariable: 73
index: 81
71ExprRangelambda_map: 74
start_index: 75
end_index: 76
72IndexedVarvariable: 77
index: 81
73Variable
74Lambdaparameter: 81
body: 78
75Literal
76Variable
77Variable
78IndexedVarvariable: 79
index: 81
79Variable
80ExprTuple81
81Variable