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, ExprRange, ExprTuple, IndexedVar, K, Lambda, Variable, m, n
from proveit.core_expr_types import n_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.logic import And, CartExp, InSet, SubsetEq
from proveit.numbers import Mult, NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(n, sub_expr1)
expr = ExprTuple(Lambda([n_1_to_m], Conditional(SubsetEq(TensorProd(ExprRange(sub_expr1, CartExp(K, sub_expr2), one, m)), CartExp(K, Mult(n_1_to_m))), And(ExprRange(sub_expr1, InSet(sub_expr2, NaturalPos), one, m)))))
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(n_{1}, n_{2}, \ldots, n_{m}\right) \mapsto \left\{\left(K^{n_{1}} {\otimes}  K^{n_{2}} {\otimes}  \ldots {\otimes}  K^{n_{m}}\right) \subseteq K^{n_{1} \cdot  n_{2} \cdot  \ldots \cdot  n_{m}} \textrm{ if } \left(n_{1} \in \mathbb{N}^+\right) \land  \left(n_{2} \in \mathbb{N}^+\right) \land  \ldots \land  \left(n_{m} \in \mathbb{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: 21
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11
9Operationoperator: 12
operands: 13
10Operationoperator: 27
operands: 14
11ExprRangelambda_map: 15
start_index: 30
end_index: 31
12Literal
13ExprTuple16
14ExprTuple32, 17
15Lambdaparameter: 36
body: 18
16ExprRangelambda_map: 19
start_index: 30
end_index: 31
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19Lambdaparameter: 36
body: 24
20Literal
21ExprTuple25
22Literal
23ExprTuple33, 26
24Operationoperator: 27
operands: 28
25ExprRangelambda_map: 29
start_index: 30
end_index: 31
26Literal
27Literal
28ExprTuple32, 33
29Lambdaparameter: 36
body: 33
30Literal
31Variable
32Variable
33IndexedVarvariable: 34
index: 36
34Variable
35ExprTuple36
36Variable