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 ExprRange, ExprTuple, U, Variable, VertExprArray, s, t
from proveit.numbers import Add, Interval, one
from proveit.physics.quantum.QPE import QPE1, QPE1_U_t_circuit
from proveit.physics.quantum.circuits import Gate, MultiQubitElem, Qcircuit
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(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)
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(\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}, \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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 4
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7
6ExprTuple8, 9
7ExprRangelambda_map: 10
start_index: 11
end_index: 12
8ExprRangelambda_map: 13
start_index: 79
end_index: 78
9ExprRangelambda_map: 13
start_index: 71
end_index: 56
10Lambdaparameter: 82
body: 14
11Operationoperator: 74
operands: 15
12Literal
13Lambdaparameter: 61
body: 16
14ExprTuple17, 18
15ExprTuple19, 79
16Operationoperator: 48
operands: 20
17ExprRangelambda_map: 21
start_index: 79
end_index: 78
18ExprRangelambda_map: 22
start_index: 79
end_index: 70
19Operationoperator: 80
operand: 78
20NamedExprselement: 24
targets: 25
21Lambdaparameter: 61
body: 26
22Lambdaparameter: 61
body: 28
23ExprTuple78
24Operationoperator: 51
operands: 29
25Operationoperator: 46
operands: 30
26Operationoperator: 31
operands: 32
27ExprTuple61
28Operationoperator: 48
operands: 33
29NamedExprsoperation: 34
part: 61
30ExprTuple79, 56
31Literal
32ExprTuple35, 36
33NamedExprselement: 37
targets: 38
34Operationoperator: 39
operands: 40
35Conditionalvalue: 41
condition: 42
36Conditionalvalue: 43
condition: 44
37Operationoperator: 51
operands: 45
38Operationoperator: 46
operands: 47
39Literal
40ExprTuple68, 78
41Operationoperator: 48
operands: 49
42Operationoperator: 50
operands: 54
43Operationoperator: 51
operands: 52
44Operationoperator: 53
operands: 54
45NamedExprsoperation: 55
part: 61
46Literal
47ExprTuple71, 56
48Literal
49NamedExprselement: 57
targets: 58
50Literal
51Literal
52NamedExprsoperation: 59
53Literal
54ExprTuple60, 61
55Operationoperator: 62
operands: 63
56Operationoperator: 74
operands: 64
57Literal
58Operationoperator: 65
operand: 71
59Literal
60Operationoperator: 74
operands: 67
61Variable
62Literal
63ExprTuple68, 69
64ExprTuple78, 70
65Literal
66ExprTuple71
67ExprTuple82, 78
68Variable
69Operationoperator: 72
operands: 73
70Variable
71Operationoperator: 74
operands: 75
72Literal
73ExprTuple76, 77
74Literal
75ExprTuple78, 79
76Literal
77Operationoperator: 80
operand: 82
78Variable
79Literal
80Literal
81ExprTuple82
82Variable