logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 20
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10
8Operationoperator: 11
operands: 12
9Operationoperator: 26
operands: 13
10ExprRangelambda_map: 14
start_index: 29
end_index: 30
11Literal
12ExprTuple15
13ExprTuple31, 16
14Lambdaparameter: 35
body: 17
15ExprRangelambda_map: 18
start_index: 29
end_index: 30
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Lambdaparameter: 35
body: 23
19Literal
20ExprTuple24
21Literal
22ExprTuple32, 25
23Operationoperator: 26
operands: 27
24ExprRangelambda_map: 28
start_index: 29
end_index: 30
25Literal
26Literal
27ExprTuple31, 32
28Lambdaparameter: 35
body: 32
29Literal
30Variable
31Variable
32IndexedVarvariable: 33
index: 35
33Variable
34ExprTuple35
35Variable