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 Hspace, InnerProd, LinMap, 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 = 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))
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_{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)
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: 39
operand: 2
1ExprTuple2
2Lambdaparameter: 47
body: 4
3ExprTuple47
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 56
operands: 9
7Literal
8ExprTuple10, 11
9ExprTuple47, 12
10Operationoperator: 54
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple47, 18
14Literal
15ExprTuple19, 20
16Literal
17ExprTuple53, 53
18Operationoperator: 21
operands: 22
19Operationoperator: 39
operand: 25
20Operationoperator: 39
operand: 26
21Literal
22ExprTuple53, 60
23ExprTuple25
24ExprTuple26
25Lambdaparameter: 63
body: 27
26Lambdaparameter: 64
body: 28
27Conditionalvalue: 29
condition: 52
28Conditionalvalue: 30
condition: 31
29Operationoperator: 54
operands: 32
30Operationoperator: 33
operands: 34
31Operationoperator: 56
operands: 35
32ExprTuple36, 63
33Literal
34ExprTuple37, 38
35ExprTuple64, 53
36Operationoperator: 47
operand: 63
37Operationoperator: 39
operand: 42
38Operationoperator: 54
operands: 41
39Literal
40ExprTuple42
41ExprTuple43, 44
42Lambdaparameter: 63
body: 46
43Operationoperator: 47
operand: 64
44Operationoperator: 49
operand: 53
45ExprTuple63
46Conditionalvalue: 51
condition: 52
47Variable
48ExprTuple64
49Literal
50ExprTuple53
51Operationoperator: 54
operands: 55
52Operationoperator: 56
operands: 57
53Variable
54Literal
55ExprTuple58, 59
56Literal
57ExprTuple63, 60
58Operationoperator: 61
operands: 62
59Literal
60Variable
61Literal
62ExprTuple63, 64
63Variable
64Variable