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 And, InSet
from proveit.physics.quantum.QPE import _m_domain, _phase_est_circuit, _success_cond
In [2]:
# build up the expression from sub-expressions
expr = Lambda(m, Conditional(_phase_est_circuit, And(InSet(m, _m_domain), _success_cond)))
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\{\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} \textrm{ if } m \in \{0~\ldotp \ldotp~2^{t} - 1\} ,  \left|\frac{m}{2^{t}} - \varphi\right|_{\textup{mod}\thinspace 1} \leq 2^{-n}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 113
body: 2
1ExprTuple113
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10, 11, 12
7Literal
8ExprTuple13, 14
9ExprTuple15, 16
10ExprTuple17, 18
11ExprTuple19, 20
12ExprTuple21, 22
13Operationoperator: 23
operands: 24
14Operationoperator: 25
operands: 26
15ExprRangelambda_map: 27
start_index: 114
end_index: 119
16ExprRangelambda_map: 28
start_index: 114
end_index: 115
17ExprRangelambda_map: 29
start_index: 114
end_index: 119
18ExprRangelambda_map: 29
start_index: 96
end_index: 97
19ExprRangelambda_map: 30
start_index: 114
end_index: 119
20ExprRangelambda_map: 31
start_index: 114
end_index: 115
21ExprRangelambda_map: 32
start_index: 114
end_index: 119
22ExprRangelambda_map: 33
start_index: 114
end_index: 115
23Literal
24ExprTuple113, 34
25Literal
26ExprTuple35, 36
27Lambdaparameter: 95
body: 37
28Lambdaparameter: 95
body: 38
29Lambdaparameter: 95
body: 39
30Lambdaparameter: 95
body: 40
31Lambdaparameter: 95
body: 41
32Lambdaparameter: 95
body: 42
33Lambdaparameter: 95
body: 44
34Operationoperator: 85
operands: 45
35Operationoperator: 46
operands: 47
36Operationoperator: 116
operands: 48
37Operationoperator: 77
operands: 49
38Operationoperator: 56
operands: 50
39Operationoperator: 56
operands: 51
40Operationoperator: 52
operands: 53
41Operationoperator: 78
operands: 54
42Operationoperator: 56
operands: 55
43ExprTuple95
44Operationoperator: 56
operands: 57
45ExprTuple58, 59
46Literal
47ExprTuple60, 114
48ExprTuple118, 61
49NamedExprsstate: 62
50NamedExprselement: 63
targets: 71
51NamedExprselement: 64
targets: 65
52Literal
53NamedExprsbasis: 66
54NamedExprsoperation: 67
55NamedExprselement: 68
targets: 69
56Literal
57NamedExprselement: 70
targets: 71
58Literal
59Operationoperator: 108
operands: 72
60Operationoperator: 108
operands: 73
61Operationoperator: 101
operand: 90
62Operationoperator: 75
operand: 91
63Operationoperator: 77
operands: 84
64Operationoperator: 78
operands: 79
65Operationoperator: 85
operands: 80
66Literal
67Literal
68Operationoperator: 83
operands: 81
69Operationoperator: 85
operands: 82
70Operationoperator: 83
operands: 84
71Operationoperator: 85
operands: 86
72ExprTuple110, 87
73ExprTuple88, 89
74ExprTuple90
75Literal
76ExprTuple91
77Literal
78Literal
79NamedExprsoperation: 92
part: 95
80ExprTuple114, 97
81NamedExprsstate: 93
part: 95
82ExprTuple114, 119
83Literal
84NamedExprsstate: 94
part: 95
85Literal
86ExprTuple96, 97
87Operationoperator: 101
operand: 114
88Operationoperator: 99
operands: 100
89Operationoperator: 101
operand: 111
90Literal
91Literal
92Operationoperator: 103
operands: 104
93Operationoperator: 105
operands: 106
94Literal
95Variable
96Operationoperator: 108
operands: 107
97Operationoperator: 108
operands: 109
98ExprTuple114
99Literal
100ExprTuple113, 110
101Literal
102ExprTuple111
103Literal
104ExprTuple112, 119
105Literal
106ExprTuple113, 119
107ExprTuple119, 114
108Literal
109ExprTuple119, 115
110Operationoperator: 116
operands: 117
111Literal
112Literal
113Variable
114Literal
115Literal
116Literal
117ExprTuple118, 119
118Literal
119Literal