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 A, B, Conditional, i, n
from proveit.core_expr_types import a_1_to_n, a_i, b_1_to_n, b_i, v_1_to_n, v_i
from proveit.linear_algebra import Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Interval(one, n)
sub_expr3 = Qmult(Ket(v_i), Bra(v_i))
expr = Conditional(Exists(instance_param_or_params = [a_1_to_n, b_1_to_n], instance_expr = And(Equals(A, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr3), domain = sub_expr2))).with_wrapping_at(2), domain = Complex).with_wrapping(), InSet(Set(v_1_to_n), 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}, b_{1}, b_{2}, \ldots, b_{n} \in \mathbb{C}}~\\
\left(\begin{array}{c} \left(A = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \land  \\ \left(B = \left(\sum_{i=1}^{n} \left(b_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \end{array}\right)\end{array} \textrm{ if } \left\{v_{1}, v_{2}, \ldots, v_{n}\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: 63
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 11
operands: 12
8Operationoperator: 13
operand: 20
9ExprTuple15, 16
10Conditionalvalue: 17
condition: 18
11Literal
12ExprTuple19
13Literal
14ExprTuple20
15ExprRangelambda_map: 21
start_index: 77
end_index: 78
16ExprRangelambda_map: 22
start_index: 77
end_index: 78
17Operationoperator: 24
operands: 23
18Operationoperator: 24
operands: 25
19ExprRangelambda_map: 26
start_index: 77
end_index: 78
20Variable
21Lambdaparameter: 59
body: 50
22Lambdaparameter: 59
body: 51
23ExprTuple27, 28
24Literal
25ExprTuple29, 30
26Lambdaparameter: 59
body: 31
27Operationoperator: 33
operands: 32
28Operationoperator: 33
operands: 34
29ExprRangelambda_map: 35
start_index: 77
end_index: 78
30ExprRangelambda_map: 36
start_index: 77
end_index: 78
31IndexedVarvariable: 83
index: 59
32ExprTuple37, 38
33Literal
34ExprTuple39, 40
35Lambdaparameter: 59
body: 41
36Lambdaparameter: 59
body: 42
37Variable
38Operationoperator: 44
operand: 48
39Variable
40Operationoperator: 44
operand: 49
41Operationoperator: 63
operands: 46
42Operationoperator: 63
operands: 47
43ExprTuple48
44Literal
45ExprTuple49
46ExprTuple50, 52
47ExprTuple51, 52
48Lambdaparameter: 85
body: 53
49Lambdaparameter: 85
body: 54
50IndexedVarvariable: 69
index: 59
51IndexedVarvariable: 70
index: 59
52Literal
53Conditionalvalue: 56
condition: 58
54Conditionalvalue: 57
condition: 58
55ExprTuple59
56Operationoperator: 61
operands: 60
57Operationoperator: 61
operands: 62
58Operationoperator: 63
operands: 64
59Variable
60ExprTuple65, 67
61Literal
62ExprTuple66, 67
63Literal
64ExprTuple85, 68
65IndexedVarvariable: 69
index: 85
66IndexedVarvariable: 70
index: 85
67Operationoperator: 71
operands: 72
68Operationoperator: 73
operands: 74
69Variable
70Variable
71Literal
72ExprTuple75, 76
73Literal
74ExprTuple77, 78
75Operationoperator: 79
operand: 82
76Operationoperator: 80
operand: 82
77Literal
78Variable
79Literal
80Literal
81ExprTuple82
82IndexedVarvariable: 83
index: 85
83Variable
84ExprTuple85
85Variable