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, a, i
from proveit.core_expr_types import V_1_to_i, a_1_to_i
from proveit.linear_algebra import InnerProdSpaces, Norm, TensorProd
from proveit.logic import And, Equals, Forall, InClass
from proveit.numbers import Mult, 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 = Equals(Norm(TensorProd(a_1_to_i)), Mult(ExprRange(sub_expr1, Norm(IndexedVar(a, sub_expr1)), one, i))), domains = sub_expr2).with_wrapping(), And(ExprRange(sub_expr1, InClass(IndexedVar(V, sub_expr1), InnerProdSpaces(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\{\begin{array}{l}\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 \| = \left(\left \|a_{1}\right \| \cdot  \left \|a_{2}\right \| \cdot  \ldots \cdot  \left \|a_{i}\right \|\right)\right)\end{array} \textrm{ if } \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)\right) \land  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)\right) \land  \ldots \land  \left(V_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\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: 1
body: 2
1ExprTuple3
2Conditionalvalue: 4
condition: 5
3ExprRangelambda_map: 6
start_index: 46
end_index: 47
4Operationoperator: 7
operand: 10
5Operationoperator: 19
operands: 9
6Lambdaparameter: 54
body: 44
7Literal
8ExprTuple10
9ExprTuple11
10Lambdaparameters: 38
body: 12
11ExprRangelambda_map: 13
start_index: 46
end_index: 47
12Conditionalvalue: 14
condition: 15
13Lambdaparameter: 54
body: 16
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operands: 22
17Literal
18ExprTuple23, 24
19Literal
20ExprTuple25
21Literal
22ExprTuple44, 26
23Operationoperator: 48
operand: 33
24Operationoperator: 28
operands: 29
25ExprRangelambda_map: 30
start_index: 46
end_index: 47
26Operationoperator: 31
operand: 36
27ExprTuple33
28Literal
29ExprTuple34
30Lambdaparameter: 54
body: 35
31Literal
32ExprTuple36
33Operationoperator: 37
operands: 38
34ExprRangelambda_map: 39
start_index: 46
end_index: 47
35Operationoperator: 40
operands: 41
36Variable
37Literal
38ExprTuple42
39Lambdaparameter: 54
body: 43
40Literal
41ExprTuple51, 44
42ExprRangelambda_map: 45
start_index: 46
end_index: 47
43Operationoperator: 48
operand: 51
44IndexedVarvariable: 50
index: 54
45Lambdaparameter: 54
body: 51
46Literal
47Variable
48Literal
49ExprTuple51
50Variable
51IndexedVarvariable: 52
index: 54
52Variable
53ExprTuple54
54Variable