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 H, K, n, v, w
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import Bases, InnerProd, InnerProdSpaces, OrthoNormBases
from proveit.logic import And, Equals, Forall, InSet, Set
from proveit.numbers import KroneckerDelta, NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Set(x_1_to_n)
expr = Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [H], instance_expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = Equals(InSet(sub_expr1, OrthoNormBases(H)), And(InSet(sub_expr1, Bases(H)), Forall(instance_param_or_params = [v, w], instance_expr = Equals(InnerProd(v, w), KroneckerDelta(v, w)), domain = sub_expr1))).with_wrapping_at(2), domain = H), domain = NaturalPos), domain = InnerProdSpaces(K)))
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_{K}~\left[\forall_{H \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)}~\left[\forall_{n \in \mathbb{N}^+}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in H}~\left(\begin{array}{c} \begin{array}{l} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{O.N.Bases}\left(H\right)\right) =  \\ \left(\left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{Bases}\left(H\right)\right) \land \left[\forall_{v, w \in \left\{x_{1}, x_{2}, \ldots, x_{n}\right\}}~\left(\left \langle v, w\right \rangle = \delta_{v, w}\right)\right]\right) \end{array} \end{array}\right)\right]\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: 42
operand: 2
1ExprTuple2
2Lambdaparameter: 20
body: 3
3Operationoperator: 42
operand: 5
4ExprTuple5
5Lambdaparameter: 50
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 42
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple50, 13
12Lambdaparameter: 75
body: 15
13Operationoperator: 16
operand: 20
14ExprTuple75
15Conditionalvalue: 18
condition: 19
16Literal
17ExprTuple20
18Operationoperator: 42
operand: 23
19Operationoperator: 65
operands: 22
20Variable
21ExprTuple23
22ExprTuple75, 24
23Lambdaparameters: 71
body: 25
24Literal
25Conditionalvalue: 26
condition: 27
26Operationoperator: 53
operands: 28
27Operationoperator: 55
operands: 29
28ExprTuple30, 31
29ExprTuple32
30Operationoperator: 65
operands: 33
31Operationoperator: 55
operands: 34
32ExprRangelambda_map: 35
start_index: 74
end_index: 75
33ExprTuple69, 36
34ExprTuple37, 38
35Lambdaparameter: 79
body: 39
36Operationoperator: 40
operand: 50
37Operationoperator: 65
operands: 41
38Operationoperator: 42
operand: 46
39Operationoperator: 65
operands: 44
40Literal
41ExprTuple69, 45
42Literal
43ExprTuple46
44ExprTuple76, 50
45Operationoperator: 47
operand: 50
46Lambdaparameters: 63
body: 49
47Literal
48ExprTuple50
49Conditionalvalue: 51
condition: 52
50Variable
51Operationoperator: 53
operands: 54
52Operationoperator: 55
operands: 56
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple59, 60
57Operationoperator: 61
operands: 63
58Operationoperator: 62
operands: 63
59Operationoperator: 65
operands: 64
60Operationoperator: 65
operands: 66
61Literal
62Literal
63ExprTuple67, 68
64ExprTuple67, 69
65Literal
66ExprTuple68, 69
67Variable
68Variable
69Operationoperator: 70
operands: 71
70Literal
71ExprTuple72
72ExprRangelambda_map: 73
start_index: 74
end_index: 75
73Lambdaparameter: 79
body: 76
74Literal
75Variable
76IndexedVarvariable: 77
index: 79
77Variable
78ExprTuple79
79Variable