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__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([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__u_Akl_v__psi_m)).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{
\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)\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
1ExprTuple104, 107
2Conditionalvalue: 3
condition: 4
3Operationoperator: 18
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 108
body: 12
9Operationoperator: 20
operands: 13
10Operationoperator: 20
operands: 14
11ExprTuple108
12Conditionalvalue: 15
condition: 16
13ExprTuple104, 17
14ExprTuple107, 17
15Operationoperator: 18
operand: 23
16Operationoperator: 20
operands: 21
17Operationoperator: 28
operands: 22
18Literal
19ExprTuple23
20Literal
21ExprTuple108, 24
22ExprTuple34, 25
23Lambdaparameters: 26
body: 27
24Operationoperator: 28
operands: 29
25Operationoperator: 39
operands: 30
26ExprTuple31
27Operationoperator: 32
operands: 33
28Literal
29ExprTuple34, 35
30ExprTuple44, 116
31ExprRangelambda_map: 36
start_index: 115
end_index: 60
32Literal
33ExprTuple37, 38
34Literal
35Operationoperator: 39
operands: 40
36Lambdaparameter: 105
body: 72
37Operationoperator: 42
operand: 45
38Operationoperator: 42
operand: 46
39Literal
40ExprTuple44, 117
41ExprTuple45
42Literal
43ExprTuple46
44Literal
45Operationoperator: 48
operands: 47
46Operationoperator: 48
operands: 49
47ExprTuple50, 51, 52
48Literal
49ExprTuple53, 54, 55
50ExprTuple57
51ExprRangelambda_map: 56
start_index: 115
end_index: 60
52ExprTuple61
53ExprTuple57, 58
54ExprRangelambda_map: 59
start_index: 115
end_index: 60
55ExprTuple61, 62
56Lambdaparameter: 105
body: 63
57ExprRangelambda_map: 64
start_index: 115
end_index: 116
58ExprRangelambda_map: 65
start_index: 115
end_index: 117
59Lambdaparameter: 105
body: 67
60Variable
61ExprRangelambda_map: 68
start_index: 115
end_index: 116
62ExprRangelambda_map: 69
start_index: 115
end_index: 117
63ExprTuple72
64Lambdaparameter: 109
body: 70
65Lambdaparameter: 109
body: 71
66ExprTuple105
67ExprTuple72, 73
68Lambdaparameter: 109
body: 74
69Lambdaparameter: 109
body: 75
70Operationoperator: 81
operands: 76
71Operationoperator: 81
operands: 77
72ExprRangelambda_map: 78
start_index: 115
end_index: 116
73ExprRangelambda_map: 79
start_index: 115
end_index: 117
74Operationoperator: 81
operands: 80
75Operationoperator: 81
operands: 82
76NamedExprselement: 83
targets: 89
77NamedExprselement: 84
targets: 91
78Lambdaparameter: 109
body: 85
79Lambdaparameter: 109
body: 87
80NamedExprselement: 88
targets: 89
81Literal
82NamedExprselement: 90
targets: 91
83Operationoperator: 93
operands: 92
84Operationoperator: 93
operands: 101
85IndexedVarvariable: 94
indices: 95
86ExprTuple109
87Operationoperator: 96
operands: 97
88Operationoperator: 100
operands: 98
89Operationoperator: 102
operands: 99
90Operationoperator: 100
operands: 101
91Operationoperator: 102
operands: 103
92NamedExprsstate: 104
part: 109
93Literal
94Variable
95ExprTuple105, 109
96Literal
97NamedExprsoperation: 106
98NamedExprsstate: 107
part: 109
99ExprTuple115, 116
100Literal
101NamedExprsstate: 108
part: 109
102Literal
103ExprTuple110, 111
104Variable
105Variable
106Literal
107Variable
108Variable
109Variable
110Operationoperator: 113
operands: 112
111Operationoperator: 113
operands: 114
112ExprTuple116, 115
113Literal
114ExprTuple116, 117
115Literal
116Variable
117Variable