logo

Expression of type Lambda

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 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 = 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(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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple3
2Operationoperator: 4
operands: 5
3ExprRangelambda_map: 6
start_index: 82
end_index: 27
4Literal
5ExprTuple7, 8
6Lambdaparameter: 72
body: 39
7Operationoperator: 10
operand: 12
8Operationoperator: 10
operand: 13
9ExprTuple12
10Literal
11ExprTuple13
12Operationoperator: 15
operands: 14
13Operationoperator: 15
operands: 16
14ExprTuple17, 18, 19
15Literal
16ExprTuple20, 21, 22
17ExprTuple24
18ExprRangelambda_map: 23
start_index: 82
end_index: 27
19ExprTuple28
20ExprTuple24, 25
21ExprRangelambda_map: 26
start_index: 82
end_index: 27
22ExprTuple28, 29
23Lambdaparameter: 72
body: 30
24ExprRangelambda_map: 31
start_index: 82
end_index: 83
25ExprRangelambda_map: 32
start_index: 82
end_index: 84
26Lambdaparameter: 72
body: 34
27Variable
28ExprRangelambda_map: 35
start_index: 82
end_index: 83
29ExprRangelambda_map: 36
start_index: 82
end_index: 84
30ExprTuple39
31Lambdaparameter: 76
body: 37
32Lambdaparameter: 76
body: 38
33ExprTuple72
34ExprTuple39, 40
35Lambdaparameter: 76
body: 41
36Lambdaparameter: 76
body: 42
37Operationoperator: 48
operands: 43
38Operationoperator: 48
operands: 44
39ExprRangelambda_map: 45
start_index: 82
end_index: 83
40ExprRangelambda_map: 46
start_index: 82
end_index: 84
41Operationoperator: 48
operands: 47
42Operationoperator: 48
operands: 49
43NamedExprselement: 50
targets: 56
44NamedExprselement: 51
targets: 58
45Lambdaparameter: 76
body: 52
46Lambdaparameter: 76
body: 54
47NamedExprselement: 55
targets: 56
48Literal
49NamedExprselement: 57
targets: 58
50Operationoperator: 60
operands: 59
51Operationoperator: 60
operands: 68
52IndexedVarvariable: 61
indices: 62
53ExprTuple76
54Operationoperator: 63
operands: 64
55Operationoperator: 67
operands: 65
56Operationoperator: 69
operands: 66
57Operationoperator: 67
operands: 68
58Operationoperator: 69
operands: 70
59NamedExprsstate: 71
part: 76
60Literal
61Variable
62ExprTuple72, 76
63Literal
64NamedExprsoperation: 73
65NamedExprsstate: 74
part: 76
66ExprTuple82, 83
67Literal
68NamedExprsstate: 75
part: 76
69Literal
70ExprTuple77, 78
71Variable
72Variable
73Literal
74Variable
75Variable
76Variable
77Operationoperator: 80
operands: 79
78Operationoperator: 80
operands: 81
79ExprTuple83, 82
80Literal
81ExprTuple83, 84
82Literal
83Variable
84Variable