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, ExprRange, H, IndexedVar, Variable, n, v, w, x
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, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Set(x_1_to_n)
expr = Conditional(Equals(InSet(sub_expr2, OrthoNormBases(H)), And(InSet(sub_expr2, Bases(H)), Forall(instance_param_or_params = [v, w], instance_expr = Equals(InnerProd(v, w), KroneckerDelta(v, w)), domain = sub_expr2))).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(x, sub_expr1), H), one, n)))
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\{\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} \textrm{ if } \left(x_{1} \in H\right) \land  \left(x_{2} \in H\right) \land  \ldots \land  \left(x_{n} \in H\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: 28
operands: 3
2Operationoperator: 30
operands: 4
3ExprTuple5, 6
4ExprTuple7
5Operationoperator: 40
operands: 8
6Operationoperator: 30
operands: 9
7ExprRangelambda_map: 10
start_index: 49
end_index: 50
8ExprTuple44, 11
9ExprTuple12, 13
10Lambdaparameter: 54
body: 14
11Operationoperator: 15
operand: 25
12Operationoperator: 40
operands: 16
13Operationoperator: 17
operand: 21
14Operationoperator: 40
operands: 19
15Literal
16ExprTuple44, 20
17Literal
18ExprTuple21
19ExprTuple51, 25
20Operationoperator: 22
operand: 25
21Lambdaparameters: 38
body: 24
22Literal
23ExprTuple25
24Conditionalvalue: 26
condition: 27
25Variable
26Operationoperator: 28
operands: 29
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32, 33
30Literal
31ExprTuple34, 35
32Operationoperator: 36
operands: 38
33Operationoperator: 37
operands: 38
34Operationoperator: 40
operands: 39
35Operationoperator: 40
operands: 41
36Literal
37Literal
38ExprTuple42, 43
39ExprTuple42, 44
40Literal
41ExprTuple43, 44
42Variable
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47
47ExprRangelambda_map: 48
start_index: 49
end_index: 50
48Lambdaparameter: 54
body: 51
49Literal
50Variable
51IndexedVarvariable: 52
index: 54
52Variable
53ExprTuple54
54Variable