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, 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
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Set(x_1_to_n)
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)
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_{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)
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: 20
operand: 2
1ExprTuple2
2Lambdaparameters: 49
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 31
operands: 6
5Operationoperator: 33
operands: 7
6ExprTuple8, 9
7ExprTuple10
8Operationoperator: 43
operands: 11
9Operationoperator: 33
operands: 12
10ExprRangelambda_map: 13
start_index: 52
end_index: 53
11ExprTuple47, 14
12ExprTuple15, 16
13Lambdaparameter: 57
body: 17
14Operationoperator: 18
operand: 28
15Operationoperator: 43
operands: 19
16Operationoperator: 20
operand: 24
17Operationoperator: 43
operands: 22
18Literal
19ExprTuple47, 23
20Literal
21ExprTuple24
22ExprTuple54, 28
23Operationoperator: 25
operand: 28
24Lambdaparameters: 41
body: 27
25Literal
26ExprTuple28
27Conditionalvalue: 29
condition: 30
28Variable
29Operationoperator: 31
operands: 32
30Operationoperator: 33
operands: 34
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple37, 38
35Operationoperator: 39
operands: 41
36Operationoperator: 40
operands: 41
37Operationoperator: 43
operands: 42
38Operationoperator: 43
operands: 44
39Literal
40Literal
41ExprTuple45, 46
42ExprTuple45, 47
43Literal
44ExprTuple46, 47
45Variable
46Variable
47Operationoperator: 48
operands: 49
48Literal
49ExprTuple50
50ExprRangelambda_map: 51
start_index: 52
end_index: 53
51Lambdaparameter: 57
body: 54
52Literal
53Variable
54IndexedVarvariable: 55
index: 57
55Variable
56ExprTuple57
57Variable