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

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

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

\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}

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()(2)('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 44
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple37, 8
6Literal
7ExprTuple9, 10
8Operationoperator: 11
operands: 12
9Operationoperator: 29
operand: 15
10Operationoperator: 29
operand: 16
11Literal
12ExprTuple43, 50
13ExprTuple15
14ExprTuple16
15Lambdaparameter: 53
body: 17
16Lambdaparameter: 54
body: 18
17Conditionalvalue: 19
condition: 42
18Conditionalvalue: 20
condition: 21
19Operationoperator: 44
operands: 22
20Operationoperator: 23
operands: 24
21Operationoperator: 46
operands: 25
22ExprTuple26, 53
23Literal
24ExprTuple27, 28
25ExprTuple54, 43
26Operationoperator: 37
operand: 53
27Operationoperator: 29
operand: 32
28Operationoperator: 44
operands: 31
29Literal
30ExprTuple32
31ExprTuple33, 34
32Lambdaparameter: 53
body: 36
33Operationoperator: 37
operand: 54
34Operationoperator: 39
operand: 43
35ExprTuple53
36Conditionalvalue: 41
condition: 42
37Variable
38ExprTuple54
39Literal
40ExprTuple43
41Operationoperator: 44
operands: 45
42Operationoperator: 46
operands: 47
43Variable
44Literal
45ExprTuple48, 49
46Literal
47ExprTuple53, 50
48Operationoperator: 51
operands: 52
49Literal
50Variable
51Literal
52ExprTuple53, 54
53Variable
54Variable