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(sub_expr2, VecAdd(ExprRange(sub_expr1, TensorProd(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j))).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(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) =  \\ \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) \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, 55, 68
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
18ExprTuple55, 22
19ExprTuple68, 22
20Operationoperator: 23
operand: 27
21Operationoperator: 25
operands: 26
22Literal
23Literal
24ExprTuple27
25Literal
26ExprTuple42, 28
27Lambdaparameters: 29
body: 30
28Operationoperator: 31
operand: 35
29ExprTuple59, 52, 61
30Operationoperator: 33
operands: 34
31Literal
32ExprTuple35
33Literal
34ExprTuple36, 37
35Variable
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operands: 41
38Literal
39ExprTuple43, 42
40Literal
41ExprTuple43, 44
42Variable
43Operationoperator: 56
operands: 45
44Operationoperator: 49
operands: 46
45ExprTuple59, 47, 61
46ExprTuple48
47Operationoperator: 49
operands: 50
48ExprRangelambda_map: 51
start_index: 67
end_index: 55
49Literal
50ExprTuple52
51Lambdaparameter: 70
body: 53
52ExprRangelambda_map: 54
start_index: 67
end_index: 55
53Operationoperator: 56
operands: 57
54Lambdaparameter: 75
body: 58
55Variable
56Literal
57ExprTuple59, 60, 61
58IndexedVarvariable: 64
index: 75
59ExprRangelambda_map: 62
start_index: 67
end_index: 63
60IndexedVarvariable: 64
index: 70
61ExprRangelambda_map: 66
start_index: 67
end_index: 68
62Lambdaparameter: 75
body: 69
63Variable
64Variable
65ExprTuple70
66Lambdaparameter: 75
body: 71
67Literal
68Variable
69IndexedVarvariable: 72
index: 75
70Variable
71IndexedVarvariable: 73
index: 75
72Variable
73Variable
74ExprTuple75
75Variable