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 OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, CartExp, 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(CartExp(Complex, 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}{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(\mathbb{C}^{n}\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: 65
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: 79
end_index: 80
16ExprRangelambda_map: 22
start_index: 79
end_index: 80
17Operationoperator: 24
operands: 23
18Operationoperator: 24
operands: 25
19ExprRangelambda_map: 26
start_index: 79
end_index: 80
20Operationoperator: 27
operands: 28
21Lambdaparameter: 61
body: 52
22Lambdaparameter: 61
body: 53
23ExprTuple29, 30
24Literal
25ExprTuple31, 32
26Lambdaparameter: 61
body: 33
27Literal
28ExprTuple54, 80
29Operationoperator: 35
operands: 34
30Operationoperator: 35
operands: 36
31ExprRangelambda_map: 37
start_index: 79
end_index: 80
32ExprRangelambda_map: 38
start_index: 79
end_index: 80
33IndexedVarvariable: 85
index: 61
34ExprTuple39, 40
35Literal
36ExprTuple41, 42
37Lambdaparameter: 61
body: 43
38Lambdaparameter: 61
body: 44
39Variable
40Operationoperator: 46
operand: 50
41Variable
42Operationoperator: 46
operand: 51
43Operationoperator: 65
operands: 48
44Operationoperator: 65
operands: 49
45ExprTuple50
46Literal
47ExprTuple51
48ExprTuple52, 54
49ExprTuple53, 54
50Lambdaparameter: 87
body: 55
51Lambdaparameter: 87
body: 56
52IndexedVarvariable: 71
index: 61
53IndexedVarvariable: 72
index: 61
54Literal
55Conditionalvalue: 58
condition: 60
56Conditionalvalue: 59
condition: 60
57ExprTuple61
58Operationoperator: 63
operands: 62
59Operationoperator: 63
operands: 64
60Operationoperator: 65
operands: 66
61Variable
62ExprTuple67, 69
63Literal
64ExprTuple68, 69
65Literal
66ExprTuple87, 70
67IndexedVarvariable: 71
index: 87
68IndexedVarvariable: 72
index: 87
69Operationoperator: 73
operands: 74
70Operationoperator: 75
operands: 76
71Variable
72Variable
73Literal
74ExprTuple77, 78
75Literal
76ExprTuple79, 80
77Operationoperator: 81
operand: 84
78Operationoperator: 82
operand: 84
79Literal
80Variable
81Literal
82Literal
83ExprTuple84
84IndexedVarvariable: 85
index: 87
85Variable
86ExprTuple87
87Variable