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

In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(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))

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(P = \textrm{OrthoProj}\left(\mathcal{H}, X\right), \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)

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 42
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple35, 6
4Literal
5ExprTuple7, 8
6Operationoperator: 9
operands: 10
7Operationoperator: 27
operand: 13
8Operationoperator: 27
operand: 14
9Literal
10ExprTuple41, 48
11ExprTuple13
12ExprTuple14
13Lambdaparameter: 51
body: 15
14Lambdaparameter: 52
body: 16
15Conditionalvalue: 17
condition: 40
16Conditionalvalue: 18
condition: 19
17Operationoperator: 42
operands: 20
18Operationoperator: 21
operands: 22
19Operationoperator: 44
operands: 23
20ExprTuple24, 51
21Literal
22ExprTuple25, 26
23ExprTuple52, 41
24Operationoperator: 35
operand: 51
25Operationoperator: 27
operand: 30
26Operationoperator: 42
operands: 29
27Literal
28ExprTuple30
29ExprTuple31, 32
30Lambdaparameter: 51
body: 34
31Operationoperator: 35
operand: 52
32Operationoperator: 37
operand: 41
33ExprTuple51
34Conditionalvalue: 39
condition: 40
35Variable
36ExprTuple52
37Literal
38ExprTuple41
39Operationoperator: 42
operands: 43
40Operationoperator: 44
operands: 45
41Variable
42Literal
43ExprTuple46, 47
44Literal
45ExprTuple51, 48
46Operationoperator: 49
operands: 50
47Literal
48Variable
49Literal
50ExprTuple51, 52
51Variable
52Variable