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 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)), one), domains = sub_expr2, condition = And(ExprRange(sub_expr1, Equals(Norm(IndexedVar(a, sub_expr1)), one), one, i))).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}\right \| = 1\right) \land  \left(\left \|a_{2}\right \| = 1\right) \land  \ldots \land  \left(\left \|a_{i}\right \| = 1\right)}~\\
\left(\left \|a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}\right \| = 1\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: 49
end_index: 44
4Operationoperator: 7
operand: 10
5Operationoperator: 27
operands: 9
6Lambdaparameter: 55
body: 41
7Literal
8ExprTuple10
9ExprTuple11
10Lambdaparameters: 36
body: 12
11ExprRangelambda_map: 13
start_index: 49
end_index: 44
12Conditionalvalue: 14
condition: 15
13Lambdaparameter: 55
body: 16
14Operationoperator: 46
operands: 17
15Operationoperator: 27
operands: 18
16Operationoperator: 19
operands: 20
17ExprTuple21, 49
18ExprTuple22, 23
19Literal
20ExprTuple41, 24
21Operationoperator: 50
operand: 31
22ExprRangelambda_map: 26
start_index: 49
end_index: 44
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operand: 34
25ExprTuple31
26Lambdaparameter: 55
body: 32
27Literal
28ExprTuple33
29Literal
30ExprTuple34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operands: 38
33ExprRangelambda_map: 39
start_index: 49
end_index: 44
34Variable
35Literal
36ExprTuple40
37Literal
38ExprTuple52, 41
39Lambdaparameter: 55
body: 42
40ExprRangelambda_map: 43
start_index: 49
end_index: 44
41IndexedVarvariable: 45
index: 55
42Operationoperator: 46
operands: 47
43Lambdaparameter: 55
body: 52
44Variable
45Variable
46Literal
47ExprTuple48, 49
48Operationoperator: 50
operand: 52
49Literal
50Literal
51ExprTuple52
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable