logo

Expression of type Conditional

from the theory of proveit.physics.quantum.algebra

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, X, i, n
from proveit.core_expr_types import x_1_to_n, x_i
from proveit.linear_algebra import HilbertSpaces, Hspace, OrthoNormBases, OrthoProj, VecSum
from proveit.logic import Equals, Forall, InClass, InSet, SubsetEq
from proveit.numbers import Interval, NaturalPos, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import x_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [X], instance_expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = Equals(OrthoProj(Hspace, X), VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n))), condition = InSet(x_1_to_n_kets, OrthoNormBases(Hspace))).with_wrapping(), domain = NaturalPos), condition = SubsetEq(X, Hspace)), InClass(Hspace, HilbertSpaces))
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_{X~|~X \subseteq \mathcal{H}}~\left[\forall_{n \in \mathbb{N}^+}~\left[\begin{array}{l}\forall_{x_{1}, x_{2}, \ldots, x_{n}~|~\left\{\lvert x_{1} \rangle, \lvert x_{2} \rangle, \ldots, \lvert x_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\left(\textrm{OrthoProj}\left(\mathcal{H}, X\right) = \left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right)\right)\end{array}\right]\right] \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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: 20
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple49, 7
6Lambdaparameter: 46
body: 9
7Literal
8ExprTuple46
9Conditionalvalue: 10
condition: 11
10Operationoperator: 20
operand: 15
11Operationoperator: 13
operands: 14
12ExprTuple15
13Literal
14ExprTuple46, 49
15Lambdaparameter: 72
body: 17
16ExprTuple72
17Conditionalvalue: 18
condition: 19
18Operationoperator: 20
operand: 23
19Operationoperator: 57
operands: 22
20Literal
21ExprTuple23
22ExprTuple72, 24
23Lambdaparameters: 25
body: 26
24Literal
25ExprTuple27
26Conditionalvalue: 28
condition: 29
27ExprRangelambda_map: 30
start_index: 71
end_index: 72
28Operationoperator: 31
operands: 32
29Operationoperator: 57
operands: 33
30Lambdaparameter: 73
body: 63
31Literal
32ExprTuple34, 35
33ExprTuple36, 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operand: 47
36Operationoperator: 42
operands: 43
37Operationoperator: 44
operand: 49
38Literal
39ExprTuple49, 46
40Literal
41ExprTuple47
42Literal
43ExprTuple48
44Literal
45ExprTuple49
46Variable
47Lambdaparameter: 76
body: 50
48ExprRangelambda_map: 51
start_index: 71
end_index: 72
49Variable
50Conditionalvalue: 52
condition: 53
51Lambdaparameter: 73
body: 54
52Operationoperator: 55
operands: 56
53Operationoperator: 57
operands: 58
54Operationoperator: 64
operand: 63
55Literal
56ExprTuple60, 61
57Literal
58ExprTuple76, 62
59ExprTuple63
60Operationoperator: 64
operand: 70
61Operationoperator: 65
operand: 70
62Operationoperator: 67
operands: 68
63IndexedVarvariable: 74
index: 73
64Literal
65Literal
66ExprTuple70
67Literal
68ExprTuple71, 72
69ExprTuple73
70IndexedVarvariable: 74
index: 76
71Literal
72Variable
73Variable
74Variable
75ExprTuple76
76Variable