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(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, condition = Q__b_1_to_j), TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2)), domain = VecSpaces(K)), 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[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\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[\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] \\  = \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) \end{array} \end{array}\right) \end{array} \end{array}\right)\right]\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, 72, 73
3Operationoperator: 40
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple69, 82, 71
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
19ExprTuple69, 25
20ExprTuple82, 24
21ExprTuple71, 25
22Operationoperator: 40
operand: 29
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29
27Literal
28ExprTuple58, 30
29Lambdaparameters: 31
body: 32
30Operationoperator: 33
operand: 37
31ExprTuple64, 65
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37
35Literal
36ExprTuple38, 39
37Variable
38Operationoperator: 40
operand: 44
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple44
42Literal
43ExprTuple45, 46
44Lambdaparameters: 74
body: 47
45Operationoperator: 56
operand: 51
46Operationoperator: 61
operands: 49
47Conditionalvalue: 50
condition: 67
48ExprTuple51
49ExprTuple64, 52, 65
50Operationoperator: 53
operands: 54
51Lambdaparameters: 74
body: 55
52Operationoperator: 56
operand: 60
53Literal
54ExprTuple59, 58
55Conditionalvalue: 59
condition: 67
56Literal
57ExprTuple60
58Variable
59Operationoperator: 61
operands: 62
60Lambdaparameters: 74
body: 63
61Literal
62ExprTuple64, 66, 65
63Conditionalvalue: 66
condition: 67
64ExprRangelambda_map: 68
start_index: 81
end_index: 69
65ExprRangelambda_map: 70
start_index: 81
end_index: 71
66Operationoperator: 72
operands: 74
67Operationoperator: 73
operands: 74
68Lambdaparameter: 86
body: 75
69Variable
70Lambdaparameter: 86
body: 76
71Variable
72Variable
73Variable
74ExprTuple77
75IndexedVarvariable: 78
index: 86
76IndexedVarvariable: 79
index: 86
77ExprRangelambda_map: 80
start_index: 81
end_index: 82
78Variable
79Variable
80Lambdaparameter: 86
body: 83
81Literal
82Variable
83IndexedVarvariable: 84
index: 86
84Variable
85ExprTuple86
86Variable