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.physics.quantum.circuits import circuit__u_Akl_v, circuit__u_Akl_v__psi_m
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__u_Akl_v__psi_m)).with_wrapping_at(2)
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())
\begin{array}{c} \begin{array}{l} \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}
} \end{array}\right) =  \\ \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) \end{array} \end{array}
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.()(2)('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, 4
3Operationoperator: 6
operand: 8
4Operationoperator: 6
operand: 9
5ExprTuple8
6Literal
7ExprTuple9
8Operationoperator: 11
operands: 10
9Operationoperator: 11
operands: 12
10ExprTuple13, 14, 15
11Literal
12ExprTuple16, 17, 18
13ExprTuple20
14ExprRangelambda_map: 19
start_index: 78
end_index: 23
15ExprTuple24
16ExprTuple20, 21
17ExprRangelambda_map: 22
start_index: 78
end_index: 23
18ExprTuple24, 25
19Lambdaparameter: 68
body: 26
20ExprRangelambda_map: 27
start_index: 78
end_index: 79
21ExprRangelambda_map: 28
start_index: 78
end_index: 80
22Lambdaparameter: 68
body: 30
23Variable
24ExprRangelambda_map: 31
start_index: 78
end_index: 79
25ExprRangelambda_map: 32
start_index: 78
end_index: 80
26ExprTuple35
27Lambdaparameter: 72
body: 33
28Lambdaparameter: 72
body: 34
29ExprTuple68
30ExprTuple35, 36
31Lambdaparameter: 72
body: 37
32Lambdaparameter: 72
body: 38
33Operationoperator: 44
operands: 39
34Operationoperator: 44
operands: 40
35ExprRangelambda_map: 41
start_index: 78
end_index: 79
36ExprRangelambda_map: 42
start_index: 78
end_index: 80
37Operationoperator: 44
operands: 43
38Operationoperator: 44
operands: 45
39NamedExprselement: 46
targets: 52
40NamedExprselement: 47
targets: 54
41Lambdaparameter: 72
body: 48
42Lambdaparameter: 72
body: 50
43NamedExprselement: 51
targets: 52
44Literal
45NamedExprselement: 53
targets: 54
46Operationoperator: 56
operands: 55
47Operationoperator: 56
operands: 64
48IndexedVarvariable: 57
indices: 58
49ExprTuple72
50Operationoperator: 59
operands: 60
51Operationoperator: 63
operands: 61
52Operationoperator: 65
operands: 62
53Operationoperator: 63
operands: 64
54Operationoperator: 65
operands: 66
55NamedExprsstate: 67
part: 72
56Literal
57Variable
58ExprTuple68, 72
59Literal
60NamedExprsoperation: 69
61NamedExprsstate: 70
part: 72
62ExprTuple78, 79
63Literal
64NamedExprsstate: 71
part: 72
65Literal
66ExprTuple73, 74
67Variable
68Variable
69Literal
70Variable
71Variable
72Variable
73Operationoperator: 76
operands: 75
74Operationoperator: 76
operands: 77
75ExprTuple79, 78
76Literal
77ExprTuple79, 80
78Literal
79Variable
80Variable