logo

Expression of type Conditional

from the theory of proveit.physics.quantum.QPE

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
from proveit.logic import Equals, InSet
from proveit.physics.quantum.QPE import _alpha_m_sqrd, _m_domain, _phase_est_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Equals(Prob(_phase_est_circuit), _alpha_m_sqrd), InSet(m, _m_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\{\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert + \rangle} & \multigate{4}{\textrm{QPE}\left(U, t\right)} & \meter & \multiqout{3}{\lvert m \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \ghost{\textrm{QPE}\left(U, t\right)} & \measure{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\lvert u \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & { /^{s} } \qw & \qout{\lvert u \rangle}
} \end{array}\right) = \left|\alpha_{m}\right|^{2} \textrm{ if } m \in \{0~\ldotp \ldotp~2^{t} - 1\}\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
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple106, 9
7Operationoperator: 10
operand: 14
8Operationoperator: 40
operands: 12
9Operationoperator: 89
operands: 13
10Literal
11ExprTuple14
12ExprTuple15, 51
13ExprTuple16, 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operand: 27
16Literal
17Operationoperator: 103
operands: 22
18Literal
19ExprTuple23, 24, 25, 26
20Literal
21ExprTuple27
22ExprTuple28, 29
23ExprTuple30, 31
24ExprTuple32, 33
25ExprTuple34, 35
26ExprTuple36, 37
27Operationoperator: 38
operand: 106
28Operationoperator: 40
operands: 41
29Operationoperator: 42
operand: 107
30ExprRangelambda_map: 44
start_index: 107
end_index: 108
31ExprRangelambda_map: 45
start_index: 107
end_index: 109
32ExprRangelambda_map: 46
start_index: 107
end_index: 108
33ExprRangelambda_map: 46
start_index: 96
end_index: 97
34ExprRangelambda_map: 47
start_index: 107
end_index: 108
35ExprRangelambda_map: 48
start_index: 107
end_index: 109
36ExprRangelambda_map: 49
start_index: 107
end_index: 108
37ExprRangelambda_map: 50
start_index: 107
end_index: 109
38Literal
39ExprTuple106
40Literal
41ExprTuple51, 108
42Literal
43ExprTuple107
44Lambdaparameter: 95
body: 52
45Lambdaparameter: 95
body: 53
46Lambdaparameter: 95
body: 54
47Lambdaparameter: 95
body: 55
48Lambdaparameter: 95
body: 56
49Lambdaparameter: 95
body: 57
50Lambdaparameter: 95
body: 59
51Literal
52Operationoperator: 81
operands: 60
53Operationoperator: 67
operands: 61
54Operationoperator: 67
operands: 62
55Operationoperator: 63
operands: 64
56Operationoperator: 82
operands: 65
57Operationoperator: 67
operands: 66
58ExprTuple95
59Operationoperator: 67
operands: 68
60NamedExprsstate: 69
61NamedExprselement: 70
targets: 78
62NamedExprselement: 71
targets: 72
63Literal
64NamedExprsbasis: 73
65NamedExprsoperation: 74
66NamedExprselement: 75
targets: 76
67Literal
68NamedExprselement: 77
targets: 78
69Operationoperator: 79
operand: 91
70Operationoperator: 81
operands: 88
71Operationoperator: 82
operands: 83
72Operationoperator: 89
operands: 84
73Literal
74Literal
75Operationoperator: 87
operands: 85
76Operationoperator: 89
operands: 86
77Operationoperator: 87
operands: 88
78Operationoperator: 89
operands: 90
79Literal
80ExprTuple91
81Literal
82Literal
83NamedExprsoperation: 92
part: 95
84ExprTuple107, 97
85NamedExprsstate: 93
part: 95
86ExprTuple107, 108
87Literal
88NamedExprsstate: 94
part: 95
89Literal
90ExprTuple96, 97
91Literal
92Operationoperator: 98
operands: 99
93Operationoperator: 100
operands: 101
94Literal
95Variable
96Operationoperator: 103
operands: 102
97Operationoperator: 103
operands: 104
98Literal
99ExprTuple105, 108
100Literal
101ExprTuple106, 108
102ExprTuple108, 107
103Literal
104ExprTuple108, 109
105Literal
106Variable
107Literal
108Literal
109Literal