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__psi_m__u_Akl_v, circuit__u_Akl_v
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__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(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)
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: 92
end_index: 29
4Literal
5ExprTuple7, 8
6Lambdaparameter: 83
body: 46
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
17ExprTuple23
18ExprRangelambda_map: 24
start_index: 92
end_index: 29
19ExprTuple25
20ExprTuple26, 27
21ExprRangelambda_map: 28
start_index: 92
end_index: 29
22ExprTuple30, 31
23ExprRangelambda_map: 32
start_index: 92
end_index: 94
24Lambdaparameter: 83
body: 33
25ExprRangelambda_map: 34
start_index: 92
end_index: 94
26ExprRangelambda_map: 35
start_index: 92
end_index: 93
27ExprRangelambda_map: 36
start_index: 92
end_index: 94
28Lambdaparameter: 83
body: 38
29Variable
30ExprRangelambda_map: 39
start_index: 92
end_index: 93
31ExprRangelambda_map: 40
start_index: 92
end_index: 94
32Lambdaparameter: 86
body: 41
33ExprTuple46
34Lambdaparameter: 86
body: 42
35Lambdaparameter: 86
body: 43
36Lambdaparameter: 86
body: 44
37ExprTuple83
38ExprTuple45, 46
39Lambdaparameter: 86
body: 47
40Lambdaparameter: 86
body: 48
41Operationoperator: 56
operands: 49
42Operationoperator: 56
operands: 50
43Operationoperator: 56
operands: 51
44Operationoperator: 56
operands: 52
45ExprRangelambda_map: 53
start_index: 92
end_index: 93
46ExprRangelambda_map: 54
start_index: 92
end_index: 94
47Operationoperator: 56
operands: 55
48Operationoperator: 56
operands: 57
49NamedExprselement: 60
targets: 58
50NamedExprselement: 66
targets: 58
51NamedExprselement: 59
targets: 65
52NamedExprselement: 60
targets: 67
53Lambdaparameter: 86
body: 61
54Lambdaparameter: 86
body: 63
55NamedExprselement: 64
targets: 65
56Literal
57NamedExprselement: 66
targets: 67
58Operationoperator: 79
operands: 68
59Operationoperator: 69
operands: 75
60Operationoperator: 69
operands: 70
61Operationoperator: 71
operands: 72
62ExprTuple86
63IndexedVarvariable: 73
indices: 74
64Operationoperator: 77
operands: 75
65Operationoperator: 79
operands: 76
66Operationoperator: 77
operands: 78
67Operationoperator: 79
operands: 80
68ExprTuple92, 94
69Literal
70NamedExprsstate: 81
part: 86
71Literal
72NamedExprsoperation: 82
73Variable
74ExprTuple83, 86
75NamedExprsstate: 84
part: 86
76ExprTuple92, 93
77Literal
78NamedExprsstate: 85
part: 86
79Literal
80ExprTuple87, 88
81Variable
82Literal
83Variable
84Variable
85Variable
86Variable
87Operationoperator: 90
operands: 89
88Operationoperator: 90
operands: 91
89ExprTuple93, 92
90Literal
91ExprTuple93, 94
92Literal
93Variable
94Variable