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 circuit__u_Akl_v
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Prob(circuit__u_Akl_v)
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 u \rangle} & \gate{A_{1, 1}} \qwx[1] & \gate{A_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 1}} \qwx[1] & \multiqout{3}{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, 2}} \qwx[1] & \gate{A_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 2}} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, l}} & \gate{A_{2, l}} & \gate{\cdots} & \gate{A_{k, l}} & \ghostqout{\lvert v \rangle}
} \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
7ExprRangelambda_map: 10
start_index: 41
end_index: 11
8ExprTuple12
9ExprRangelambda_map: 13
start_index: 41
end_index: 42
10Lambdaparameter: 38
body: 15
11Variable
12ExprRangelambda_map: 16
start_index: 41
end_index: 42
13Lambdaparameter: 40
body: 17
14ExprTuple38
15ExprTuple18
16Lambdaparameter: 40
body: 19
17Operationoperator: 22
operands: 20
18ExprRangelambda_map: 21
start_index: 41
end_index: 42
19Operationoperator: 22
operands: 23
20NamedExprselement: 24
targets: 28
21Lambdaparameter: 40
body: 26
22Literal
23NamedExprselement: 27
targets: 28
24Operationoperator: 29
operands: 30
25ExprTuple40
26IndexedVarvariable: 31
indices: 32
27Operationoperator: 33
operands: 34
28Operationoperator: 35
operands: 36
29Literal
30NamedExprsstate: 37
part: 40
31Variable
32ExprTuple38, 40
33Literal
34NamedExprsstate: 39
part: 40
35Literal
36ExprTuple41, 42
37Variable
38Variable
39Variable
40Variable
41Literal
42Variable