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 A, Conditional, ExprRange, ExprTuple, Function, IndexedVar, Lambda, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, TensorProd
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, sub_expr1)
expr = ExprTuple(Lambda([A_1_to_n], Conditional(Forall(instance_param_or_params = [v_1_to_n], instance_expr = Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(sub_expr2, [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), And(ExprRange(sub_expr1, InSet(sub_expr2, LinMap(IndexedVar(V, sub_expr1), IndexedVar(W, sub_expr1))), one, n)))))
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(A_{1}, A_{2}, \ldots, A_{n}\right) \mapsto \left\{\begin{array}{l}\forall_{\left(v_{1} \in V_{1}\right), \left(v_{2} \in V_{2}\right), \ldots, \left(v_{n} \in V_{n}\right)}~\\
\left(\left(A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{n}\right)\left(v_{1} {\otimes}  v_{2} {\otimes}  \ldots {\otimes}  v_{n}\right) = \left(A_{1}\left(v_{1}\right) {\otimes}  A_{2}\left(v_{2}\right) {\otimes}  \ldots {\otimes}  A_{n}\left(v_{n}\right)\right)\right)\end{array} \textrm{ if } \left(A_{1} \in \mathcal{L}\left(V_{1}, W_{1}\right)\right) \land  \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right) \land  \ldots \land  \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\right)\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: 30
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 17
operands: 7
5Literal
6ExprTuple8
7ExprTuple9
8Lambdaparameters: 37
body: 10
9ExprRangelambda_map: 11
start_index: 47
end_index: 48
10Conditionalvalue: 12
condition: 13
11Lambdaparameter: 56
body: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 39
operands: 19
15Literal
16ExprTuple20, 21
17Literal
18ExprTuple22
19ExprTuple49, 23
20Operationoperator: 24
operand: 31
21Operationoperator: 36
operands: 26
22ExprRangelambda_map: 27
start_index: 47
end_index: 48
23Operationoperator: 28
operands: 29
24Operationoperator: 36
operands: 30
25ExprTuple31
26ExprTuple32
27Lambdaparameter: 56
body: 33
28Literal
29ExprTuple45, 34
30ExprTuple35
31Operationoperator: 36
operands: 37
32ExprRangelambda_map: 38
start_index: 47
end_index: 48
33Operationoperator: 39
operands: 40
34IndexedVarvariable: 41
index: 56
35ExprRangelambda_map: 42
start_index: 47
end_index: 48
36Literal
37ExprTuple43
38Lambdaparameter: 56
body: 44
39Literal
40ExprTuple53, 45
41Variable
42Lambdaparameter: 56
body: 49
43ExprRangelambda_map: 46
start_index: 47
end_index: 48
44Operationoperator: 49
operand: 53
45IndexedVarvariable: 51
index: 56
46Lambdaparameter: 56
body: 53
47Literal
48Variable
49IndexedVarvariable: 52
index: 56
50ExprTuple53
51Variable
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable