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 Conditional, Lambda
from proveit.core_expr_types.expr_arrays import A11_to_Akl
from proveit.logic import Equals, Forall, InSet
from proveit.physics.quantum import m_ket_domain, var_ket_psi
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(var_ket_psi, Conditional(Forall(instance_param_or_params = [A11_to_Akl], instance_expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__psi_m__u_Akl_v)).with_wrapping_at(2)).with_wrapping(), InSet(var_ket_psi, m_ket_domain)))
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())
\lvert \psi \rangle \mapsto \left\{\begin{array}{l}\forall_{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}}~\\
\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)\end{array} \textrm{ if } \lvert \psi \rangle \in \mathbb{C}^{2^{m}}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 101
body: 2
1ExprTuple101
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple101, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operands: 14
11ExprTuple15
12Operationoperator: 16
operands: 17
13Literal
14ExprTuple18, 19
15ExprRangelambda_map: 20
start_index: 109
end_index: 46
16Literal
17ExprTuple21, 22
18Literal
19Operationoperator: 23
operands: 24
20Lambdaparameter: 100
body: 63
21Operationoperator: 26
operand: 29
22Operationoperator: 26
operand: 30
23Literal
24ExprTuple28, 110
25ExprTuple29
26Literal
27ExprTuple30
28Literal
29Operationoperator: 32
operands: 31
30Operationoperator: 32
operands: 33
31ExprTuple34, 35, 36
32Literal
33ExprTuple37, 38, 39
34ExprTuple40
35ExprRangelambda_map: 41
start_index: 109
end_index: 46
36ExprTuple42
37ExprTuple43, 44
38ExprRangelambda_map: 45
start_index: 109
end_index: 46
39ExprTuple47, 48
40ExprRangelambda_map: 49
start_index: 109
end_index: 111
41Lambdaparameter: 100
body: 50
42ExprRangelambda_map: 51
start_index: 109
end_index: 111
43ExprRangelambda_map: 52
start_index: 109
end_index: 110
44ExprRangelambda_map: 53
start_index: 109
end_index: 111
45Lambdaparameter: 100
body: 55
46Variable
47ExprRangelambda_map: 56
start_index: 109
end_index: 110
48ExprRangelambda_map: 57
start_index: 109
end_index: 111
49Lambdaparameter: 103
body: 58
50ExprTuple63
51Lambdaparameter: 103
body: 59
52Lambdaparameter: 103
body: 60
53Lambdaparameter: 103
body: 61
54ExprTuple100
55ExprTuple62, 63
56Lambdaparameter: 103
body: 64
57Lambdaparameter: 103
body: 65
58Operationoperator: 73
operands: 66
59Operationoperator: 73
operands: 67
60Operationoperator: 73
operands: 68
61Operationoperator: 73
operands: 69
62ExprRangelambda_map: 70
start_index: 109
end_index: 110
63ExprRangelambda_map: 71
start_index: 109
end_index: 111
64Operationoperator: 73
operands: 72
65Operationoperator: 73
operands: 74
66NamedExprselement: 77
targets: 75
67NamedExprselement: 83
targets: 75
68NamedExprselement: 76
targets: 82
69NamedExprselement: 77
targets: 84
70Lambdaparameter: 103
body: 78
71Lambdaparameter: 103
body: 80
72NamedExprselement: 81
targets: 82
73Literal
74NamedExprselement: 83
targets: 84
75Operationoperator: 96
operands: 85
76Operationoperator: 86
operands: 92
77Operationoperator: 86
operands: 87
78Operationoperator: 88
operands: 89
79ExprTuple103
80IndexedVarvariable: 90
indices: 91
81Operationoperator: 94
operands: 92
82Operationoperator: 96
operands: 93
83Operationoperator: 94
operands: 95
84Operationoperator: 96
operands: 97
85ExprTuple109, 111
86Literal
87NamedExprsstate: 98
part: 103
88Literal
89NamedExprsoperation: 99
90Variable
91ExprTuple100, 103
92NamedExprsstate: 101
part: 103
93ExprTuple109, 110
94Literal
95NamedExprsstate: 102
part: 103
96Literal
97ExprTuple104, 105
98Variable
99Literal
100Variable
101Variable
102Variable
103Variable
104Operationoperator: 107
operands: 106
105Operationoperator: 107
operands: 108
106ExprTuple110, 109
107Literal
108ExprTuple110, 111
109Literal
110Variable
111Variable