logo

Expression of type Lambda

from the theory of proveit.linear_algebra.inner_products

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, Lambda, M, i, n
from proveit.core_expr_types import a_1_to_n, a_i, x_1_to_n, x_i
from proveit.linear_algebra import Hspace, OrthoNormBases, OrthoProj, ScalarMult, Span, VecSum
from proveit.logic import Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, one
In [2]:
# build up the expression from sub-expressions
expr = Lambda([x_1_to_n], Conditional(Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(M, VecSum(index_or_indices = [i], summand = ScalarMult(a_i, OrthoProj(Hspace, Span(Set(x_i)))), domain = Interval(one, n))), domain = Complex).with_wrapping(), InSet(Set(x_1_to_n), OrthoNormBases(Hspace))))
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(x_{1}, x_{2}, \ldots, x_{n}\right) \mapsto \left\{\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\\
\left(M = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \textrm{OrthoProj}\left(\mathcal{H}, \textrm{Span}\left(\left\{x_{i}\right\}\right)\right)\right)\right)\right)\end{array} \textrm{ if } \left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\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: 12
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 42
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 61
operands: 12
9Operationoperator: 13
operand: 54
10ExprTuple15
11Conditionalvalue: 16
condition: 17
12ExprTuple18
13Literal
14ExprTuple54
15ExprRangelambda_map: 19
start_index: 56
end_index: 57
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18ExprRangelambda_map: 24
start_index: 56
end_index: 57
19Lambdaparameter: 48
body: 38
20Literal
21ExprTuple25, 26
22Literal
23ExprTuple27
24Lambdaparameter: 48
body: 28
25Variable
26Operationoperator: 29
operand: 32
27ExprRangelambda_map: 31
start_index: 56
end_index: 57
28IndexedVarvariable: 64
index: 48
29Literal
30ExprTuple32
31Lambdaparameter: 48
body: 33
32Lambdaparameter: 66
body: 34
33Operationoperator: 42
operands: 35
34Conditionalvalue: 36
condition: 37
35ExprTuple38, 39
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operands: 43
38IndexedVarvariable: 49
index: 48
39Literal
40Literal
41ExprTuple45, 46
42Literal
43ExprTuple66, 47
44ExprTuple48
45IndexedVarvariable: 49
index: 66
46Operationoperator: 50
operands: 51
47Operationoperator: 52
operands: 53
48Variable
49Variable
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple56, 57
54Variable
55Operationoperator: 58
operand: 60
56Literal
57Variable
58Literal
59ExprTuple60
60Operationoperator: 61
operand: 63
61Literal
62ExprTuple63
63IndexedVarvariable: 64
index: 66
64Variable
65ExprTuple66
66Variable