logo

Expression of type ExprTuple

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, ExprTuple, H, IndexedVar, Lambda, 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 = ExprTuple(Lambda([x_1_to_n], 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(\left(x_{1}, x_{2}, \ldots, x_{n}\right) \mapsto \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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 48
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 30
operands: 5
4Operationoperator: 32
operands: 6
5ExprTuple7, 8
6ExprTuple9
7Operationoperator: 42
operands: 10
8Operationoperator: 32
operands: 11
9ExprRangelambda_map: 12
start_index: 51
end_index: 52
10ExprTuple46, 13
11ExprTuple14, 15
12Lambdaparameter: 56
body: 16
13Operationoperator: 17
operand: 27
14Operationoperator: 42
operands: 18
15Operationoperator: 19
operand: 23
16Operationoperator: 42
operands: 21
17Literal
18ExprTuple46, 22
19Literal
20ExprTuple23
21ExprTuple53, 27
22Operationoperator: 24
operand: 27
23Lambdaparameters: 40
body: 26
24Literal
25ExprTuple27
26Conditionalvalue: 28
condition: 29
27Variable
28Operationoperator: 30
operands: 31
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34, 35
32Literal
33ExprTuple36, 37
34Operationoperator: 38
operands: 40
35Operationoperator: 39
operands: 40
36Operationoperator: 42
operands: 41
37Operationoperator: 42
operands: 43
38Literal
39Literal
40ExprTuple44, 45
41ExprTuple44, 46
42Literal
43ExprTuple45, 46
44Variable
45Variable
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49
49ExprRangelambda_map: 50
start_index: 51
end_index: 52
50Lambdaparameter: 56
body: 53
51Literal
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable