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_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Equals(Prob(phase_kickback_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] & \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) = 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: 1
operands: 2
1Literal
2ExprTuple3, 85
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Operationoperator: 7
operands: 8
7Literal
8ExprTuple9, 10, 11
9ExprTuple12, 13
10ExprTuple14, 15
11ExprTuple16, 17
12Operationoperator: 49
operands: 18
13ExprRangelambda_map: 19
start_index: 85
end_index: 24
14Operationoperator: 40
operands: 20
15ExprRangelambda_map: 21
start_index: 85
end_index: 24
16Operationoperator: 55
operands: 22
17ExprRangelambda_map: 23
start_index: 85
end_index: 24
18NamedExprsstate: 25
19Lambdaparameter: 64
body: 26
20NamedExprselement: 27
targets: 28
21Lambdaparameter: 64
body: 29
22NamedExprsstate: 30
23Lambdaparameter: 64
body: 32
24Operationoperator: 70
operands: 33
25Operationoperator: 81
operand: 42
26Operationoperator: 40
operands: 35
27Literal
28Operationoperator: 36
operand: 88
29Operationoperator: 40
operands: 38
30Operationoperator: 68
operands: 39
31ExprTuple64
32Operationoperator: 40
operands: 41
33ExprTuple76, 85
34ExprTuple42
35NamedExprselement: 43
targets: 48
36Literal
37ExprTuple88
38NamedExprselement: 44
targets: 48
39ExprTuple45, 46
40Literal
41NamedExprselement: 47
targets: 48
42Literal
43Operationoperator: 49
operands: 56
44Operationoperator: 50
operands: 51
45Operationoperator: 77
operands: 52
46Operationoperator: 53
operands: 54
47Operationoperator: 55
operands: 56
48Operationoperator: 57
operands: 58
49Literal
50Literal
51NamedExprsoperation: 59
part: 64
52ExprTuple85, 60
53Literal
54ExprTuple61, 62
55Literal
56NamedExprsstate: 63
part: 64
57Literal
58ExprTuple88, 65
59Variable
60Operationoperator: 79
operands: 66
61Operationoperator: 81
operand: 73
62Operationoperator: 68
operands: 69
63Variable
64Variable
65Operationoperator: 70
operands: 71
66ExprTuple88, 72
67ExprTuple73
68Literal
69ExprTuple74, 75
70Literal
71ExprTuple76, 88
72Operationoperator: 77
operands: 78
73Literal
74Operationoperator: 79
operands: 80
75Operationoperator: 81
operand: 85
76Variable
77Literal
78ExprTuple85, 88
79Literal
80ExprTuple83, 84
81Literal
82ExprTuple85
83Literal
84Operationoperator: 86
operands: 87
85Literal
86Literal
87ExprTuple88, 89, 90, 91
88Literal
89Literal
90Literal
91Variable