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__psi_m
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Prob(circuit__u_Akl_v__psi_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())
\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} \\
\qin{\lvert \psi \rangle} & { /^{m} } \qw & { /^{m} } \qw & \gate{\cdots} & { /^{m} } \qw & \qout{\lvert \psi \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, 10
7ExprRangelambda_map: 11
start_index: 66
end_index: 12
8ExprTuple13, 14
9ExprRangelambda_map: 15
start_index: 66
end_index: 67
10ExprRangelambda_map: 16
start_index: 66
end_index: 68
11Lambdaparameter: 56
body: 18
12Variable
13ExprRangelambda_map: 19
start_index: 66
end_index: 67
14ExprRangelambda_map: 20
start_index: 66
end_index: 68
15Lambdaparameter: 60
body: 21
16Lambdaparameter: 60
body: 22
17ExprTuple56
18ExprTuple23, 24
19Lambdaparameter: 60
body: 25
20Lambdaparameter: 60
body: 26
21Operationoperator: 32
operands: 27
22Operationoperator: 32
operands: 28
23ExprRangelambda_map: 29
start_index: 66
end_index: 67
24ExprRangelambda_map: 30
start_index: 66
end_index: 68
25Operationoperator: 32
operands: 31
26Operationoperator: 32
operands: 33
27NamedExprselement: 34
targets: 40
28NamedExprselement: 35
targets: 42
29Lambdaparameter: 60
body: 36
30Lambdaparameter: 60
body: 38
31NamedExprselement: 39
targets: 40
32Literal
33NamedExprselement: 41
targets: 42
34Operationoperator: 44
operands: 43
35Operationoperator: 44
operands: 52
36IndexedVarvariable: 45
indices: 46
37ExprTuple60
38Operationoperator: 47
operands: 48
39Operationoperator: 51
operands: 49
40Operationoperator: 53
operands: 50
41Operationoperator: 51
operands: 52
42Operationoperator: 53
operands: 54
43NamedExprsstate: 55
part: 60
44Literal
45Variable
46ExprTuple56, 60
47Literal
48NamedExprsoperation: 57
49NamedExprsstate: 58
part: 60
50ExprTuple66, 67
51Literal
52NamedExprsstate: 59
part: 60
53Literal
54ExprTuple61, 62
55Variable
56Variable
57Literal
58Variable
59Variable
60Variable
61Operationoperator: 64
operands: 63
62Operationoperator: 64
operands: 65
63ExprTuple67, 66
64Literal
65ExprTuple67, 68
66Literal
67Variable
68Variable