logo

Expression of type Conditional

from the theory of proveit.physics.quantum.circuits

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
from proveit.core_expr_types import U_1_to_i, V_1_to_j
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import one
from proveit.physics.quantum import m_ket_domain, var_ket_psi
from proveit.physics.quantum.circuits import circuit_Ui_Vj, circuit_Ui_psi_m, circuit_psi_m_Vj
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [U_1_to_i, V_1_to_j], instance_expr = Implies(Equals(Prob(circuit_Ui_psi_m), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_psi_m_Vj)).with_wrapping_at(2)).with_wrapping_at(2)).with_wrapping(), InSet(var_ket_psi, m_ket_domain))
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}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \qout{\lvert \psi \rangle}
} \end{array}\right) = 1\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & \qw
} \end{array}\right) =  \\ \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & { /^{m} } \qw
} \end{array}\right) \end{array} \end{array}\right) \end{array} \end{array}\right)\end{array} \textrm{ if } \lvert \psi \rangle \in \mathbb{C}^{2^{m}}\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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple69, 8
7Lambdaparameters: 9
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple40, 42
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18
15Literal
16Operationoperator: 19
operands: 20
17Operationoperator: 22
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20ExprTuple24, 72
21ExprTuple25, 71
22Literal
23ExprTuple26, 27
24Literal
25Operationoperator: 30
operand: 32
26Operationoperator: 30
operand: 33
27Operationoperator: 30
operand: 34
28ExprTuple32
29ExprTuple33
30Literal
31ExprTuple34
32Operationoperator: 37
operands: 35
33Operationoperator: 37
operands: 36
34Operationoperator: 37
operands: 38
35ExprTuple40, 39
36ExprTuple40, 42
37Literal
38ExprTuple41, 42
39ExprTuple43
40ExprRangelambda_map: 44
start_index: 71
end_index: 45
41ExprTuple46
42ExprRangelambda_map: 47
start_index: 71
end_index: 48
43ExprRangelambda_map: 49
start_index: 71
end_index: 72
44Lambdaparameter: 70
body: 50
45Variable
46ExprRangelambda_map: 51
start_index: 71
end_index: 72
47Lambdaparameter: 70
body: 52
48Variable
49Lambdaparameter: 70
body: 53
50IndexedVarvariable: 54
index: 70
51Lambdaparameter: 70
body: 55
52IndexedVarvariable: 56
index: 70
53Operationoperator: 59
operands: 58
54Variable
55Operationoperator: 59
operands: 60
56Variable
57ExprTuple70
58NamedExprselement: 61
targets: 63
59Literal
60NamedExprselement: 62
targets: 63
61Operationoperator: 64
operands: 66
62Operationoperator: 65
operands: 66
63Operationoperator: 67
operands: 68
64Literal
65Literal
66NamedExprsstate: 69
part: 70
67Literal
68ExprTuple71, 72
69Variable
70Variable
71Literal
72Variable