logo

Expression of type Conditional

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 Conditional, 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, InClass, 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 = Conditional(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), InClass(H, 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())
\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] \textrm{ if } H \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 36
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple44, 7
6Lambdaparameter: 69
body: 9
7Operationoperator: 10
operand: 14
8ExprTuple69
9Conditionalvalue: 12
condition: 13
10Literal
11ExprTuple14
12Operationoperator: 36
operand: 17
13Operationoperator: 59
operands: 16
14Variable
15ExprTuple17
16ExprTuple69, 18
17Lambdaparameters: 65
body: 19
18Literal
19Conditionalvalue: 20
condition: 21
20Operationoperator: 47
operands: 22
21Operationoperator: 49
operands: 23
22ExprTuple24, 25
23ExprTuple26
24Operationoperator: 59
operands: 27
25Operationoperator: 49
operands: 28
26ExprRangelambda_map: 29
start_index: 68
end_index: 69
27ExprTuple63, 30
28ExprTuple31, 32
29Lambdaparameter: 73
body: 33
30Operationoperator: 34
operand: 44
31Operationoperator: 59
operands: 35
32Operationoperator: 36
operand: 40
33Operationoperator: 59
operands: 38
34Literal
35ExprTuple63, 39
36Literal
37ExprTuple40
38ExprTuple70, 44
39Operationoperator: 41
operand: 44
40Lambdaparameters: 57
body: 43
41Literal
42ExprTuple44
43Conditionalvalue: 45
condition: 46
44Variable
45Operationoperator: 47
operands: 48
46Operationoperator: 49
operands: 50
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple53, 54
51Operationoperator: 55
operands: 57
52Operationoperator: 56
operands: 57
53Operationoperator: 59
operands: 58
54Operationoperator: 59
operands: 60
55Literal
56Literal
57ExprTuple61, 62
58ExprTuple61, 63
59Literal
60ExprTuple62, 63
61Variable
62Variable
63Operationoperator: 64
operands: 65
64Literal
65ExprTuple66
66ExprRangelambda_map: 67
start_index: 68
end_index: 69
67Lambdaparameter: 73
body: 70
68Literal
69Variable
70IndexedVarvariable: 71
index: 73
71Variable
72ExprTuple73
73Variable