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__psi_m__u_Akl_v, circuit__u_Akl_v
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__psi_m__u_Akl_v)).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{
\qin{\lvert \psi \rangle} & { /^{m} } \qw & { /^{m} } \qw & \gate{\cdots} & { /^{m} } \qw & \qout{\lvert \psi \rangle} \\
\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) \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
13ExprTuple19
14ExprRangelambda_map: 20
start_index: 88
end_index: 25
15ExprTuple21
16ExprTuple22, 23
17ExprRangelambda_map: 24
start_index: 88
end_index: 25
18ExprTuple26, 27
19ExprRangelambda_map: 28
start_index: 88
end_index: 90
20Lambdaparameter: 79
body: 29
21ExprRangelambda_map: 30
start_index: 88
end_index: 90
22ExprRangelambda_map: 31
start_index: 88
end_index: 89
23ExprRangelambda_map: 32
start_index: 88
end_index: 90
24Lambdaparameter: 79
body: 34
25Variable
26ExprRangelambda_map: 35
start_index: 88
end_index: 89
27ExprRangelambda_map: 36
start_index: 88
end_index: 90
28Lambdaparameter: 82
body: 37
29ExprTuple42
30Lambdaparameter: 82
body: 38
31Lambdaparameter: 82
body: 39
32Lambdaparameter: 82
body: 40
33ExprTuple79
34ExprTuple41, 42
35Lambdaparameter: 82
body: 43
36Lambdaparameter: 82
body: 44
37Operationoperator: 52
operands: 45
38Operationoperator: 52
operands: 46
39Operationoperator: 52
operands: 47
40Operationoperator: 52
operands: 48
41ExprRangelambda_map: 49
start_index: 88
end_index: 89
42ExprRangelambda_map: 50
start_index: 88
end_index: 90
43Operationoperator: 52
operands: 51
44Operationoperator: 52
operands: 53
45NamedExprselement: 56
targets: 54
46NamedExprselement: 62
targets: 54
47NamedExprselement: 55
targets: 61
48NamedExprselement: 56
targets: 63
49Lambdaparameter: 82
body: 57
50Lambdaparameter: 82
body: 59
51NamedExprselement: 60
targets: 61
52Literal
53NamedExprselement: 62
targets: 63
54Operationoperator: 75
operands: 64
55Operationoperator: 65
operands: 71
56Operationoperator: 65
operands: 66
57Operationoperator: 67
operands: 68
58ExprTuple82
59IndexedVarvariable: 69
indices: 70
60Operationoperator: 73
operands: 71
61Operationoperator: 75
operands: 72
62Operationoperator: 73
operands: 74
63Operationoperator: 75
operands: 76
64ExprTuple88, 90
65Literal
66NamedExprsstate: 77
part: 82
67Literal
68NamedExprsoperation: 78
69Variable
70ExprTuple79, 82
71NamedExprsstate: 80
part: 82
72ExprTuple88, 89
73Literal
74NamedExprsstate: 81
part: 82
75Literal
76ExprTuple83, 84
77Variable
78Literal
79Variable
80Variable
81Variable
82Variable
83Operationoperator: 86
operands: 85
84Operationoperator: 86
operands: 87
85ExprTuple89, 88
86Literal
87ExprTuple89, 90
88Literal
89Variable
90Variable