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__u_Akl_v, circuit__u_Akl_v__psi_m
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__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())
\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{
\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}\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: 83
end_index: 28
5Literal
6ExprTuple8, 9
7Lambdaparameter: 73
body: 40
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
18ExprTuple25
19ExprRangelambda_map: 24
start_index: 83
end_index: 28
20ExprTuple29
21ExprTuple25, 26
22ExprRangelambda_map: 27
start_index: 83
end_index: 28
23ExprTuple29, 30
24Lambdaparameter: 73
body: 31
25ExprRangelambda_map: 32
start_index: 83
end_index: 84
26ExprRangelambda_map: 33
start_index: 83
end_index: 85
27Lambdaparameter: 73
body: 35
28Variable
29ExprRangelambda_map: 36
start_index: 83
end_index: 84
30ExprRangelambda_map: 37
start_index: 83
end_index: 85
31ExprTuple40
32Lambdaparameter: 77
body: 38
33Lambdaparameter: 77
body: 39
34ExprTuple73
35ExprTuple40, 41
36Lambdaparameter: 77
body: 42
37Lambdaparameter: 77
body: 43
38Operationoperator: 49
operands: 44
39Operationoperator: 49
operands: 45
40ExprRangelambda_map: 46
start_index: 83
end_index: 84
41ExprRangelambda_map: 47
start_index: 83
end_index: 85
42Operationoperator: 49
operands: 48
43Operationoperator: 49
operands: 50
44NamedExprselement: 51
targets: 57
45NamedExprselement: 52
targets: 59
46Lambdaparameter: 77
body: 53
47Lambdaparameter: 77
body: 55
48NamedExprselement: 56
targets: 57
49Literal
50NamedExprselement: 58
targets: 59
51Operationoperator: 61
operands: 60
52Operationoperator: 61
operands: 69
53IndexedVarvariable: 62
indices: 63
54ExprTuple77
55Operationoperator: 64
operands: 65
56Operationoperator: 68
operands: 66
57Operationoperator: 70
operands: 67
58Operationoperator: 68
operands: 69
59Operationoperator: 70
operands: 71
60NamedExprsstate: 72
part: 77
61Literal
62Variable
63ExprTuple73, 77
64Literal
65NamedExprsoperation: 74
66NamedExprsstate: 75
part: 77
67ExprTuple83, 84
68Literal
69NamedExprsstate: 76
part: 77
70Literal
71ExprTuple78, 79
72Variable
73Variable
74Literal
75Variable
76Variable
77Variable
78Operationoperator: 81
operands: 80
79Operationoperator: 81
operands: 82
80ExprTuple84, 83
81Literal
82ExprTuple84, 85
83Literal
84Variable
85Variable