logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.circuits

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, IndexedVar, Variable, m, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.numbers import Add, Exp, Interval, Mult, e, frac, i, one, pi, sqrt, two
from proveit.physics.quantum import ket0, ket1, var_ket_u, varphi
from proveit.physics.quantum.circuits import MultiQubitElem, Output
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(ExprRange(sub_expr1, Output(state = ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, IndexedVar(varphi, sub_expr1))), ket1)))), one, t), ExprRange(sub_expr1, MultiQubitElem(element = Output(state = var_ket_u, part = sub_expr1), targets = Interval(Add(t, one), Add(t, m))), one, m))
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{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{1}} \cdot \lvert 1 \rangle\right)\right)} 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{2}} \cdot \lvert 1 \rangle\right)\right)} 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{t}} \cdot \lvert 1 \rangle\right)\right)} 
} \end{array},\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~1~\mbox{on}~\{t + 1~\ldotp \ldotp~t + m\}} 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~2~\mbox{on}~\{t + 1~\ldotp \ldotp~t + m\}} 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~m~\mbox{on}~\{t + 1~\ldotp \ldotp~t + m\}} 
} \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
1ExprRangelambda_map: 3
start_index: 50
end_index: 32
2ExprRangelambda_map: 4
start_index: 50
end_index: 33
3Lambdaparameter: 59
body: 5
4Lambdaparameter: 59
body: 6
5Operationoperator: 14
operands: 7
6Operationoperator: 8
operands: 9
7NamedExprsstate: 10
8Literal
9NamedExprselement: 11
targets: 12
10Operationoperator: 36
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple18, 19
14Literal
15NamedExprsstate: 20
part: 59
16Literal
17ExprTuple21, 22
18Operationoperator: 42
operands: 23
19Operationoperator: 24
operands: 25
20Variable
21Operationoperator: 27
operands: 26
22Operationoperator: 27
operands: 28
23ExprTuple50, 29
24Literal
25ExprTuple30, 31
26ExprTuple32, 50
27Literal
28ExprTuple32, 33
29Operationoperator: 44
operands: 34
30Operationoperator: 46
operand: 39
31Operationoperator: 36
operands: 37
32Variable
33Variable
34ExprTuple53, 38
35ExprTuple39
36Literal
37ExprTuple40, 41
38Operationoperator: 42
operands: 43
39Literal
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operand: 50
42Literal
43ExprTuple50, 53
44Literal
45ExprTuple48, 49
46Literal
47ExprTuple50
48Literal
49Operationoperator: 51
operands: 52
50Literal
51Literal
52ExprTuple53, 54, 55, 56
53Literal
54Literal
55Literal
56IndexedVarvariable: 57
index: 59
57Variable
58ExprTuple59
59Variable