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_on_register_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Prob(phase_kickback_on_register_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] & \qw & \gate{\cdots} \qwx[1] & \qw & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{1}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert + \rangle} & \qw \qwx[1] & \control{} \qw \qwx[1] & \gate{\cdots} \qwx[1] & \qw & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{2}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} & \qout{\vdots} \\
\qin{\lvert + \rangle} & \qw \qwx[1] & \qw \qwx[1] & \gate{\cdots} \qwx[1] & \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_{t}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert u \rangle} & \gate{U_{1}} & \gate{U_{2}} & \gate{\cdots} & \gate{U_{t}} & \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
7ExprRangelambda_map: 11
start_index: 105
end_index: 104
8ExprTuple12, 13
9ExprRangelambda_map: 14
start_index: 105
end_index: 104
10ExprRangelambda_map: 15
start_index: 105
end_index: 88
11Lambdaparameter: 87
body: 16
12ExprRangelambda_map: 17
start_index: 105
end_index: 104
13ExprRangelambda_map: 18
start_index: 105
end_index: 88
14Lambdaparameter: 114
body: 19
15Lambdaparameter: 114
body: 20
16ExprTuple21, 22
17Lambdaparameter: 114
body: 23
18Lambdaparameter: 114
body: 24
19Operationoperator: 38
operands: 25
20Operationoperator: 63
operands: 26
21ExprRangelambda_map: 27
start_index: 105
end_index: 104
22ExprRangelambda_map: 28
start_index: 105
end_index: 88
23Operationoperator: 43
operands: 29
24Operationoperator: 63
operands: 30
25NamedExprsstate: 31
26NamedExprselement: 32
targets: 49
27Lambdaparameter: 114
body: 33
28Lambdaparameter: 114
body: 34
29NamedExprsstate: 35
30NamedExprselement: 36
targets: 49
31Operationoperator: 98
operand: 45
32Operationoperator: 38
operands: 44
33Operationoperator: 39
operands: 40
34Operationoperator: 63
operands: 41
35Operationoperator: 83
operands: 42
36Operationoperator: 43
operands: 44
37ExprTuple45
38Literal
39Literal
40ExprTuple46, 47
41NamedExprselement: 48
targets: 49
42ExprTuple50, 51
43Literal
44NamedExprsstate: 52
part: 114
45Literal
46Conditionalvalue: 53
condition: 54
47Conditionalvalue: 55
condition: 56
48Operationoperator: 66
operands: 57
49Operationoperator: 58
operands: 59
50Operationoperator: 94
operands: 60
51Operationoperator: 61
operands: 62
52Variable
53Operationoperator: 63
operands: 64
54Operationoperator: 65
operands: 69
55Operationoperator: 66
operands: 67
56Operationoperator: 68
operands: 69
57NamedExprsoperation: 70
part: 114
58Literal
59ExprTuple93, 71
60ExprTuple105, 72
61Literal
62ExprTuple73, 74
63Literal
64NamedExprselement: 75
targets: 76
65Literal
66Literal
67NamedExprsoperation: 77
68Literal
69ExprTuple87, 114
70IndexedVarvariable: 78
index: 87
71Operationoperator: 100
operands: 80
72Operationoperator: 96
operands: 81
73Operationoperator: 98
operand: 90
74Operationoperator: 83
operands: 84
75Literal
76Operationoperator: 85
operand: 93
77Literal
78Variable
79ExprTuple87
80ExprTuple104, 88
81ExprTuple108, 89
82ExprTuple90
83Literal
84ExprTuple91, 92
85Literal
86ExprTuple93
87Variable
88Variable
89Operationoperator: 94
operands: 95
90Literal
91Operationoperator: 96
operands: 97
92Operationoperator: 98
operand: 105
93Operationoperator: 100
operands: 101
94Literal
95ExprTuple105, 108
96Literal
97ExprTuple102, 103
98Literal
99ExprTuple105
100Literal
101ExprTuple104, 105
102Literal
103Operationoperator: 106
operands: 107
104Variable
105Literal
106Literal
107ExprTuple108, 109, 110, 111
108Literal
109Literal
110Literal
111IndexedVarvariable: 112
index: 114
112Variable
113ExprTuple114
114Variable