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(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)), 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\{\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] \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
2ExprTuple65, 78, 67
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
15ExprTuple65, 21
16ExprTuple78, 20
17ExprTuple67, 21
18Operationoperator: 36
operand: 25
19Operationoperator: 23
operands: 24
20Literal
21Literal
22ExprTuple25
23Literal
24ExprTuple54, 26
25Lambdaparameters: 27
body: 28
26Operationoperator: 29
operand: 33
27ExprTuple60, 61
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33
31Literal
32ExprTuple34, 35
33Variable
34Operationoperator: 36
operand: 40
35Operationoperator: 38
operands: 39
36Literal
37ExprTuple40
38Literal
39ExprTuple41, 42
40Lambdaparameters: 70
body: 43
41Operationoperator: 52
operand: 47
42Operationoperator: 57
operands: 45
43Conditionalvalue: 46
condition: 63
44ExprTuple47
45ExprTuple60, 48, 61
46Operationoperator: 49
operands: 50
47Lambdaparameters: 70
body: 51
48Operationoperator: 52
operand: 56
49Literal
50ExprTuple55, 54
51Conditionalvalue: 55
condition: 63
52Literal
53ExprTuple56
54Variable
55Operationoperator: 57
operands: 58
56Lambdaparameters: 70
body: 59
57Literal
58ExprTuple60, 62, 61
59Conditionalvalue: 62
condition: 63
60ExprRangelambda_map: 64
start_index: 77
end_index: 65
61ExprRangelambda_map: 66
start_index: 77
end_index: 67
62Operationoperator: 68
operands: 70
63Operationoperator: 69
operands: 70
64Lambdaparameter: 82
body: 71
65Variable
66Lambdaparameter: 82
body: 72
67Variable
68Variable
69Variable
70ExprTuple73
71IndexedVarvariable: 74
index: 82
72IndexedVarvariable: 75
index: 82
73ExprRangelambda_map: 76
start_index: 77
end_index: 78
74Variable
75Variable
76Lambdaparameter: 82
body: 79
77Literal
78Variable
79IndexedVarvariable: 80
index: 82
80Variable
81ExprTuple82
82Variable