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, Function, K, Lambda, Q, V, f, i, j, k, s
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 ScalarMult, TensorProd, VecSpaces, VecSum
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 = Function(s, sub_expr1)
sub_expr3 = ScalarMult(sub_expr2, f__b_1_to_j)
expr = ExprTuple(Lambda([K, f, Q, s], 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(TensorProd(a_1_to_i, sub_expr3, c_1_to_k), V), condition = Q__b_1_to_j), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)), condition = Q__b_1_to_j), TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k)).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, s\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} \left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot \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)\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)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\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]\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, 82, 72, 81
3Operationoperator: 40
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple78, 91, 80
7Conditionalvalue: 8
condition: 9
8Operationoperator: 40
operand: 13
9Operationoperator: 11
operands: 12
10ExprTuple13
11Literal
12ExprTuple14, 15, 16
13Lambdaparameter: 59
body: 18
14Operationoperator: 53
operands: 19
15Operationoperator: 53
operands: 20
16Operationoperator: 53
operands: 21
17ExprTuple59
18Conditionalvalue: 22
condition: 23
19ExprTuple78, 25
20ExprTuple91, 24
21ExprTuple80, 25
22Operationoperator: 40
operand: 29
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29
27Literal
28ExprTuple59, 30
29Lambdaparameters: 31
body: 32
30Operationoperator: 33
operand: 37
31ExprTuple73, 74
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37
35Literal
36ExprTuple38, 39
37Variable
38Operationoperator: 40
operand: 44
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple44
42Literal
43ExprTuple45, 46
44Lambdaparameters: 83
body: 47
45Operationoperator: 56
operand: 51
46Operationoperator: 68
operands: 49
47Conditionalvalue: 50
condition: 67
48ExprTuple51
49ExprTuple73, 52, 74
50Operationoperator: 53
operands: 54
51Lambdaparameters: 83
body: 55
52Operationoperator: 56
operand: 61
53Literal
54ExprTuple58, 59
55Conditionalvalue: 60
condition: 67
56Literal
57ExprTuple61
58Operationoperator: 68
operands: 62
59Variable
60Operationoperator: 70
operands: 63
61Lambdaparameters: 83
body: 64
62ExprTuple73, 66, 74
63ExprTuple75, 65
64Conditionalvalue: 66
condition: 67
65Operationoperator: 68
operands: 69
66Operationoperator: 70
operands: 71
67Operationoperator: 72
operands: 83
68Literal
69ExprTuple73, 76, 74
70Literal
71ExprTuple75, 76
72Variable
73ExprRangelambda_map: 77
start_index: 90
end_index: 78
74ExprRangelambda_map: 79
start_index: 90
end_index: 80
75Operationoperator: 81
operands: 83
76Operationoperator: 82
operands: 83
77Lambdaparameter: 95
body: 84
78Variable
79Lambdaparameter: 95
body: 85
80Variable
81Variable
82Variable
83ExprTuple86
84IndexedVarvariable: 87
index: 95
85IndexedVarvariable: 88
index: 95
86ExprRangelambda_map: 89
start_index: 90
end_index: 91
87Variable
88Variable
89Lambdaparameter: 95
body: 92
90Literal
91Variable
92IndexedVarvariable: 93
index: 95
93Variable
94ExprTuple95
95Variable