logo

Expression of type ExprTuple

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, ExprTuple, Lambda, 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 = ExprTuple(Lambda(m, 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(m \mapsto \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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 108
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple108, 11
9Operationoperator: 12
operand: 16
10Operationoperator: 42
operands: 14
11Operationoperator: 91
operands: 15
12Literal
13ExprTuple16
14ExprTuple17, 53
15ExprTuple18, 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operand: 29
18Literal
19Operationoperator: 105
operands: 24
20Literal
21ExprTuple25, 26, 27, 28
22Literal
23ExprTuple29
24ExprTuple30, 31
25ExprTuple32, 33
26ExprTuple34, 35
27ExprTuple36, 37
28ExprTuple38, 39
29Operationoperator: 40
operand: 108
30Operationoperator: 42
operands: 43
31Operationoperator: 44
operand: 109
32ExprRangelambda_map: 46
start_index: 109
end_index: 110
33ExprRangelambda_map: 47
start_index: 109
end_index: 111
34ExprRangelambda_map: 48
start_index: 109
end_index: 110
35ExprRangelambda_map: 48
start_index: 98
end_index: 99
36ExprRangelambda_map: 49
start_index: 109
end_index: 110
37ExprRangelambda_map: 50
start_index: 109
end_index: 111
38ExprRangelambda_map: 51
start_index: 109
end_index: 110
39ExprRangelambda_map: 52
start_index: 109
end_index: 111
40Literal
41ExprTuple108
42Literal
43ExprTuple53, 110
44Literal
45ExprTuple109
46Lambdaparameter: 97
body: 54
47Lambdaparameter: 97
body: 55
48Lambdaparameter: 97
body: 56
49Lambdaparameter: 97
body: 57
50Lambdaparameter: 97
body: 58
51Lambdaparameter: 97
body: 59
52Lambdaparameter: 97
body: 61
53Literal
54Operationoperator: 83
operands: 62
55Operationoperator: 69
operands: 63
56Operationoperator: 69
operands: 64
57Operationoperator: 65
operands: 66
58Operationoperator: 84
operands: 67
59Operationoperator: 69
operands: 68
60ExprTuple97
61Operationoperator: 69
operands: 70
62NamedExprsstate: 71
63NamedExprselement: 72
targets: 80
64NamedExprselement: 73
targets: 74
65Literal
66NamedExprsbasis: 75
67NamedExprsoperation: 76
68NamedExprselement: 77
targets: 78
69Literal
70NamedExprselement: 79
targets: 80
71Operationoperator: 81
operand: 93
72Operationoperator: 83
operands: 90
73Operationoperator: 84
operands: 85
74Operationoperator: 91
operands: 86
75Literal
76Literal
77Operationoperator: 89
operands: 87
78Operationoperator: 91
operands: 88
79Operationoperator: 89
operands: 90
80Operationoperator: 91
operands: 92
81Literal
82ExprTuple93
83Literal
84Literal
85NamedExprsoperation: 94
part: 97
86ExprTuple109, 99
87NamedExprsstate: 95
part: 97
88ExprTuple109, 110
89Literal
90NamedExprsstate: 96
part: 97
91Literal
92ExprTuple98, 99
93Literal
94Operationoperator: 100
operands: 101
95Operationoperator: 102
operands: 103
96Literal
97Variable
98Operationoperator: 105
operands: 104
99Operationoperator: 105
operands: 106
100Literal
101ExprTuple107, 110
102Literal
103ExprTuple108, 110
104ExprTuple110, 109
105Literal
106ExprTuple110, 111
107Literal
108Variable
109Literal
110Literal
111Literal