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, V, Variable, i
from proveit.core_expr_types import V_1_to_i, a_1_to_i
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import And, Forall, InClass, 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 = [V_1_to_i]
expr = Lambda(sub_expr2, Conditional(Forall(instance_param_or_params = [a_1_to_i], instance_expr = InSet(TensorProd(a_1_to_i), TensorProd(V_1_to_i)), domains = sub_expr2), And(ExprRange(sub_expr1, InClass(IndexedVar(V, sub_expr1), VecSpaces(K)), one, i))))
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(V_{1}, V_{2}, \ldots, V_{i}\right) \mapsto \left\{\forall_{\left(a_{1} \in V_{1}\right), \left(a_{2} \in V_{2}\right), \ldots, \left(a_{i} \in V_{i}\right)}~\left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}\right) \in \left(V_{1} {\otimes}  V_{2} {\otimes}  \ldots {\otimes}  V_{i}\right)\right) \textrm{ if } \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) \land  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) \land  \ldots \land  \left(V_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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
0Lambdaparameters: 25
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 15
operands: 6
4Literal
5ExprTuple7
6ExprTuple8
7Lambdaparameters: 23
body: 9
8ExprRangelambda_map: 10
start_index: 35
end_index: 36
9Conditionalvalue: 11
condition: 12
10Lambdaparameter: 44
body: 13
11Operationoperator: 37
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19, 20
15Literal
16ExprTuple21
17Literal
18ExprTuple40, 22
19Operationoperator: 24
operands: 23
20Operationoperator: 24
operands: 25
21ExprRangelambda_map: 26
start_index: 35
end_index: 36
22Operationoperator: 27
operand: 32
23ExprTuple29
24Literal
25ExprTuple30
26Lambdaparameter: 44
body: 31
27Literal
28ExprTuple32
29ExprRangelambda_map: 33
start_index: 35
end_index: 36
30ExprRangelambda_map: 34
start_index: 35
end_index: 36
31Operationoperator: 37
operands: 38
32Variable
33Lambdaparameter: 44
body: 39
34Lambdaparameter: 44
body: 40
35Literal
36Variable
37Literal
38ExprTuple39, 40
39IndexedVarvariable: 41
index: 44
40IndexedVarvariable: 42
index: 44
41Variable
42Variable
43ExprTuple44
44Variable