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 And, Equals, Forall, InSet
from proveit.physics.quantum import l_ket_domain, m_ket_domain, var_ket_psi, var_ket_u, var_ket_v
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_u, var_ket_v], Conditional(Forall(instance_param_or_params = [var_ket_psi], instance_expr = 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(), domain = m_ket_domain), And(InSet(var_ket_u, l_ket_domain), InSet(var_ket_v, l_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())
\left(\lvert u \rangle, \lvert v \rangle\right) \mapsto \left\{\forall_{\lvert \psi \rangle \in \mathbb{C}^{2^{m}}}~\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}\right] \textrm{ if } \lvert u \rangle \in \mathbb{C}^{2^{l}} ,  \lvert v \rangle \in \mathbb{C}^{2^{l}}\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
1ExprTuple114, 118
2Conditionalvalue: 3
condition: 4
3Operationoperator: 18
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 117
body: 12
9Operationoperator: 20
operands: 13
10Operationoperator: 20
operands: 14
11ExprTuple117
12Conditionalvalue: 15
condition: 16
13ExprTuple114, 17
14ExprTuple118, 17
15Operationoperator: 18
operand: 23
16Operationoperator: 20
operands: 21
17Operationoperator: 28
operands: 22
18Literal
19ExprTuple23
20Literal
21ExprTuple117, 24
22ExprTuple34, 25
23Lambdaparameters: 26
body: 27
24Operationoperator: 28
operands: 29
25Operationoperator: 39
operands: 30
26ExprTuple31
27Operationoperator: 32
operands: 33
28Literal
29ExprTuple34, 35
30ExprTuple44, 127
31ExprRangelambda_map: 36
start_index: 125
end_index: 62
32Literal
33ExprTuple37, 38
34Literal
35Operationoperator: 39
operands: 40
36Lambdaparameter: 116
body: 79
37Operationoperator: 42
operand: 45
38Operationoperator: 42
operand: 46
39Literal
40ExprTuple44, 126
41ExprTuple45
42Literal
43ExprTuple46
44Literal
45Operationoperator: 48
operands: 47
46Operationoperator: 48
operands: 49
47ExprTuple50, 51, 52
48Literal
49ExprTuple53, 54, 55
50ExprTuple56
51ExprRangelambda_map: 57
start_index: 125
end_index: 62
52ExprTuple58
53ExprTuple59, 60
54ExprRangelambda_map: 61
start_index: 125
end_index: 62
55ExprTuple63, 64
56ExprRangelambda_map: 65
start_index: 125
end_index: 127
57Lambdaparameter: 116
body: 66
58ExprRangelambda_map: 67
start_index: 125
end_index: 127
59ExprRangelambda_map: 68
start_index: 125
end_index: 126
60ExprRangelambda_map: 69
start_index: 125
end_index: 127
61Lambdaparameter: 116
body: 71
62Variable
63ExprRangelambda_map: 72
start_index: 125
end_index: 126
64ExprRangelambda_map: 73
start_index: 125
end_index: 127
65Lambdaparameter: 119
body: 74
66ExprTuple79
67Lambdaparameter: 119
body: 75
68Lambdaparameter: 119
body: 76
69Lambdaparameter: 119
body: 77
70ExprTuple116
71ExprTuple78, 79
72Lambdaparameter: 119
body: 80
73Lambdaparameter: 119
body: 81
74Operationoperator: 89
operands: 82
75Operationoperator: 89
operands: 83
76Operationoperator: 89
operands: 84
77Operationoperator: 89
operands: 85
78ExprRangelambda_map: 86
start_index: 125
end_index: 126
79ExprRangelambda_map: 87
start_index: 125
end_index: 127
80Operationoperator: 89
operands: 88
81Operationoperator: 89
operands: 90
82NamedExprselement: 93
targets: 91
83NamedExprselement: 99
targets: 91
84NamedExprselement: 92
targets: 98
85NamedExprselement: 93
targets: 100
86Lambdaparameter: 119
body: 94
87Lambdaparameter: 119
body: 96
88NamedExprselement: 97
targets: 98
89Literal
90NamedExprselement: 99
targets: 100
91Operationoperator: 112
operands: 101
92Operationoperator: 102
operands: 108
93Operationoperator: 102
operands: 103
94Operationoperator: 104
operands: 105
95ExprTuple119
96IndexedVarvariable: 106
indices: 107
97Operationoperator: 110
operands: 108
98Operationoperator: 112
operands: 109
99Operationoperator: 110
operands: 111
100Operationoperator: 112
operands: 113
101ExprTuple125, 127
102Literal
103NamedExprsstate: 114
part: 119
104Literal
105NamedExprsoperation: 115
106Variable
107ExprTuple116, 119
108NamedExprsstate: 117
part: 119
109ExprTuple125, 126
110Literal
111NamedExprsstate: 118
part: 119
112Literal
113ExprTuple120, 121
114Variable
115Literal
116Variable
117Variable
118Variable
119Variable
120Operationoperator: 123
operands: 122
121Operationoperator: 123
operands: 124
122ExprTuple126, 125
123Literal
124ExprTuple126, 127
125Literal
126Variable
127Variable