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, n, v
from proveit.core_expr_types import A_1_to_n, v_1_to_n
from proveit.linear_algebra import TensorProd
from proveit.logic import And, Equals, 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(v, sub_expr1)
expr = ExprTuple(Lambda([v_1_to_n], Conditional(Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(IndexedVar(A, sub_expr1), [sub_expr2]), one, n))), And(ExprRange(sub_expr1, InSet(sub_expr2, IndexedVar(V, 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(v_{1}, v_{2}, \ldots, v_{n}\right) \mapsto \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) \textrm{ if } \left(v_{1} \in V_{1}\right) \land  \left(v_{2} \in V_{2}\right) \land  \ldots \land  \left(v_{n} \in V_{n}\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: 22
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11
9Operationoperator: 12
operand: 17
10Operationoperator: 21
operands: 14
11ExprRangelambda_map: 15
start_index: 31
end_index: 32
12Operationoperator: 21
operands: 16
13ExprTuple17
14ExprTuple18
15Lambdaparameter: 40
body: 19
16ExprTuple20
17Operationoperator: 21
operands: 22
18ExprRangelambda_map: 23
start_index: 31
end_index: 32
19Operationoperator: 24
operands: 25
20ExprRangelambda_map: 26
start_index: 31
end_index: 32
21Literal
22ExprTuple27
23Lambdaparameter: 40
body: 28
24Literal
25ExprTuple37, 29
26Lambdaparameter: 40
body: 33
27ExprRangelambda_map: 30
start_index: 31
end_index: 32
28Operationoperator: 33
operand: 37
29IndexedVarvariable: 35
index: 40
30Lambdaparameter: 40
body: 37
31Literal
32Variable
33IndexedVarvariable: 36
index: 40
34ExprTuple37
35Variable
36Variable
37IndexedVarvariable: 38
index: 40
38Variable
39ExprTuple40
40Variable