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 Equals, Forall, InSet
from proveit.numbers import Mult, 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)), Mult(ExprRange(sub_expr1, Norm(IndexedVar(a, sub_expr1)), one, i))), domains = sub_expr2).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} {\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}\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: 55
body: 2
1ExprTuple55
2Conditionalvalue: 3
condition: 4
3Operationoperator: 15
operand: 7
4Operationoperator: 48
operands: 6
5ExprTuple7
6ExprTuple55, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple11
10Conditionalvalue: 12
condition: 13
11ExprRangelambda_map: 14
start_index: 54
end_index: 55
12Operationoperator: 15
operand: 18
13Operationoperator: 27
operands: 17
14Lambdaparameter: 62
body: 52
15Literal
16ExprTuple18
17ExprTuple19
18Lambdaparameters: 46
body: 20
19ExprRangelambda_map: 21
start_index: 54
end_index: 55
20Conditionalvalue: 22
condition: 23
21Lambdaparameter: 62
body: 24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Literal
26ExprTuple31, 32
27Literal
28ExprTuple33
29Literal
30ExprTuple52, 34
31Operationoperator: 56
operand: 41
32Operationoperator: 36
operands: 37
33ExprRangelambda_map: 38
start_index: 54
end_index: 55
34Operationoperator: 39
operand: 44
35ExprTuple41
36Literal
37ExprTuple42
38Lambdaparameter: 62
body: 43
39Literal
40ExprTuple44
41Operationoperator: 45
operands: 46
42ExprRangelambda_map: 47
start_index: 54
end_index: 55
43Operationoperator: 48
operands: 49
44Variable
45Literal
46ExprTuple50
47Lambdaparameter: 62
body: 51
48Literal
49ExprTuple59, 52
50ExprRangelambda_map: 53
start_index: 54
end_index: 55
51Operationoperator: 56
operand: 59
52IndexedVarvariable: 58
index: 62
53Lambdaparameter: 62
body: 59
54Literal
55Variable
56Literal
57ExprTuple59
58Variable
59IndexedVarvariable: 60
index: 62
60Variable
61ExprTuple62
62Variable