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 import U_1_to_i, V_1_to_j
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import one
from proveit.physics.quantum import m_ket_domain, var_ket_psi
from proveit.physics.quantum.circuits import circuit_Ui_Vj, circuit_Ui_psi_m, circuit_psi_m_Vj
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 = [U_1_to_i, V_1_to_j], instance_expr = Implies(Equals(Prob(circuit_Ui_psi_m), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_psi_m_Vj)).with_wrapping_at(2)).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_{U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \qout{\lvert \psi \rangle}
} \end{array}\right) = 1\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & \qw
} \end{array}\right) =  \\ \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & { /^{m} } \qw
} \end{array}\right) \end{array} \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: 71
body: 2
1ExprTuple71
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple71, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operands: 14
11ExprTuple42, 44
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Literal
18Operationoperator: 21
operands: 22
19Operationoperator: 24
operands: 23
20Operationoperator: 24
operands: 25
21Literal
22ExprTuple26, 74
23ExprTuple27, 73
24Literal
25ExprTuple28, 29
26Literal
27Operationoperator: 32
operand: 34
28Operationoperator: 32
operand: 35
29Operationoperator: 32
operand: 36
30ExprTuple34
31ExprTuple35
32Literal
33ExprTuple36
34Operationoperator: 39
operands: 37
35Operationoperator: 39
operands: 38
36Operationoperator: 39
operands: 40
37ExprTuple42, 41
38ExprTuple42, 44
39Literal
40ExprTuple43, 44
41ExprTuple45
42ExprRangelambda_map: 46
start_index: 73
end_index: 47
43ExprTuple48
44ExprRangelambda_map: 49
start_index: 73
end_index: 50
45ExprRangelambda_map: 51
start_index: 73
end_index: 74
46Lambdaparameter: 72
body: 52
47Variable
48ExprRangelambda_map: 53
start_index: 73
end_index: 74
49Lambdaparameter: 72
body: 54
50Variable
51Lambdaparameter: 72
body: 55
52IndexedVarvariable: 56
index: 72
53Lambdaparameter: 72
body: 57
54IndexedVarvariable: 58
index: 72
55Operationoperator: 61
operands: 60
56Variable
57Operationoperator: 61
operands: 62
58Variable
59ExprTuple72
60NamedExprselement: 63
targets: 65
61Literal
62NamedExprselement: 64
targets: 65
63Operationoperator: 66
operands: 68
64Operationoperator: 67
operands: 68
65Operationoperator: 69
operands: 70
66Literal
67Literal
68NamedExprsstate: 71
part: 72
69Literal
70ExprTuple73, 74
71Variable
72Variable
73Literal
74Variable