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 ExprRange, IndexedVar, K, Lambda, V, Variable, b, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = TensorProd(a_1_to_i, VecAdd(b_1_to_j), c_1_to_k)
expr = Lambda(K, 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, b_1_to_j, c_1_to_k], instance_expr = Implies(InSet(sub_expr2, V), Equals(VecAdd(ExprRange(sub_expr1, TensorProd(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j)), sub_expr2).with_wrapping_at(2)).with_wrapping_at(2)).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domain = 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())
K \mapsto \left[\forall_{i, j, 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}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{1}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{2}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \ldots +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{j}{\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(b_{1} +  b_{2} +  \ldots +  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\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
0Lambdaparameter: 35
body: 1
1Operationoperator: 23
operand: 3
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple63, 57, 67
5Conditionalvalue: 6
condition: 7
6Operationoperator: 23
operand: 11
7Operationoperator: 9
operands: 10
8ExprTuple11
9Literal
10ExprTuple12, 13, 14
11Lambdaparameter: 42
body: 16
12Operationoperator: 38
operands: 17
13Operationoperator: 38
operands: 18
14Operationoperator: 38
operands: 19
15ExprTuple42
16Conditionalvalue: 20
condition: 21
17ExprTuple63, 22
18ExprTuple57, 22
19ExprTuple67, 22
20Operationoperator: 23
operand: 27
21Operationoperator: 25
operands: 26
22Literal
23Literal
24ExprTuple27
25Literal
26ExprTuple42, 28
27Lambdaparameters: 29
body: 30
28Operationoperator: 31
operand: 35
29ExprTuple58, 53, 60
30Operationoperator: 33
operands: 34
31Literal
32ExprTuple35
33Literal
34ExprTuple36, 37
35Variable
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operands: 41
38Literal
39ExprTuple44, 42
40Literal
41ExprTuple43, 44
42Variable
43Operationoperator: 50
operands: 45
44Operationoperator: 54
operands: 46
45ExprTuple47
46ExprTuple58, 48, 60
47ExprRangelambda_map: 49
start_index: 66
end_index: 57
48Operationoperator: 50
operands: 51
49Lambdaparameter: 70
body: 52
50Literal
51ExprTuple53
52Operationoperator: 54
operands: 55
53ExprRangelambda_map: 56
start_index: 66
end_index: 57
54Literal
55ExprTuple58, 59, 60
56Lambdaparameter: 75
body: 61
57Variable
58ExprRangelambda_map: 62
start_index: 66
end_index: 63
59IndexedVarvariable: 68
index: 70
60ExprRangelambda_map: 65
start_index: 66
end_index: 67
61IndexedVarvariable: 68
index: 75
62Lambdaparameter: 75
body: 69
63Variable
64ExprTuple70
65Lambdaparameter: 75
body: 71
66Literal
67Variable
68Variable
69IndexedVarvariable: 72
index: 75
70Variable
71IndexedVarvariable: 73
index: 75
72Variable
73Variable
74ExprTuple75
75Variable