# 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.
# import Expression classes needed to build the expression
from proveit import Conditional, ExprTuple, Lambda, P, Px, Py, X, x, y
from proveit.linear_algebra import HilbertSpaces, Hspace, InnerProd, LinMap, OrthoProj, VecZero
from proveit.logic import And, Equals, Forall, Iff, Implies, InClass, SubsetEq
from proveit.numbers import zero

In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda([Hspace, X], Conditional(Forall(instance_param_or_params = [P], instance_expr = Iff(Equals(P, OrthoProj(Hspace, X)), And(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Px, x), domain = X), Forall(instance_param_or_params = [y], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(InnerProd(x, y), zero), domain = X), Equals(Py, VecZero(Hspace))), domain = Hspace)).with_wrapping_at(2)).with_wrapping_at(2), domain = LinMap(Hspace, Hspace)), And(InClass(Hspace, HilbertSpaces), InClass(X, HilbertSpaces), SubsetEq(X, 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(\left(\mathcal{H}, X\right) \mapsto \left\{\forall_{P \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(P = \textrm{OrthoProj}\left(\mathcal{H}, X\right)\right) \Leftrightarrow  \\ \left(\begin{array}{c} \left[\forall_{x \in X}~\left(P\left(x\right) = x\right)\right] \land  \\ \left[\forall_{y \in \mathcal{H}}~\left(\left[\forall_{x \in X}~\left(\left \langle x, y\right \rangle = 0\right)\right] \Rightarrow \left(P\left(y\right) = \vec{0}\left(\mathcal{H}\right)\right)\right)\right] \end{array}\right) \end{array} \end{array}\right) \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  X \subseteq \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
0ExprTuple1
1Lambdaparameters: 36
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 53
operand: 7
4Operationoperator: 28
operands: 6
5ExprTuple7
6ExprTuple8, 9, 10
7Lambdaparameter: 61
body: 12
8Operationoperator: 14
operands: 13
9Operationoperator: 14
operands: 15
10Operationoperator: 16
operands: 17
11ExprTuple61
12Conditionalvalue: 18
condition: 19
13ExprTuple67, 20
14Literal
15ExprTuple74, 20
16Literal
17ExprTuple74, 67
18Operationoperator: 21
operands: 22
19Operationoperator: 70
operands: 23
20Literal
21Literal
22ExprTuple24, 25
23ExprTuple61, 26
24Operationoperator: 68
operands: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple61, 32
28Literal
29ExprTuple33, 34
30Literal
31ExprTuple67, 67
32Operationoperator: 35
operands: 36
33Operationoperator: 53
operand: 39
34Operationoperator: 53
operand: 40
35Literal
36ExprTuple67, 74
37ExprTuple39
38ExprTuple40
39Lambdaparameter: 77
body: 41
40Lambdaparameter: 78
body: 42
41Conditionalvalue: 43
condition: 66
42Conditionalvalue: 44
condition: 45
43Operationoperator: 68
operands: 46
44Operationoperator: 47
operands: 48
45Operationoperator: 70
operands: 49
46ExprTuple50, 77
47Literal
48ExprTuple51, 52
49ExprTuple78, 67
50Operationoperator: 61
operand: 77
51Operationoperator: 53
operand: 56
52Operationoperator: 68
operands: 55
53Literal
54ExprTuple56
55ExprTuple57, 58
56Lambdaparameter: 77
body: 60
57Operationoperator: 61
operand: 78
58Operationoperator: 63
operand: 67
59ExprTuple77
60Conditionalvalue: 65
condition: 66
61Variable
62ExprTuple78
63Literal
64ExprTuple67
65Operationoperator: 68
operands: 69
66Operationoperator: 70
operands: 71
67Variable
68Literal
69ExprTuple72, 73
70Literal
71ExprTuple77, 74
72Operationoperator: 75
operands: 76
73Literal
74Variable
75Literal
76ExprTuple77, 78
77Variable
78Variable