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 ExprRange, IndexedVar, K, Lambda, 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
from proveit.numbers import NaturalPos, 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(K, Forall(instance_param_or_params = [i], instance_expr = Forall(instance_param_or_params = sub_expr2, instance_expr = 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(), domain = InnerProdSpaces(K)).with_wrapping(), domain = 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())
K \mapsto \left[\forall_{i \in \mathbb{N}^+}~\left[\begin{array}{l}\forall_{V_{1}, V_{2}, \ldots, V_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)}~\\
\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}\right]\end{array}\right]\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 45
body: 1
1Operationoperator: 18
operand: 3
2ExprTuple3
3Lambdaparameter: 55
body: 5
4ExprTuple55
5Conditionalvalue: 6
condition: 7
6Operationoperator: 18
operand: 10
7Operationoperator: 48
operands: 9
8ExprTuple10
9ExprTuple55, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple14
13Conditionalvalue: 15
condition: 16
14ExprRangelambda_map: 17
start_index: 60
end_index: 55
15Operationoperator: 18
operand: 21
16Operationoperator: 38
operands: 20
17Lambdaparameter: 66
body: 52
18Literal
19ExprTuple21
20ExprTuple22
21Lambdaparameters: 47
body: 23
22ExprRangelambda_map: 24
start_index: 60
end_index: 55
23Conditionalvalue: 25
condition: 26
24Lambdaparameter: 66
body: 27
25Operationoperator: 57
operands: 28
26Operationoperator: 38
operands: 29
27Operationoperator: 30
operands: 31
28ExprTuple32, 60
29ExprTuple33, 34
30Literal
31ExprTuple52, 35
32Operationoperator: 61
operand: 42
33ExprRangelambda_map: 37
start_index: 60
end_index: 55
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operand: 45
36ExprTuple42
37Lambdaparameter: 66
body: 43
38Literal
39ExprTuple44
40Literal
41ExprTuple45
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operands: 49
44ExprRangelambda_map: 50
start_index: 60
end_index: 55
45Variable
46Literal
47ExprTuple51
48Literal
49ExprTuple63, 52
50Lambdaparameter: 66
body: 53
51ExprRangelambda_map: 54
start_index: 60
end_index: 55
52IndexedVarvariable: 56
index: 66
53Operationoperator: 57
operands: 58
54Lambdaparameter: 66
body: 63
55Variable
56Variable
57Literal
58ExprTuple59, 60
59Operationoperator: 61
operand: 63
60Literal
61Literal
62ExprTuple63
63IndexedVarvariable: 64
index: 66
64Variable
65ExprTuple66
66Variable