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 CartExp, Forall, 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}")
expr = Lambda(m, Conditional(Forall(instance_param_or_params = [n_1_to_m], instance_expr = SubsetEq(TensorProd(ExprRange(sub_expr1, CartExp(K, IndexedVar(n, sub_expr1)), one, m)), CartExp(K, Mult(n_1_to_m))), domain = NaturalPos), InSet(m, NaturalPos)))
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())
m \mapsto \left\{\forall_{n_{1}, n_{2}, \ldots, n_{m} \in \mathbb{N}^+}~\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}}\right) \textrm{ if } m \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 38
body: 2
1ExprTuple38
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 29
operands: 7
5Literal
6ExprTuple8
7ExprTuple38, 33
8Lambdaparameters: 28
body: 9
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 17
14Literal
15ExprTuple18
16Operationoperator: 19
operands: 20
17Operationoperator: 34
operands: 21
18ExprRangelambda_map: 22
start_index: 37
end_index: 38
19Literal
20ExprTuple23
21ExprTuple39, 24
22Lambdaparameter: 43
body: 25
23ExprRangelambda_map: 26
start_index: 37
end_index: 38
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operands: 30
26Lambdaparameter: 43
body: 31
27Literal
28ExprTuple32
29Literal
30ExprTuple40, 33
31Operationoperator: 34
operands: 35
32ExprRangelambda_map: 36
start_index: 37
end_index: 38
33Literal
34Literal
35ExprTuple39, 40
36Lambdaparameter: 43
body: 40
37Literal
38Variable
39Variable
40IndexedVarvariable: 41
index: 43
41Variable
42ExprTuple43
43Variable