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, ExprRange, Lambda, U, Variable, VertExprArray, s, t
from proveit.linear_algebra import Unitary
from proveit.logic import InSet
from proveit.numbers import Add, Exp, Interval, one, two
from proveit.physics.quantum.QPE import QPE1, QPE1_U_t_circuit
from proveit.physics.quantum.circuits import Gate, MultiQubitElem, Qcircuit, QcircuitEquiv
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Add(t, s)
sub_expr3 = MultiQubitElem(element = Gate(operation = QPE1(U, t), part = sub_expr1), targets = Interval(one, sub_expr2))
expr = Lambda(U, Conditional(QcircuitEquiv(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, sub_expr3, one, t), ExprRange(sub_expr1, sub_expr3, Add(t, one), sub_expr2)])), QPE1_U_t_circuit), InSet(U, Unitary(Exp(two, s)))))
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())
U \mapsto \left\{\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \multigate{1}{\textrm{QPE}_1\left(U, t\right)} & { /^{t} } \qw \\
& \ghost{\textrm{QPE}_1\left(U, t\right)} & { /^{s} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \control{} \qw \qwx[1] & \qw & \gate{\cdots} \qwx[1] & \qw & \qw \\
& \qw \qwx[1] & \control{} \qw \qwx[1] & \gate{\cdots} \qwx[1] & \qw & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} & \qw \\
& \qw \qwx[1] & \qw \qwx[1] & \gate{\cdots} \qwx[1] & \control{} \qw \qwx[1] & \qw \\
& \gate{U^{2^{t - 1}}} & \gate{U^{2^{t - 2}}} & \gate{\cdots} & \gate{U^{2^{0}}} & { /^{s} } \qw
} \end{array}\right) \textrm{ if } U \in \textrm{U}\left(2^{s}\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 81
body: 2
1ExprTuple81
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple81, 11
9Operationoperator: 13
operand: 17
10Operationoperator: 13
operands: 14
11Operationoperator: 15
operand: 19
12ExprTuple17
13Literal
14ExprTuple18
15Literal
16ExprTuple19
17ExprTuple20, 21
18ExprRangelambda_map: 22
start_index: 23
end_index: 24
19Operationoperator: 85
operands: 25
20ExprRangelambda_map: 26
start_index: 92
end_index: 91
21ExprRangelambda_map: 26
start_index: 84
end_index: 69
22Lambdaparameter: 95
body: 27
23Operationoperator: 87
operands: 28
24Literal
25ExprTuple89, 83
26Lambdaparameter: 74
body: 29
27ExprTuple30, 31
28ExprTuple32, 92
29Operationoperator: 61
operands: 33
30ExprRangelambda_map: 34
start_index: 92
end_index: 91
31ExprRangelambda_map: 35
start_index: 92
end_index: 83
32Operationoperator: 93
operand: 91
33NamedExprselement: 37
targets: 38
34Lambdaparameter: 74
body: 39
35Lambdaparameter: 74
body: 41
36ExprTuple91
37Operationoperator: 64
operands: 42
38Operationoperator: 59
operands: 43
39Operationoperator: 44
operands: 45
40ExprTuple74
41Operationoperator: 61
operands: 46
42NamedExprsoperation: 47
part: 74
43ExprTuple92, 69
44Literal
45ExprTuple48, 49
46NamedExprselement: 50
targets: 51
47Operationoperator: 52
operands: 53
48Conditionalvalue: 54
condition: 55
49Conditionalvalue: 56
condition: 57
50Operationoperator: 64
operands: 58
51Operationoperator: 59
operands: 60
52Literal
53ExprTuple81, 91
54Operationoperator: 61
operands: 62
55Operationoperator: 63
operands: 67
56Operationoperator: 64
operands: 65
57Operationoperator: 66
operands: 67
58NamedExprsoperation: 68
part: 74
59Literal
60ExprTuple84, 69
61Literal
62NamedExprselement: 70
targets: 71
63Literal
64Literal
65NamedExprsoperation: 72
66Literal
67ExprTuple73, 74
68Operationoperator: 75
operands: 76
69Operationoperator: 87
operands: 77
70Literal
71Operationoperator: 78
operand: 84
72Literal
73Operationoperator: 87
operands: 80
74Variable
75Literal
76ExprTuple81, 82
77ExprTuple91, 83
78Literal
79ExprTuple84
80ExprTuple95, 91
81Variable
82Operationoperator: 85
operands: 86
83Variable
84Operationoperator: 87
operands: 88
85Literal
86ExprTuple89, 90
87Literal
88ExprTuple91, 92
89Literal
90Operationoperator: 93
operand: 95
91Variable
92Literal
93Literal
94ExprTuple95
95Variable