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 Conditional, ExprTuple, Function, K, Lambda, V, 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 And, 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([i, j, k], Conditional(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(), And(InSet(i, Natural), InSet(j, NaturalPos), InSet(k, 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(i, j, k\right) \mapsto \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} \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N}^+ ,  k \in \mathbb{N}\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
2ExprTuple74, 87, 76
3Conditionalvalue: 4
condition: 5
4Operationoperator: 36
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameter: 55
body: 14
10Operationoperator: 49
operands: 15
11Operationoperator: 49
operands: 16
12Operationoperator: 49
operands: 17
13ExprTuple55
14Conditionalvalue: 18
condition: 19
15ExprTuple74, 21
16ExprTuple87, 20
17ExprTuple76, 21
18Operationoperator: 36
operand: 25
19Operationoperator: 23
operands: 24
20Literal
21Literal
22ExprTuple25
23Literal
24ExprTuple55, 26
25Lambdaparameters: 27
body: 28
26Operationoperator: 29
operand: 33
27ExprTuple69, 70
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33
31Literal
32ExprTuple34, 35
33Variable
34Operationoperator: 36
operand: 40
35Operationoperator: 38
operands: 39
36Literal
37ExprTuple40
38Literal
39ExprTuple41, 42
40Lambdaparameters: 79
body: 43
41Operationoperator: 52
operand: 47
42Operationoperator: 64
operands: 45
43Conditionalvalue: 46
condition: 63
44ExprTuple47
45ExprTuple69, 48, 70
46Operationoperator: 49
operands: 50
47Lambdaparameters: 79
body: 51
48Operationoperator: 52
operand: 57
49Literal
50ExprTuple54, 55
51Conditionalvalue: 56
condition: 63
52Literal
53ExprTuple57
54Operationoperator: 64
operands: 58
55Variable
56Operationoperator: 66
operands: 59
57Lambdaparameters: 79
body: 60
58ExprTuple69, 62, 70
59ExprTuple71, 61
60Conditionalvalue: 62
condition: 63
61Operationoperator: 64
operands: 65
62Operationoperator: 66
operands: 67
63Operationoperator: 68
operands: 79
64Literal
65ExprTuple69, 72, 70
66Literal
67ExprTuple71, 72
68Variable
69ExprRangelambda_map: 73
start_index: 86
end_index: 74
70ExprRangelambda_map: 75
start_index: 86
end_index: 76
71Operationoperator: 77
operands: 79
72Operationoperator: 78
operands: 79
73Lambdaparameter: 91
body: 80
74Variable
75Lambdaparameter: 91
body: 81
76Variable
77Variable
78Variable
79ExprTuple82
80IndexedVarvariable: 83
index: 91
81IndexedVarvariable: 84
index: 91
82ExprRangelambda_map: 85
start_index: 86
end_index: 87
83Variable
84Variable
85Lambdaparameter: 91
body: 88
86Literal
87Variable
88IndexedVarvariable: 89
index: 91
89Variable
90ExprTuple91
91Variable