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, k, l, m
from proveit.core_expr_types.expr_arrays import A11_to_Akl
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import NaturalPos
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([k, l, m], Conditional(Forall(instance_param_or_params = [var_ket_u, var_ket_v], instance_expr = 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), domain = l_ket_domain), And(InSet(k, NaturalPos), InSet(l, NaturalPos), InSet(m, NaturalPos))))
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(k, l, m\right) \mapsto \left\{\forall_{\lvert u \rangle, \lvert v \rangle \in \mathbb{C}^{2^{l}}}~\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]\right] \textrm{ if } k \in \mathbb{N}^+ ,  l \in \mathbb{N}^+ ,  m \in \mathbb{N}^+\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
1ExprTuple76, 141, 140
2Conditionalvalue: 3
condition: 4
3Operationoperator: 32
operand: 7
4Operationoperator: 20
operands: 6
5ExprTuple7
6ExprTuple8, 9, 10
7Lambdaparameters: 11
body: 12
8Operationoperator: 34
operands: 13
9Operationoperator: 34
operands: 14
10Operationoperator: 34
operands: 15
11ExprTuple128, 132
12Conditionalvalue: 16
condition: 17
13ExprTuple76, 18
14ExprTuple141, 18
15ExprTuple140, 18
16Operationoperator: 32
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple23, 24
22Lambdaparameter: 131
body: 26
23Operationoperator: 34
operands: 27
24Operationoperator: 34
operands: 28
25ExprTuple131
26Conditionalvalue: 29
condition: 30
27ExprTuple128, 31
28ExprTuple132, 31
29Operationoperator: 32
operand: 37
30Operationoperator: 34
operands: 35
31Operationoperator: 42
operands: 36
32Literal
33ExprTuple37
34Literal
35ExprTuple131, 38
36ExprTuple48, 39
37Lambdaparameters: 40
body: 41
38Operationoperator: 42
operands: 43
39Operationoperator: 53
operands: 44
40ExprTuple45
41Operationoperator: 46
operands: 47
42Literal
43ExprTuple48, 49
44ExprTuple58, 141
45ExprRangelambda_map: 50
start_index: 139
end_index: 76
46Literal
47ExprTuple51, 52
48Literal
49Operationoperator: 53
operands: 54
50Lambdaparameter: 130
body: 93
51Operationoperator: 56
operand: 59
52Operationoperator: 56
operand: 60
53Literal
54ExprTuple58, 140
55ExprTuple59
56Literal
57ExprTuple60
58Literal
59Operationoperator: 62
operands: 61
60Operationoperator: 62
operands: 63
61ExprTuple64, 65, 66
62Literal
63ExprTuple67, 68, 69
64ExprTuple70
65ExprRangelambda_map: 71
start_index: 139
end_index: 76
66ExprTuple72
67ExprTuple73, 74
68ExprRangelambda_map: 75
start_index: 139
end_index: 76
69ExprTuple77, 78
70ExprRangelambda_map: 79
start_index: 139
end_index: 141
71Lambdaparameter: 130
body: 80
72ExprRangelambda_map: 81
start_index: 139
end_index: 141
73ExprRangelambda_map: 82
start_index: 139
end_index: 140
74ExprRangelambda_map: 83
start_index: 139
end_index: 141
75Lambdaparameter: 130
body: 85
76Variable
77ExprRangelambda_map: 86
start_index: 139
end_index: 140
78ExprRangelambda_map: 87
start_index: 139
end_index: 141
79Lambdaparameter: 133
body: 88
80ExprTuple93
81Lambdaparameter: 133
body: 89
82Lambdaparameter: 133
body: 90
83Lambdaparameter: 133
body: 91
84ExprTuple130
85ExprTuple92, 93
86Lambdaparameter: 133
body: 94
87Lambdaparameter: 133
body: 95
88Operationoperator: 103
operands: 96
89Operationoperator: 103
operands: 97
90Operationoperator: 103
operands: 98
91Operationoperator: 103
operands: 99
92ExprRangelambda_map: 100
start_index: 139
end_index: 140
93ExprRangelambda_map: 101
start_index: 139
end_index: 141
94Operationoperator: 103
operands: 102
95Operationoperator: 103
operands: 104
96NamedExprselement: 107
targets: 105
97NamedExprselement: 113
targets: 105
98NamedExprselement: 106
targets: 112
99NamedExprselement: 107
targets: 114
100Lambdaparameter: 133
body: 108
101Lambdaparameter: 133
body: 110
102NamedExprselement: 111
targets: 112
103Literal
104NamedExprselement: 113
targets: 114
105Operationoperator: 126
operands: 115
106Operationoperator: 116
operands: 122
107Operationoperator: 116
operands: 117
108Operationoperator: 118
operands: 119
109ExprTuple133
110IndexedVarvariable: 120
indices: 121
111Operationoperator: 124
operands: 122
112Operationoperator: 126
operands: 123
113Operationoperator: 124
operands: 125
114Operationoperator: 126
operands: 127
115ExprTuple139, 141
116Literal
117NamedExprsstate: 128
part: 133
118Literal
119NamedExprsoperation: 129
120Variable
121ExprTuple130, 133
122NamedExprsstate: 131
part: 133
123ExprTuple139, 140
124Literal
125NamedExprsstate: 132
part: 133
126Literal
127ExprTuple134, 135
128Variable
129Literal
130Variable
131Variable
132Variable
133Variable
134Operationoperator: 137
operands: 136
135Operationoperator: 137
operands: 138
136ExprTuple140, 139
137Literal
138ExprTuple140, 141
139Literal
140Variable
141Variable