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(TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k), 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)).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(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) \\  = \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] \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
2ExprTuple75, 86, 79
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
15ExprTuple75, 21
16ExprTuple86, 20
17ExprTuple79, 21
18Operationoperator: 36
operand: 25
19Operationoperator: 23
operands: 24
20Literal
21Literal
22ExprTuple25
23Literal
24ExprTuple55, 26
25Lambdaparameters: 27
body: 28
26Operationoperator: 29
operand: 33
27ExprTuple70, 72
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33
31Literal
32ExprTuple34, 35
33Variable
34Operationoperator: 36
operand: 40
35Operationoperator: 38
operands: 39
36Literal
37ExprTuple40
38Literal
39ExprTuple41, 42
40Lambdaparameters: 77
body: 43
41Operationoperator: 67
operands: 44
42Operationoperator: 51
operand: 48
43Conditionalvalue: 46
condition: 62
44ExprTuple70, 47, 72
45ExprTuple48
46Operationoperator: 49
operands: 50
47Operationoperator: 51
operand: 56
48Lambdaparameters: 77
body: 53
49Literal
50ExprTuple54, 55
51Literal
52ExprTuple56
53Conditionalvalue: 57
condition: 62
54Operationoperator: 67
operands: 58
55Variable
56Lambdaparameters: 77
body: 59
57Operationoperator: 64
operands: 60
58ExprTuple70, 61, 72
59Conditionalvalue: 61
condition: 62
60ExprTuple69, 63
61Operationoperator: 64
operands: 65
62Operationoperator: 66
operands: 77
63Operationoperator: 67
operands: 68
64Literal
65ExprTuple69, 71
66Variable
67Literal
68ExprTuple70, 71, 72
69Operationoperator: 73
operands: 77
70ExprRangelambda_map: 74
start_index: 85
end_index: 75
71Operationoperator: 76
operands: 77
72ExprRangelambda_map: 78
start_index: 85
end_index: 79
73Variable
74Lambdaparameter: 91
body: 80
75Variable
76Variable
77ExprTuple81
78Lambdaparameter: 91
body: 82
79Variable
80IndexedVarvariable: 83
index: 91
81ExprRangelambda_map: 84
start_index: 85
end_index: 86
82IndexedVarvariable: 87
index: 91
83Variable
84Lambdaparameter: 91
body: 88
85Literal
86Variable
87Variable
88IndexedVarvariable: 89
index: 91
89Variable
90ExprTuple91
91Variable