# 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, Lambda, P, Px, Py, X, x, y
from proveit.linear_algebra import Hspace, InnerProd, LinMap, OrthoProj, VecZero
from proveit.logic import And, Equals, Forall, Iff, Implies, InSet
from proveit.numbers import zero

In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(P, Conditional(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), InSet(P, LinMap(Hspace, 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())

P \mapsto \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} \textrm{ if } P \in \mathcal{L}\left(\mathcal{H}, \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
0Lambdaparameter: 45
body: 2
1ExprTuple45
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 54
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple45, 10
8Operationoperator: 52
operands: 11
9Operationoperator: 12
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple45, 16
12Literal
13ExprTuple17, 18
14Literal
15ExprTuple51, 51
16Operationoperator: 19
operands: 20
17Operationoperator: 37
operand: 23
18Operationoperator: 37
operand: 24
19Literal
20ExprTuple51, 58
21ExprTuple23
22ExprTuple24
23Lambdaparameter: 61
body: 25
24Lambdaparameter: 62
body: 26
25Conditionalvalue: 27
condition: 50
26Conditionalvalue: 28
condition: 29
27Operationoperator: 52
operands: 30
28Operationoperator: 31
operands: 32
29Operationoperator: 54
operands: 33
30ExprTuple34, 61
31Literal
32ExprTuple35, 36
33ExprTuple62, 51
34Operationoperator: 45
operand: 61
35Operationoperator: 37
operand: 40
36Operationoperator: 52
operands: 39
37Literal
38ExprTuple40
39ExprTuple41, 42
40Lambdaparameter: 61
body: 44
41Operationoperator: 45
operand: 62
42Operationoperator: 47
operand: 51
43ExprTuple61
44Conditionalvalue: 49
condition: 50
45Variable
46ExprTuple62
47Literal
48ExprTuple51
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operands: 55
51Variable
52Literal
53ExprTuple56, 57
54Literal
55ExprTuple61, 58
56Operationoperator: 59
operands: 60
57Literal
58Variable
59Literal
60ExprTuple61, 62
61Variable
62Variable