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, a, b, k, m
from proveit.core_expr_types import U_1_to_m
from proveit.logic import And, Forall, Implies, InSet
from proveit.numbers import NaturalPos
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_aU, circuit_aUb, circuit_b
In [2]:
# build up the expression from sub-expressions
expr = Lambda([k, m], Conditional(Forall(instance_param_or_params = [a, b, U_1_to_m], instance_expr = Implies(circuit_aUb, QcircuitEquiv(circuit_aU, circuit_b))), And(InSet(k, 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, m\right) \mapsto \left\{\forall_{a, b, U_{1}, U_{2}, \ldots, U_{m}}~\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) \textrm{ if } k \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
1ExprTuple66, 39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple62, 63, 34
13Operationoperator: 17
operands: 18
14ExprTuple66, 19
15Literal
16ExprTuple39, 19
17Literal
18ExprTuple20, 21
19Literal
20Operationoperator: 30
operands: 22
21Operationoperator: 23
operands: 24
22ExprTuple33, 34, 25
23Literal
24ExprTuple26, 27
25ExprTuple28
26Operationoperator: 30
operands: 29
27Operationoperator: 30
operand: 35
28ExprRangelambda_map: 32
start_index: 65
end_index: 66
29ExprTuple33, 34
30Literal
31ExprTuple35
32Lambdaparameter: 64
body: 36
33ExprTuple37
34ExprRangelambda_map: 38
start_index: 65
end_index: 39
35ExprTuple40
36Operationoperator: 52
operands: 41
37ExprRangelambda_map: 42
start_index: 65
end_index: 66
38Lambdaparameter: 64
body: 43
39Variable
40ExprRangelambda_map: 44
start_index: 65
end_index: 66
41NamedExprselement: 45
targets: 56
42Lambdaparameter: 64
body: 46
43IndexedVarvariable: 47
index: 64
44Lambdaparameter: 64
body: 49
45Operationoperator: 50
operands: 59
46Operationoperator: 52
operands: 51
47Variable
48ExprTuple64
49Operationoperator: 52
operands: 53
50Literal
51NamedExprselement: 54
targets: 56
52Literal
53NamedExprselement: 55
targets: 56
54Operationoperator: 58
operands: 57
55Operationoperator: 58
operands: 59
56Operationoperator: 60
operands: 61
57NamedExprsstate: 62
part: 64
58Literal
59NamedExprsstate: 63
part: 64
60Literal
61ExprTuple65, 66
62Variable
63Variable
64Variable
65Literal
66Variable