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, a, b
from proveit.core_expr_types import U_1_to_m
from proveit.logic import Implies
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_aU, circuit_aUb, circuit_b
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b, U_1_to_m], Implies(circuit_aUb, QcircuitEquiv(circuit_aU, circuit_b)))
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(a, b, U_{1}, U_{2}, \ldots, U_{m}\right) \mapsto \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \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_{m} \\ \downarrow\end{array}} & \qout{b}
} \end{array}\right) \Rightarrow \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \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_{m} \\ \downarrow\end{array}} & { /^{k} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{b} & { /^{k} } \qw
} \end{array}\right)\right)\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
1ExprTuple47, 48, 19
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 15
operands: 7
6Operationoperator: 8
operands: 9
7ExprTuple18, 19, 10
8Literal
9ExprTuple11, 12
10ExprTuple13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operand: 20
13ExprRangelambda_map: 17
start_index: 50
end_index: 51
14ExprTuple18, 19
15Literal
16ExprTuple20
17Lambdaparameter: 49
body: 21
18ExprTuple22
19ExprRangelambda_map: 23
start_index: 50
end_index: 24
20ExprTuple25
21Operationoperator: 37
operands: 26
22ExprRangelambda_map: 27
start_index: 50
end_index: 51
23Lambdaparameter: 49
body: 28
24Variable
25ExprRangelambda_map: 29
start_index: 50
end_index: 51
26NamedExprselement: 30
targets: 41
27Lambdaparameter: 49
body: 31
28IndexedVarvariable: 32
index: 49
29Lambdaparameter: 49
body: 34
30Operationoperator: 35
operands: 44
31Operationoperator: 37
operands: 36
32Variable
33ExprTuple49
34Operationoperator: 37
operands: 38
35Literal
36NamedExprselement: 39
targets: 41
37Literal
38NamedExprselement: 40
targets: 41
39Operationoperator: 43
operands: 42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42NamedExprsstate: 47
part: 49
43Literal
44NamedExprsstate: 48
part: 49
45Literal
46ExprTuple50, 51
47Variable
48Variable
49Variable
50Literal
51Variable