logo

Expression of type Lambda

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