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, ExprRange, ExprTuple, Lambda, U, Variable, VertExprArray, s, t
from proveit.linear_algebra import Unitary
from proveit.logic import And, Forall, InSet
from proveit.numbers import Add, Exp, Interval, NaturalPos, 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 = ExprTuple(Lambda([s, t], Conditional(Forall(instance_param_or_params = [U], instance_expr = 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), domain = Unitary(Exp(two, s))), And(InSet(s, NaturalPos), InSet(t, NaturalPos)))))
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(\left(s, t\right) \mapsto \left\{\forall_{U \in \textrm{U}\left(2^{s}\right)}~\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)\right) \textrm{ if } s \in \mathbb{N}^+ ,  t \in \mathbb{N}^+\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
1Lambdaparameters: 2
body: 3
2ExprTuple98, 106
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12
10Lambdaparameter: 96
body: 14
11Operationoperator: 22
operands: 15
12Operationoperator: 22
operands: 16
13ExprTuple96
14Conditionalvalue: 17
condition: 18
15ExprTuple98, 19
16ExprTuple106, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple96, 26
24Operationoperator: 28
operand: 32
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operand: 34
27ExprTuple32
28Literal
29ExprTuple33
30Literal
31ExprTuple34
32ExprTuple35, 36
33ExprRangelambda_map: 37
start_index: 38
end_index: 39
34Operationoperator: 100
operands: 40
35ExprRangelambda_map: 41
start_index: 107
end_index: 106
36ExprRangelambda_map: 41
start_index: 99
end_index: 84
37Lambdaparameter: 110
body: 42
38Operationoperator: 102
operands: 43
39Literal
40ExprTuple104, 98
41Lambdaparameter: 89
body: 44
42ExprTuple45, 46
43ExprTuple47, 107
44Operationoperator: 76
operands: 48
45ExprRangelambda_map: 49
start_index: 107
end_index: 106
46ExprRangelambda_map: 50
start_index: 107
end_index: 98
47Operationoperator: 108
operand: 106
48NamedExprselement: 52
targets: 53
49Lambdaparameter: 89
body: 54
50Lambdaparameter: 89
body: 56
51ExprTuple106
52Operationoperator: 79
operands: 57
53Operationoperator: 74
operands: 58
54Operationoperator: 59
operands: 60
55ExprTuple89
56Operationoperator: 76
operands: 61
57NamedExprsoperation: 62
part: 89
58ExprTuple107, 84
59Literal
60ExprTuple63, 64
61NamedExprselement: 65
targets: 66
62Operationoperator: 67
operands: 68
63Conditionalvalue: 69
condition: 70
64Conditionalvalue: 71
condition: 72
65Operationoperator: 79
operands: 73
66Operationoperator: 74
operands: 75
67Literal
68ExprTuple96, 106
69Operationoperator: 76
operands: 77
70Operationoperator: 78
operands: 82
71Operationoperator: 79
operands: 80
72Operationoperator: 81
operands: 82
73NamedExprsoperation: 83
part: 89
74Literal
75ExprTuple99, 84
76Literal
77NamedExprselement: 85
targets: 86
78Literal
79Literal
80NamedExprsoperation: 87
81Literal
82ExprTuple88, 89
83Operationoperator: 90
operands: 91
84Operationoperator: 102
operands: 92
85Literal
86Operationoperator: 93
operand: 99
87Literal
88Operationoperator: 102
operands: 95
89Variable
90Literal
91ExprTuple96, 97
92ExprTuple106, 98
93Literal
94ExprTuple99
95ExprTuple110, 106
96Variable
97Operationoperator: 100
operands: 101
98Variable
99Operationoperator: 102
operands: 103
100Literal
101ExprTuple104, 105
102Literal
103ExprTuple106, 107
104Literal
105Operationoperator: 108
operand: 110
106Variable
107Literal
108Literal
109ExprTuple110
110Variable