logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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())
\left(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]\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 36
body: 2
2Operationoperator: 24
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple64, 56, 69
6Conditionalvalue: 7
condition: 8
7Operationoperator: 24
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple13, 14, 15
12Lambdaparameter: 43
body: 17
13Operationoperator: 39
operands: 18
14Operationoperator: 39
operands: 19
15Operationoperator: 39
operands: 20
16ExprTuple43
17Conditionalvalue: 21
condition: 22
18ExprTuple64, 23
19ExprTuple56, 23
20ExprTuple69, 23
21Operationoperator: 24
operand: 28
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple43, 29
28Lambdaparameters: 30
body: 31
29Operationoperator: 32
operand: 36
30ExprTuple60, 53, 62
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple44, 43
41Literal
42ExprTuple44, 45
43Variable
44Operationoperator: 57
operands: 46
45Operationoperator: 50
operands: 47
46ExprTuple60, 48, 62
47ExprTuple49
48Operationoperator: 50
operands: 51
49ExprRangelambda_map: 52
start_index: 68
end_index: 56
50Literal
51ExprTuple53
52Lambdaparameter: 71
body: 54
53ExprRangelambda_map: 55
start_index: 68
end_index: 56
54Operationoperator: 57
operands: 58
55Lambdaparameter: 76
body: 59
56Variable
57Literal
58ExprTuple60, 61, 62
59IndexedVarvariable: 65
index: 76
60ExprRangelambda_map: 63
start_index: 68
end_index: 64
61IndexedVarvariable: 65
index: 71
62ExprRangelambda_map: 67
start_index: 68
end_index: 69
63Lambdaparameter: 76
body: 70
64Variable
65Variable
66ExprTuple71
67Lambdaparameter: 76
body: 72
68Literal
69Variable
70IndexedVarvariable: 73
index: 76
71Variable
72IndexedVarvariable: 74
index: 76
73Variable
74Variable
75ExprTuple76
76Variable