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, K, Lambda, V, 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 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 = TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)
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(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(), 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} 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} \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
2ExprTuple66, 77, 70
3Conditionalvalue: 4
condition: 5
4Operationoperator: 36
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameter: 54
body: 14
10Operationoperator: 49
operands: 15
11Operationoperator: 49
operands: 16
12Operationoperator: 49
operands: 17
13ExprTuple54
14Conditionalvalue: 18
condition: 19
15ExprTuple66, 21
16ExprTuple77, 20
17ExprTuple70, 21
18Operationoperator: 36
operand: 25
19Operationoperator: 23
operands: 24
20Literal
21Literal
22ExprTuple25
23Literal
24ExprTuple54, 26
25Lambdaparameters: 27
body: 28
26Operationoperator: 29
operand: 33
27ExprTuple61, 63
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33
31Literal
32ExprTuple34, 35
33Variable
34Operationoperator: 36
operand: 40
35Operationoperator: 38
operands: 39
36Literal
37ExprTuple40
38Literal
39ExprTuple41, 42
40Lambdaparameters: 68
body: 43
41Operationoperator: 58
operands: 44
42Operationoperator: 51
operand: 48
43Conditionalvalue: 46
condition: 60
44ExprTuple61, 47, 63
45ExprTuple48
46Operationoperator: 49
operands: 50
47Operationoperator: 51
operand: 55
48Lambdaparameters: 68
body: 53
49Literal
50ExprTuple56, 54
51Literal
52ExprTuple55
53Conditionalvalue: 56
condition: 60
54Variable
55Lambdaparameters: 68
body: 57
56Operationoperator: 58
operands: 59
57Conditionalvalue: 62
condition: 60
58Literal
59ExprTuple61, 62, 63
60Operationoperator: 64
operands: 68
61ExprRangelambda_map: 65
start_index: 76
end_index: 66
62Operationoperator: 67
operands: 68
63ExprRangelambda_map: 69
start_index: 76
end_index: 70
64Variable
65Lambdaparameter: 82
body: 71
66Variable
67Variable
68ExprTuple72
69Lambdaparameter: 82
body: 73
70Variable
71IndexedVarvariable: 74
index: 82
72ExprRangelambda_map: 75
start_index: 76
end_index: 77
73IndexedVarvariable: 78
index: 82
74Variable
75Lambdaparameter: 82
body: 79
76Literal
77Variable
78Variable
79IndexedVarvariable: 80
index: 82
80Variable
81ExprTuple82
82Variable