logo

Expression of type Equals

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.logic import Equals
from proveit.numbers import one
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 = Equals(Prob(phase_kickback_on_register_circuit), one)
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) = 1
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 67
operands: 1
1ExprTuple2, 107
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9, 10
8ExprTuple11, 12
9ExprRangelambda_map: 13
start_index: 107
end_index: 106
10ExprTuple14, 15
11ExprRangelambda_map: 16
start_index: 107
end_index: 106
12ExprRangelambda_map: 17
start_index: 107
end_index: 90
13Lambdaparameter: 89
body: 18
14ExprRangelambda_map: 19
start_index: 107
end_index: 106
15ExprRangelambda_map: 20
start_index: 107
end_index: 90
16Lambdaparameter: 116
body: 21
17Lambdaparameter: 116
body: 22
18ExprTuple23, 24
19Lambdaparameter: 116
body: 25
20Lambdaparameter: 116
body: 26
21Operationoperator: 40
operands: 27
22Operationoperator: 65
operands: 28
23ExprRangelambda_map: 29
start_index: 107
end_index: 106
24ExprRangelambda_map: 30
start_index: 107
end_index: 90
25Operationoperator: 45
operands: 31
26Operationoperator: 65
operands: 32
27NamedExprsstate: 33
28NamedExprselement: 34
targets: 51
29Lambdaparameter: 116
body: 35
30Lambdaparameter: 116
body: 36
31NamedExprsstate: 37
32NamedExprselement: 38
targets: 51
33Operationoperator: 100
operand: 47
34Operationoperator: 40
operands: 46
35Operationoperator: 41
operands: 42
36Operationoperator: 65
operands: 43
37Operationoperator: 85
operands: 44
38Operationoperator: 45
operands: 46
39ExprTuple47
40Literal
41Literal
42ExprTuple48, 49
43NamedExprselement: 50
targets: 51
44ExprTuple52, 53
45Literal
46NamedExprsstate: 54
part: 116
47Literal
48Conditionalvalue: 55
condition: 56
49Conditionalvalue: 57
condition: 58
50Operationoperator: 68
operands: 59
51Operationoperator: 60
operands: 61
52Operationoperator: 96
operands: 62
53Operationoperator: 63
operands: 64
54Variable
55Operationoperator: 65
operands: 66
56Operationoperator: 67
operands: 71
57Operationoperator: 68
operands: 69
58Operationoperator: 70
operands: 71
59NamedExprsoperation: 72
part: 116
60Literal
61ExprTuple95, 73
62ExprTuple107, 74
63Literal
64ExprTuple75, 76
65Literal
66NamedExprselement: 77
targets: 78
67Literal
68Literal
69NamedExprsoperation: 79
70Literal
71ExprTuple89, 116
72IndexedVarvariable: 80
index: 89
73Operationoperator: 102
operands: 82
74Operationoperator: 98
operands: 83
75Operationoperator: 100
operand: 92
76Operationoperator: 85
operands: 86
77Literal
78Operationoperator: 87
operand: 95
79Literal
80Variable
81ExprTuple89
82ExprTuple106, 90
83ExprTuple110, 91
84ExprTuple92
85Literal
86ExprTuple93, 94
87Literal
88ExprTuple95
89Variable
90Variable
91Operationoperator: 96
operands: 97
92Literal
93Operationoperator: 98
operands: 99
94Operationoperator: 100
operand: 107
95Operationoperator: 102
operands: 103
96Literal
97ExprTuple107, 110
98Literal
99ExprTuple104, 105
100Literal
101ExprTuple107
102Literal
103ExprTuple106, 107
104Literal
105Operationoperator: 108
operands: 109
106Variable
107Literal
108Literal
109ExprTuple110, 111, 112, 113
110Literal
111Literal
112Literal
113IndexedVarvariable: 114
index: 116
114Variable
115ExprTuple116
116Variable