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 ExprTuple, K, Lambda, Q, V, f, 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 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 = ExprTuple(Lambda([K, f, Q], 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, 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(), domains = [Natural, NaturalPos, 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(\left(K, f, Q\right) \mapsto \left[\forall_{i \in \mathbb{N}, j \in \mathbb{N}^+, 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}, 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}\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
1Lambdaparameters: 2
body: 3
2ExprTuple37, 71, 68
3Operationoperator: 40
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple70, 81, 74
7Conditionalvalue: 8
condition: 9
8Operationoperator: 40
operand: 13
9Operationoperator: 11
operands: 12
10ExprTuple13
11Literal
12ExprTuple14, 15, 16
13Lambdaparameter: 58
body: 18
14Operationoperator: 53
operands: 19
15Operationoperator: 53
operands: 20
16Operationoperator: 53
operands: 21
17ExprTuple58
18Conditionalvalue: 22
condition: 23
19ExprTuple70, 25
20ExprTuple81, 24
21ExprTuple74, 25
22Operationoperator: 40
operand: 29
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29
27Literal
28ExprTuple58, 30
29Lambdaparameters: 31
body: 32
30Operationoperator: 33
operand: 37
31ExprTuple65, 67
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37
35Literal
36ExprTuple38, 39
37Variable
38Operationoperator: 40
operand: 44
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple44
42Literal
43ExprTuple45, 46
44Lambdaparameters: 72
body: 47
45Operationoperator: 62
operands: 48
46Operationoperator: 55
operand: 52
47Conditionalvalue: 50
condition: 64
48ExprTuple65, 51, 67
49ExprTuple52
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operand: 59
52Lambdaparameters: 72
body: 57
53Literal
54ExprTuple60, 58
55Literal
56ExprTuple59
57Conditionalvalue: 60
condition: 64
58Variable
59Lambdaparameters: 72
body: 61
60Operationoperator: 62
operands: 63
61Conditionalvalue: 66
condition: 64
62Literal
63ExprTuple65, 66, 67
64Operationoperator: 68
operands: 72
65ExprRangelambda_map: 69
start_index: 80
end_index: 70
66Operationoperator: 71
operands: 72
67ExprRangelambda_map: 73
start_index: 80
end_index: 74
68Variable
69Lambdaparameter: 86
body: 75
70Variable
71Variable
72ExprTuple76
73Lambdaparameter: 86
body: 77
74Variable
75IndexedVarvariable: 78
index: 86
76ExprRangelambda_map: 79
start_index: 80
end_index: 81
77IndexedVarvariable: 82
index: 86
78Variable
79Lambdaparameter: 86
body: 83
80Literal
81Variable
82Variable
83IndexedVarvariable: 84
index: 86
84Variable
85ExprTuple86
86Variable