logo

Expression of type QcircuitEquiv

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, Variable, VertExprArray, t
from proveit.linear_algebra import TensorProd
from proveit.numbers import Add, Interval, one
from proveit.physics.quantum.QPE import _ket_u, _psi_t_ket, _s
from proveit.physics.quantum.circuits import MultiQubitElem, Output, Qcircuit, QcircuitEquiv
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Add(t, one)
sub_expr3 = Add(t, _s)
sub_expr4 = MultiQubitElem(element = Output(state = TensorProd(_psi_t_ket, _ket_u), part = sub_expr1), targets = Interval(one, sub_expr3))
expr = QcircuitEquiv(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _psi_t_ket, part = sub_expr1), targets = Interval(one, t)), one, t).with_wrapping_at(2,6), ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _ket_u, part = sub_expr1), targets = Interval(sub_expr2, sub_expr3)), one, _s).with_wrapping_at(2,6)])), Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, sub_expr4, one, t).with_wrapping_at(2,6), ExprRange(sub_expr1, sub_expr4, sub_expr2, sub_expr3).with_wrapping_at(2,6)])))
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{
& \qout{\lvert \psi_{t} \rangle} \\
& \qout{\lvert u \rangle}
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \multiqout{1}{\lvert \psi_{t} \rangle {\otimes} \lvert u \rangle} \\
& \ghostqout{\lvert \psi_{t} \rangle {\otimes} \lvert u \rangle}
} \end{array}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 6
operand: 8
4Operationoperator: 6
operand: 9
5ExprTuple8
6Literal
7ExprTuple9
8ExprTuple10, 11
9ExprTuple12, 13
10ExprRangelambda_map: 14
start_index: 48
end_index: 54
11ExprRangelambda_map: 15
start_index: 48
end_index: 51
12ExprRangelambda_map: 16
start_index: 48
end_index: 54
13ExprRangelambda_map: 16
start_index: 39
end_index: 42
14Lambdaparameter: 41
body: 17
15Lambdaparameter: 41
body: 18
16Lambdaparameter: 41
body: 20
17Operationoperator: 23
operands: 21
18Operationoperator: 23
operands: 22
19ExprTuple41
20Operationoperator: 23
operands: 24
21NamedExprselement: 25
targets: 26
22NamedExprselement: 27
targets: 28
23Literal
24NamedExprselement: 29
targets: 30
25Operationoperator: 35
operands: 31
26Operationoperator: 37
operands: 32
27Operationoperator: 35
operands: 33
28Operationoperator: 37
operands: 34
29Operationoperator: 35
operands: 36
30Operationoperator: 37
operands: 38
31NamedExprsstate: 49
part: 41
32ExprTuple48, 54
33NamedExprsstate: 50
part: 41
34ExprTuple39, 42
35Literal
36NamedExprsstate: 40
part: 41
37Literal
38ExprTuple48, 42
39Operationoperator: 46
operands: 43
40Operationoperator: 44
operands: 45
41Variable
42Operationoperator: 46
operands: 47
43ExprTuple54, 48
44Literal
45ExprTuple49, 50
46Literal
47ExprTuple54, 51
48Literal
49Operationoperator: 52
operand: 54
50Literal
51Literal
52Literal
53ExprTuple54
54Variable