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 Lambda
from proveit.core_expr_types import U_1_to_i, V_1_to_j
from proveit.logic import Equals, Implies
from proveit.numbers import one
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([U_1_to_i, V_1_to_j], 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))
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(U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}\right) \mapsto \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)
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
1ExprTuple25, 27
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 8
operands: 7
6Operationoperator: 8
operands: 9
7ExprTuple10, 56
8Literal
9ExprTuple11, 12
10Operationoperator: 15
operand: 17
11Operationoperator: 15
operand: 18
12Operationoperator: 15
operand: 19
13ExprTuple17
14ExprTuple18
15Literal
16ExprTuple19
17Operationoperator: 22
operands: 20
18Operationoperator: 22
operands: 21
19Operationoperator: 22
operands: 23
20ExprTuple25, 24
21ExprTuple25, 27
22Literal
23ExprTuple26, 27
24ExprTuple28
25ExprRangelambda_map: 29
start_index: 56
end_index: 30
26ExprTuple31
27ExprRangelambda_map: 32
start_index: 56
end_index: 33
28ExprRangelambda_map: 34
start_index: 56
end_index: 57
29Lambdaparameter: 55
body: 35
30Variable
31ExprRangelambda_map: 36
start_index: 56
end_index: 57
32Lambdaparameter: 55
body: 37
33Variable
34Lambdaparameter: 55
body: 38
35IndexedVarvariable: 39
index: 55
36Lambdaparameter: 55
body: 40
37IndexedVarvariable: 41
index: 55
38Operationoperator: 44
operands: 43
39Variable
40Operationoperator: 44
operands: 45
41Variable
42ExprTuple55
43NamedExprselement: 46
targets: 48
44Literal
45NamedExprselement: 47
targets: 48
46Operationoperator: 49
operands: 51
47Operationoperator: 50
operands: 51
48Operationoperator: 52
operands: 53
49Literal
50Literal
51NamedExprsstate: 54
part: 55
52Literal
53ExprTuple56, 57
54Variable
55Variable
56Literal
57Variable