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, 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, InSet
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(i, Conditional(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(), InSet(i, 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())
i \mapsto \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} \textrm{ if } i \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: 52
body: 2
1ExprTuple52
2Conditionalvalue: 3
condition: 4
3Operationoperator: 15
operand: 7
4Operationoperator: 45
operands: 6
5ExprTuple7
6ExprTuple52, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple11
10Conditionalvalue: 12
condition: 13
11ExprRangelambda_map: 14
start_index: 57
end_index: 52
12Operationoperator: 15
operand: 18
13Operationoperator: 35
operands: 17
14Lambdaparameter: 63
body: 49
15Literal
16ExprTuple18
17ExprTuple19
18Lambdaparameters: 44
body: 20
19ExprRangelambda_map: 21
start_index: 57
end_index: 52
20Conditionalvalue: 22
condition: 23
21Lambdaparameter: 63
body: 24
22Operationoperator: 54
operands: 25
23Operationoperator: 35
operands: 26
24Operationoperator: 27
operands: 28
25ExprTuple29, 57
26ExprTuple30, 31
27Literal
28ExprTuple49, 32
29Operationoperator: 58
operand: 39
30ExprRangelambda_map: 34
start_index: 57
end_index: 52
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operand: 42
33ExprTuple39
34Lambdaparameter: 63
body: 40
35Literal
36ExprTuple41
37Literal
38ExprTuple42
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41ExprRangelambda_map: 47
start_index: 57
end_index: 52
42Variable
43Literal
44ExprTuple48
45Literal
46ExprTuple60, 49
47Lambdaparameter: 63
body: 50
48ExprRangelambda_map: 51
start_index: 57
end_index: 52
49IndexedVarvariable: 53
index: 63
50Operationoperator: 54
operands: 55
51Lambdaparameter: 63
body: 60
52Variable
53Variable
54Literal
55ExprTuple56, 57
56Operationoperator: 58
operand: 60
57Literal
58Literal
59ExprTuple60
60IndexedVarvariable: 61
index: 63
61Variable
62ExprTuple63
63Variable