logo

Expression of type Output

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.linear_algebra import ScalarMult, VecAdd
from proveit.numbers import Exp, Mult, e, frac, i, one, pi, sqrt, two
from proveit.physics.quantum import ket0, ket1, varphi
from proveit.physics.quantum.circuits import Output
In [2]:
# build up the expression from sub-expressions
expr = Output(state = ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, varphi)), ket1))))
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())
\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} \cdot \lvert 1 \rangle\right)\right)} 
} \end{array}
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2NamedExprsstate: 3
3Operationoperator: 15
operands: 4
4ExprTuple5, 6
5Operationoperator: 21
operands: 7
6Operationoperator: 8
operands: 9
7ExprTuple29, 10
8Literal
9ExprTuple11, 12
10Operationoperator: 23
operands: 13
11Operationoperator: 25
operand: 18
12Operationoperator: 15
operands: 16
13ExprTuple32, 17
14ExprTuple18
15Literal
16ExprTuple19, 20
17Operationoperator: 21
operands: 22
18Literal
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operand: 29
21Literal
22ExprTuple29, 32
23Literal
24ExprTuple27, 28
25Literal
26ExprTuple29
27Literal
28Operationoperator: 30
operands: 31
29Literal
30Literal
31ExprTuple32, 33, 34, 35
32Literal
33Literal
34Literal
35Variable