logo

Expression of type Conditional

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.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import Conditional, 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 = 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\{\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..
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: 51
operand: 5
2Operationoperator: 26
operands: 4
3ExprTuple5
4ExprTuple6, 7, 8
5Lambdaparameter: 59
body: 10
6Operationoperator: 12
operands: 11
7Operationoperator: 12
operands: 13
8Operationoperator: 14
operands: 15
9ExprTuple59
10Conditionalvalue: 16
condition: 17
11ExprTuple65, 18
12Literal
13ExprTuple72, 18
14Literal
15ExprTuple72, 65
16Operationoperator: 19
operands: 20
17Operationoperator: 68
operands: 21
18Literal
19Literal
20ExprTuple22, 23
21ExprTuple59, 24
22Operationoperator: 66
operands: 25
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operands: 29
25ExprTuple59, 30
26Literal
27ExprTuple31, 32
28Literal
29ExprTuple65, 65
30Operationoperator: 33
operands: 34
31Operationoperator: 51
operand: 37
32Operationoperator: 51
operand: 38
33Literal
34ExprTuple65, 72
35ExprTuple37
36ExprTuple38
37Lambdaparameter: 75
body: 39
38Lambdaparameter: 76
body: 40
39Conditionalvalue: 41
condition: 64
40Conditionalvalue: 42
condition: 43
41Operationoperator: 66
operands: 44
42Operationoperator: 45
operands: 46
43Operationoperator: 68
operands: 47
44ExprTuple48, 75
45Literal
46ExprTuple49, 50
47ExprTuple76, 65
48Operationoperator: 59
operand: 75
49Operationoperator: 51
operand: 54
50Operationoperator: 66
operands: 53
51Literal
52ExprTuple54
53ExprTuple55, 56
54Lambdaparameter: 75
body: 58
55Operationoperator: 59
operand: 76
56Operationoperator: 61
operand: 65
57ExprTuple75
58Conditionalvalue: 63
condition: 64
59Variable
60ExprTuple76
61Literal
62ExprTuple65
63Operationoperator: 66
operands: 67
64Operationoperator: 68
operands: 69
65Variable
66Literal
67ExprTuple70, 71
68Literal
69ExprTuple75, 72
70Operationoperator: 73
operands: 74
71Literal
72Variable
73Literal
74ExprTuple75, 76
75Variable
76Variable