logo

Expression of type Forall

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 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, SubsetEq
from proveit.numbers import zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [Hspace, X], instance_expr = 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)), domain = HilbertSpaces, condition = 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())
\forall_{\mathcal{H}, X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}~|~X \subseteq \mathcal{H}}~\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)\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 54
operand: 2
1ExprTuple2
2Lambdaparameters: 37
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 54
operand: 8
5Operationoperator: 29
operands: 7
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameter: 62
body: 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11Operationoperator: 17
operands: 18
12ExprTuple62
13Conditionalvalue: 19
condition: 20
14ExprTuple68, 21
15Literal
16ExprTuple75, 21
17Literal
18ExprTuple75, 68
19Operationoperator: 22
operands: 23
20Operationoperator: 71
operands: 24
21Literal
22Literal
23ExprTuple25, 26
24ExprTuple62, 27
25Operationoperator: 69
operands: 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28ExprTuple62, 33
29Literal
30ExprTuple34, 35
31Literal
32ExprTuple68, 68
33Operationoperator: 36
operands: 37
34Operationoperator: 54
operand: 40
35Operationoperator: 54
operand: 41
36Literal
37ExprTuple68, 75
38ExprTuple40
39ExprTuple41
40Lambdaparameter: 78
body: 42
41Lambdaparameter: 79
body: 43
42Conditionalvalue: 44
condition: 67
43Conditionalvalue: 45
condition: 46
44Operationoperator: 69
operands: 47
45Operationoperator: 48
operands: 49
46Operationoperator: 71
operands: 50
47ExprTuple51, 78
48Literal
49ExprTuple52, 53
50ExprTuple79, 68
51Operationoperator: 62
operand: 78
52Operationoperator: 54
operand: 57
53Operationoperator: 69
operands: 56
54Literal
55ExprTuple57
56ExprTuple58, 59
57Lambdaparameter: 78
body: 61
58Operationoperator: 62
operand: 79
59Operationoperator: 64
operand: 68
60ExprTuple78
61Conditionalvalue: 66
condition: 67
62Variable
63ExprTuple79
64Literal
65ExprTuple68
66Operationoperator: 69
operands: 70
67Operationoperator: 71
operands: 72
68Variable
69Literal
70ExprTuple73, 74
71Literal
72ExprTuple78, 75
73Operationoperator: 76
operands: 77
74Literal
75Variable
76Literal
77ExprTuple78, 79
78Variable
79Variable