logo

Expression of type Prob

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.physics.quantum.circuits import register_meas
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Prob(register_meas)
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())
\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\multiqin{3}{\lvert \psi \rangle} & \meter & \multiqout{3}{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \measure{\begin{array}{c}:\\ \left(m - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}}
} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7, 8
6ExprTuple9
7ExprTuple10
8ExprTuple11
9ExprRangelambda_map: 12
start_index: 37
end_index: 41
10ExprRangelambda_map: 13
start_index: 37
end_index: 41
11ExprRangelambda_map: 14
start_index: 37
end_index: 41
12Lambdaparameter: 36
body: 15
13Lambdaparameter: 36
body: 16
14Lambdaparameter: 36
body: 18
15Operationoperator: 22
operands: 19
16Operationoperator: 20
operands: 21
17ExprTuple36
18Operationoperator: 22
operands: 23
19NamedExprselement: 24
targets: 27
20Literal
21NamedExprsbasis: 25
22Literal
23NamedExprselement: 26
targets: 27
24Operationoperator: 28
operands: 29
25Literal
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28Literal
29NamedExprsstate: 34
part: 36
30Literal
31NamedExprsstate: 35
part: 36
32Literal
33ExprTuple37, 41
34Variable
35Operationoperator: 38
operands: 39
36Variable
37Literal
38Literal
39ExprTuple40, 41
40Variable
41Variable