# 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, 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 = 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())

\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()

namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 52
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple43, 8
6Operationoperator: 50
operands: 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple43, 14
10Literal
11ExprTuple15, 16
12Literal
13ExprTuple49, 49
14Operationoperator: 17
operands: 18
15Operationoperator: 35
operand: 21
16Operationoperator: 35
operand: 22
17Literal
18ExprTuple49, 56
19ExprTuple21
20ExprTuple22
21Lambdaparameter: 59
body: 23
22Lambdaparameter: 60
body: 24
23Conditionalvalue: 25
condition: 48
24Conditionalvalue: 26
condition: 27
25Operationoperator: 50
operands: 28
26Operationoperator: 29
operands: 30
27Operationoperator: 52
operands: 31
28ExprTuple32, 59
29Literal
30ExprTuple33, 34
31ExprTuple60, 49
32Operationoperator: 43
operand: 59
33Operationoperator: 35
operand: 38
34Operationoperator: 50
operands: 37
35Literal
36ExprTuple38
37ExprTuple39, 40
38Lambdaparameter: 59
body: 42
39Operationoperator: 43
operand: 60
40Operationoperator: 45
operand: 49
41ExprTuple59
42Conditionalvalue: 47
condition: 48
43Variable
44ExprTuple60
45Literal
46ExprTuple49
47Operationoperator: 50
operands: 51
48Operationoperator: 52
operands: 53
49Variable
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple59, 56
54Operationoperator: 57
operands: 58
55Literal
56Variable
57Literal
58ExprTuple59, 60
59Variable
60Variable