logo

Expression of type ExprTuple

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 import ExprTuple, Lambda
from proveit.core_expr_types.expr_arrays import A11_to_Akl
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 = ExprTuple(Lambda([A11_to_Akl], 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())
\left(\left(A_{1, 1}, A_{1, 2}, \ldots, A_{1, l}, A_{2, 1}, A_{2, 2}, \ldots, A_{2, l}, \ldots\ldots, A_{k, 1}, A_{k, 2}, \ldots, A_{k, l}\right) \mapsto \left(\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}\right)\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple4
3Operationoperator: 5
operands: 6
4ExprRangelambda_map: 7
start_index: 93
end_index: 30
5Literal
6ExprTuple8, 9
7Lambdaparameter: 84
body: 47
8Operationoperator: 11
operand: 13
9Operationoperator: 11
operand: 14
10ExprTuple13
11Literal
12ExprTuple14
13Operationoperator: 16
operands: 15
14Operationoperator: 16
operands: 17
15ExprTuple18, 19, 20
16Literal
17ExprTuple21, 22, 23
18ExprTuple24
19ExprRangelambda_map: 25
start_index: 93
end_index: 30
20ExprTuple26
21ExprTuple27, 28
22ExprRangelambda_map: 29
start_index: 93
end_index: 30
23ExprTuple31, 32
24ExprRangelambda_map: 33
start_index: 93
end_index: 95
25Lambdaparameter: 84
body: 34
26ExprRangelambda_map: 35
start_index: 93
end_index: 95
27ExprRangelambda_map: 36
start_index: 93
end_index: 94
28ExprRangelambda_map: 37
start_index: 93
end_index: 95
29Lambdaparameter: 84
body: 39
30Variable
31ExprRangelambda_map: 40
start_index: 93
end_index: 94
32ExprRangelambda_map: 41
start_index: 93
end_index: 95
33Lambdaparameter: 87
body: 42
34ExprTuple47
35Lambdaparameter: 87
body: 43
36Lambdaparameter: 87
body: 44
37Lambdaparameter: 87
body: 45
38ExprTuple84
39ExprTuple46, 47
40Lambdaparameter: 87
body: 48
41Lambdaparameter: 87
body: 49
42Operationoperator: 57
operands: 50
43Operationoperator: 57
operands: 51
44Operationoperator: 57
operands: 52
45Operationoperator: 57
operands: 53
46ExprRangelambda_map: 54
start_index: 93
end_index: 94
47ExprRangelambda_map: 55
start_index: 93
end_index: 95
48Operationoperator: 57
operands: 56
49Operationoperator: 57
operands: 58
50NamedExprselement: 61
targets: 59
51NamedExprselement: 67
targets: 59
52NamedExprselement: 60
targets: 66
53NamedExprselement: 61
targets: 68
54Lambdaparameter: 87
body: 62
55Lambdaparameter: 87
body: 64
56NamedExprselement: 65
targets: 66
57Literal
58NamedExprselement: 67
targets: 68
59Operationoperator: 80
operands: 69
60Operationoperator: 70
operands: 76
61Operationoperator: 70
operands: 71
62Operationoperator: 72
operands: 73
63ExprTuple87
64IndexedVarvariable: 74
indices: 75
65Operationoperator: 78
operands: 76
66Operationoperator: 80
operands: 77
67Operationoperator: 78
operands: 79
68Operationoperator: 80
operands: 81
69ExprTuple93, 95
70Literal
71NamedExprsstate: 82
part: 87
72Literal
73NamedExprsoperation: 83
74Variable
75ExprTuple84, 87
76NamedExprsstate: 85
part: 87
77ExprTuple93, 94
78Literal
79NamedExprsstate: 86
part: 87
80Literal
81ExprTuple88, 89
82Variable
83Literal
84Variable
85Variable
86Variable
87Variable
88Operationoperator: 91
operands: 90
89Operationoperator: 91
operands: 92
90ExprTuple94, 93
91Literal
92ExprTuple94, 95
93Literal
94Variable
95Variable