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, n, v, w
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import Bases, InnerProd, 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 = [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)
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_{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]
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: 28
operand: 2
1ExprTuple2
2Lambdaparameter: 61
body: 4
3ExprTuple61
4Conditionalvalue: 5
condition: 6
5Operationoperator: 28
operand: 9
6Operationoperator: 51
operands: 8
7ExprTuple9
8ExprTuple61, 10
9Lambdaparameters: 57
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 39
operands: 14
13Operationoperator: 41
operands: 15
14ExprTuple16, 17
15ExprTuple18
16Operationoperator: 51
operands: 19
17Operationoperator: 41
operands: 20
18ExprRangelambda_map: 21
start_index: 60
end_index: 61
19ExprTuple55, 22
20ExprTuple23, 24
21Lambdaparameter: 65
body: 25
22Operationoperator: 26
operand: 36
23Operationoperator: 51
operands: 27
24Operationoperator: 28
operand: 32
25Operationoperator: 51
operands: 30
26Literal
27ExprTuple55, 31
28Literal
29ExprTuple32
30ExprTuple62, 36
31Operationoperator: 33
operand: 36
32Lambdaparameters: 49
body: 35
33Literal
34ExprTuple36
35Conditionalvalue: 37
condition: 38
36Variable
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple45, 46
43Operationoperator: 47
operands: 49
44Operationoperator: 48
operands: 49
45Operationoperator: 51
operands: 50
46Operationoperator: 51
operands: 52
47Literal
48Literal
49ExprTuple53, 54
50ExprTuple53, 55
51Literal
52ExprTuple54, 55
53Variable
54Variable
55Operationoperator: 56
operands: 57
56Literal
57ExprTuple58
58ExprRangelambda_map: 59
start_index: 60
end_index: 61
59Lambdaparameter: 65
body: 62
60Literal
61Variable
62IndexedVarvariable: 63
index: 65
63Variable
64ExprTuple65
65Variable