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 = [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_{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]
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: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 39
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple47, 10
9Lambdaparameter: 72
body: 12
10Operationoperator: 13
operand: 17
11ExprTuple72
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple17
15Operationoperator: 39
operand: 20
16Operationoperator: 62
operands: 19
17Variable
18ExprTuple20
19ExprTuple72, 21
20Lambdaparameters: 68
body: 22
21Literal
22Conditionalvalue: 23
condition: 24
23Operationoperator: 50
operands: 25
24Operationoperator: 52
operands: 26
25ExprTuple27, 28
26ExprTuple29
27Operationoperator: 62
operands: 30
28Operationoperator: 52
operands: 31
29ExprRangelambda_map: 32
start_index: 71
end_index: 72
30ExprTuple66, 33
31ExprTuple34, 35
32Lambdaparameter: 76
body: 36
33Operationoperator: 37
operand: 47
34Operationoperator: 62
operands: 38
35Operationoperator: 39
operand: 43
36Operationoperator: 62
operands: 41
37Literal
38ExprTuple66, 42
39Literal
40ExprTuple43
41ExprTuple73, 47
42Operationoperator: 44
operand: 47
43Lambdaparameters: 60
body: 46
44Literal
45ExprTuple47
46Conditionalvalue: 48
condition: 49
47Variable
48Operationoperator: 50
operands: 51
49Operationoperator: 52
operands: 53
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple56, 57
54Operationoperator: 58
operands: 60
55Operationoperator: 59
operands: 60
56Operationoperator: 62
operands: 61
57Operationoperator: 62
operands: 63
58Literal
59Literal
60ExprTuple64, 65
61ExprTuple64, 66
62Literal
63ExprTuple65, 66
64Variable
65Variable
66Operationoperator: 67
operands: 68
67Literal
68ExprTuple69
69ExprRangelambda_map: 70
start_index: 71
end_index: 72
70Lambdaparameter: 76
body: 73
71Literal
72Variable
73IndexedVarvariable: 74
index: 76
74Variable
75ExprTuple76
76Variable