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__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([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__u_Akl_v__psi_m)).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{
\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]\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
1ExprTuple74, 130, 131
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
11ExprTuple118, 121
12Conditionalvalue: 16
condition: 17
13ExprTuple74, 18
14ExprTuple130, 18
15ExprTuple131, 18
16Operationoperator: 32
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple23, 24
22Lambdaparameter: 122
body: 26
23Operationoperator: 34
operands: 27
24Operationoperator: 34
operands: 28
25ExprTuple122
26Conditionalvalue: 29
condition: 30
27ExprTuple118, 31
28ExprTuple121, 31
29Operationoperator: 32
operand: 37
30Operationoperator: 34
operands: 35
31Operationoperator: 42
operands: 36
32Literal
33ExprTuple37
34Literal
35ExprTuple122, 38
36ExprTuple48, 39
37Lambdaparameters: 40
body: 41
38Operationoperator: 42
operands: 43
39Operationoperator: 53
operands: 44
40ExprTuple45
41Operationoperator: 46
operands: 47
42Literal
43ExprTuple48, 49
44ExprTuple58, 130
45ExprRangelambda_map: 50
start_index: 129
end_index: 74
46Literal
47ExprTuple51, 52
48Literal
49Operationoperator: 53
operands: 54
50Lambdaparameter: 119
body: 86
51Operationoperator: 56
operand: 59
52Operationoperator: 56
operand: 60
53Literal
54ExprTuple58, 131
55ExprTuple59
56Literal
57ExprTuple60
58Literal
59Operationoperator: 62
operands: 61
60Operationoperator: 62
operands: 63
61ExprTuple64, 65, 66
62Literal
63ExprTuple67, 68, 69
64ExprTuple71
65ExprRangelambda_map: 70
start_index: 129
end_index: 74
66ExprTuple75
67ExprTuple71, 72
68ExprRangelambda_map: 73
start_index: 129
end_index: 74
69ExprTuple75, 76
70Lambdaparameter: 119
body: 77
71ExprRangelambda_map: 78
start_index: 129
end_index: 130
72ExprRangelambda_map: 79
start_index: 129
end_index: 131
73Lambdaparameter: 119
body: 81
74Variable
75ExprRangelambda_map: 82
start_index: 129
end_index: 130
76ExprRangelambda_map: 83
start_index: 129
end_index: 131
77ExprTuple86
78Lambdaparameter: 123
body: 84
79Lambdaparameter: 123
body: 85
80ExprTuple119
81ExprTuple86, 87
82Lambdaparameter: 123
body: 88
83Lambdaparameter: 123
body: 89
84Operationoperator: 95
operands: 90
85Operationoperator: 95
operands: 91
86ExprRangelambda_map: 92
start_index: 129
end_index: 130
87ExprRangelambda_map: 93
start_index: 129
end_index: 131
88Operationoperator: 95
operands: 94
89Operationoperator: 95
operands: 96
90NamedExprselement: 97
targets: 103
91NamedExprselement: 98
targets: 105
92Lambdaparameter: 123
body: 99
93Lambdaparameter: 123
body: 101
94NamedExprselement: 102
targets: 103
95Literal
96NamedExprselement: 104
targets: 105
97Operationoperator: 107
operands: 106
98Operationoperator: 107
operands: 115
99IndexedVarvariable: 108
indices: 109
100ExprTuple123
101Operationoperator: 110
operands: 111
102Operationoperator: 114
operands: 112
103Operationoperator: 116
operands: 113
104Operationoperator: 114
operands: 115
105Operationoperator: 116
operands: 117
106NamedExprsstate: 118
part: 123
107Literal
108Variable
109ExprTuple119, 123
110Literal
111NamedExprsoperation: 120
112NamedExprsstate: 121
part: 123
113ExprTuple129, 130
114Literal
115NamedExprsstate: 122
part: 123
116Literal
117ExprTuple124, 125
118Variable
119Variable
120Literal
121Variable
122Variable
123Variable
124Operationoperator: 127
operands: 126
125Operationoperator: 127
operands: 128
126ExprTuple130, 129
127Literal
128ExprTuple130, 131
129Literal
130Variable
131Variable