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__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_psi, Conditional(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(), 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{
\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} \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: 92
body: 2
1ExprTuple92
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple92, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operands: 14
11ExprTuple15
12Operationoperator: 16
operands: 17
13Literal
14ExprTuple18, 19
15ExprRangelambda_map: 20
start_index: 99
end_index: 44
16Literal
17ExprTuple21, 22
18Literal
19Operationoperator: 23
operands: 24
20Lambdaparameter: 89
body: 56
21Operationoperator: 26
operand: 29
22Operationoperator: 26
operand: 30
23Literal
24ExprTuple28, 101
25ExprTuple29
26Literal
27ExprTuple30
28Literal
29Operationoperator: 32
operands: 31
30Operationoperator: 32
operands: 33
31ExprTuple34, 35, 36
32Literal
33ExprTuple37, 38, 39
34ExprTuple41
35ExprRangelambda_map: 40
start_index: 99
end_index: 44
36ExprTuple45
37ExprTuple41, 42
38ExprRangelambda_map: 43
start_index: 99
end_index: 44
39ExprTuple45, 46
40Lambdaparameter: 89
body: 47
41ExprRangelambda_map: 48
start_index: 99
end_index: 100
42ExprRangelambda_map: 49
start_index: 99
end_index: 101
43Lambdaparameter: 89
body: 51
44Variable
45ExprRangelambda_map: 52
start_index: 99
end_index: 100
46ExprRangelambda_map: 53
start_index: 99
end_index: 101
47ExprTuple56
48Lambdaparameter: 93
body: 54
49Lambdaparameter: 93
body: 55
50ExprTuple89
51ExprTuple56, 57
52Lambdaparameter: 93
body: 58
53Lambdaparameter: 93
body: 59
54Operationoperator: 65
operands: 60
55Operationoperator: 65
operands: 61
56ExprRangelambda_map: 62
start_index: 99
end_index: 100
57ExprRangelambda_map: 63
start_index: 99
end_index: 101
58Operationoperator: 65
operands: 64
59Operationoperator: 65
operands: 66
60NamedExprselement: 67
targets: 73
61NamedExprselement: 68
targets: 75
62Lambdaparameter: 93
body: 69
63Lambdaparameter: 93
body: 71
64NamedExprselement: 72
targets: 73
65Literal
66NamedExprselement: 74
targets: 75
67Operationoperator: 77
operands: 76
68Operationoperator: 77
operands: 85
69IndexedVarvariable: 78
indices: 79
70ExprTuple93
71Operationoperator: 80
operands: 81
72Operationoperator: 84
operands: 82
73Operationoperator: 86
operands: 83
74Operationoperator: 84
operands: 85
75Operationoperator: 86
operands: 87
76NamedExprsstate: 88
part: 93
77Literal
78Variable
79ExprTuple89, 93
80Literal
81NamedExprsoperation: 90
82NamedExprsstate: 91
part: 93
83ExprTuple99, 100
84Literal
85NamedExprsstate: 92
part: 93
86Literal
87ExprTuple94, 95
88Variable
89Variable
90Literal
91Variable
92Variable
93Variable
94Operationoperator: 97
operands: 96
95Operationoperator: 97
operands: 98
96ExprTuple100, 99
97Literal
98ExprTuple100, 101
99Literal
100Variable
101Variable