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, M, i, n
from proveit.core_expr_types import a_1_to_n, a_i, v_i
from proveit.linear_algebra import Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(M, VecSum(index_or_indices = [i], summand = ScalarMult(a_i, Qmult(Ket(v_i), Bra(v_i))), domain = Interval(one, n))), domain = Complex).with_wrapping(), InSet(Set(v_1_to_n_kets), OrthoNormBases(Hspace)))
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}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\\
\left(M = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\end{array} \textrm{ if } \left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathcal{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: 3
operand: 6
2Operationoperator: 47
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 24
operand: 17
8Operationoperator: 12
operand: 18
9ExprTuple14
10Conditionalvalue: 15
condition: 16
11ExprTuple17
12Literal
13ExprTuple18
14ExprRangelambda_map: 19
start_index: 61
end_index: 62
15Operationoperator: 20
operands: 21
16Operationoperator: 22
operands: 23
17Operationoperator: 24
operands: 25
18Variable
19Lambdaparameter: 53
body: 42
20Literal
21ExprTuple26, 27
22Literal
23ExprTuple28
24Literal
25ExprTuple29
26Variable
27Operationoperator: 30
operand: 34
28ExprRangelambda_map: 32
start_index: 61
end_index: 62
29ExprRangelambda_map: 33
start_index: 61
end_index: 62
30Literal
31ExprTuple34
32Lambdaparameter: 53
body: 35
33Lambdaparameter: 53
body: 36
34Lambdaparameter: 69
body: 37
35Operationoperator: 47
operands: 38
36Operationoperator: 63
operand: 44
37Conditionalvalue: 40
condition: 41
38ExprTuple42, 43
39ExprTuple44
40Operationoperator: 45
operands: 46
41Operationoperator: 47
operands: 48
42IndexedVarvariable: 54
index: 53
43Literal
44IndexedVarvariable: 67
index: 53
45Literal
46ExprTuple50, 51
47Literal
48ExprTuple69, 52
49ExprTuple53
50IndexedVarvariable: 54
index: 69
51Operationoperator: 55
operands: 56
52Operationoperator: 57
operands: 58
53Variable
54Variable
55Literal
56ExprTuple59, 60
57Literal
58ExprTuple61, 62
59Operationoperator: 63
operand: 66
60Operationoperator: 64
operand: 66
61Literal
62Variable
63Literal
64Literal
65ExprTuple66
66IndexedVarvariable: 67
index: 69
67Variable
68ExprTuple69
69Variable