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 phase_kickback_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Prob(phase_kickback_circuit)
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{
\qin{\lvert + \rangle} & \control{} \qw \qwx[1] & \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)} \\
\qin{\lvert u \rangle} & \gate{U} & \qout{\lvert u \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
7ExprTuple11, 12
8ExprTuple13, 14
9Operationoperator: 46
operands: 15
10ExprRangelambda_map: 16
start_index: 82
end_index: 21
11Operationoperator: 37
operands: 17
12ExprRangelambda_map: 18
start_index: 82
end_index: 21
13Operationoperator: 52
operands: 19
14ExprRangelambda_map: 20
start_index: 82
end_index: 21
15NamedExprsstate: 22
16Lambdaparameter: 61
body: 23
17NamedExprselement: 24
targets: 25
18Lambdaparameter: 61
body: 26
19NamedExprsstate: 27
20Lambdaparameter: 61
body: 29
21Operationoperator: 67
operands: 30
22Operationoperator: 78
operand: 39
23Operationoperator: 37
operands: 32
24Literal
25Operationoperator: 33
operand: 85
26Operationoperator: 37
operands: 35
27Operationoperator: 65
operands: 36
28ExprTuple61
29Operationoperator: 37
operands: 38
30ExprTuple73, 82
31ExprTuple39
32NamedExprselement: 40
targets: 45
33Literal
34ExprTuple85
35NamedExprselement: 41
targets: 45
36ExprTuple42, 43
37Literal
38NamedExprselement: 44
targets: 45
39Literal
40Operationoperator: 46
operands: 53
41Operationoperator: 47
operands: 48
42Operationoperator: 74
operands: 49
43Operationoperator: 50
operands: 51
44Operationoperator: 52
operands: 53
45Operationoperator: 54
operands: 55
46Literal
47Literal
48NamedExprsoperation: 56
part: 61
49ExprTuple82, 57
50Literal
51ExprTuple58, 59
52Literal
53NamedExprsstate: 60
part: 61
54Literal
55ExprTuple85, 62
56Variable
57Operationoperator: 76
operands: 63
58Operationoperator: 78
operand: 70
59Operationoperator: 65
operands: 66
60Variable
61Variable
62Operationoperator: 67
operands: 68
63ExprTuple85, 69
64ExprTuple70
65Literal
66ExprTuple71, 72
67Literal
68ExprTuple73, 85
69Operationoperator: 74
operands: 75
70Literal
71Operationoperator: 76
operands: 77
72Operationoperator: 78
operand: 82
73Variable
74Literal
75ExprTuple82, 85
76Literal
77ExprTuple80, 81
78Literal
79ExprTuple82
80Literal
81Operationoperator: 83
operands: 84
82Literal
83Literal
84ExprTuple85, 86, 87, 88
85Literal
86Literal
87Literal
88Variable