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, ExprRange, H, IndexedVar, Lambda, Variable, n, v, w, x
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import Bases, InnerProd, OrthoNormBases
from proveit.logic import And, Equals, Forall, InSet, Set
from proveit.numbers import KroneckerDelta, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Set(x_1_to_n)
expr = Lambda([x_1_to_n], Conditional(Equals(InSet(sub_expr2, OrthoNormBases(H)), And(InSet(sub_expr2, Bases(H)), Forall(instance_param_or_params = [v, w], instance_expr = Equals(InnerProd(v, w), KroneckerDelta(v, w)), domain = sub_expr2))).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(x, sub_expr1), H), one, n))))
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}{c} \begin{array}{l} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{O.N.Bases}\left(H\right)\right) =  \\ \left(\left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{Bases}\left(H\right)\right) \land \left[\forall_{v, w \in \left\{x_{1}, x_{2}, \ldots, x_{n}\right\}}~\left(\left \langle v, w\right \rangle = \delta_{v, w}\right)\right]\right) \end{array} \end{array} \textrm{ if } \left(x_{1} \in H\right) \land  \left(x_{2} \in H\right) \land  \ldots \land  \left(x_{n} \in 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: 47
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 29
operands: 4
3Operationoperator: 31
operands: 5
4ExprTuple6, 7
5ExprTuple8
6Operationoperator: 41
operands: 9
7Operationoperator: 31
operands: 10
8ExprRangelambda_map: 11
start_index: 50
end_index: 51
9ExprTuple45, 12
10ExprTuple13, 14
11Lambdaparameter: 55
body: 15
12Operationoperator: 16
operand: 26
13Operationoperator: 41
operands: 17
14Operationoperator: 18
operand: 22
15Operationoperator: 41
operands: 20
16Literal
17ExprTuple45, 21
18Literal
19ExprTuple22
20ExprTuple52, 26
21Operationoperator: 23
operand: 26
22Lambdaparameters: 39
body: 25
23Literal
24ExprTuple26
25Conditionalvalue: 27
condition: 28
26Variable
27Operationoperator: 29
operands: 30
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Operationoperator: 37
operands: 39
34Operationoperator: 38
operands: 39
35Operationoperator: 41
operands: 40
36Operationoperator: 41
operands: 42
37Literal
38Literal
39ExprTuple43, 44
40ExprTuple43, 45
41Literal
42ExprTuple44, 45
43Variable
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48
48ExprRangelambda_map: 49
start_index: 50
end_index: 51
49Lambdaparameter: 55
body: 52
50Literal
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable