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, j, k, l, m
from proveit.core_expr_types import A_1_to_j, B_1_to_k, C_1_to_l, D_1_to_m
from proveit.logic import And, Forall, Implies, InSet
from proveit.numbers import Natural
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_AjBkCl, circuit_AjDmCl, circuit_Bk, circuit_Dm
In [2]:
# build up the expression from sub-expressions
expr = Lambda([j, k, l, m], Conditional(Forall(instance_param_or_params = [A_1_to_j, B_1_to_k, C_1_to_l, D_1_to_m], instance_expr = Implies(QcircuitEquiv(circuit_Bk, circuit_Dm), QcircuitEquiv(circuit_AjBkCl, circuit_AjDmCl).with_wrapping_at(1)).with_wrapping_at(2)).with_wrapping(), And(InSet(j, Natural), InSet(k, Natural), InSet(l, Natural), InSet(m, Natural))))
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(j, k, l, m\right) \mapsto \left\{\begin{array}{l}\forall_{A_{1}, A_{2}, \ldots, A_{j}, B_{1}, B_{2}, \ldots, B_{k}, C_{1}, C_{2}, \ldots, C_{l}, D_{1}, D_{2}, \ldots, D_{m}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\B_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{k} \\ \downarrow\end{array}} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\D_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{m} \\ \downarrow\end{array}} & \qw
} \end{array}\right)\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\A_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{j} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{k} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{l} \\ \downarrow\end{array}} & \qw
} \end{array}\right) \\  \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\A_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{j} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{m} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{l} \\ \downarrow\end{array}} & \qw
} \end{array}\right) \end{array} \end{array}\right) \end{array} \end{array}\right)\end{array} \textrm{ if } j \in \mathbb{N} ,  k \in \mathbb{N} ,  l \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
1ExprTuple45, 43, 50, 47
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12, 13
9Lambdaparameters: 14
body: 15
10Operationoperator: 19
operands: 16
11Operationoperator: 19
operands: 17
12Operationoperator: 19
operands: 18
13Operationoperator: 19
operands: 20
14ExprTuple39, 38, 41, 40
15Operationoperator: 21
operands: 22
16ExprTuple45, 23
17ExprTuple43, 23
18ExprTuple50, 23
19Literal
20ExprTuple47, 23
21Literal
22ExprTuple24, 25
23Literal
24Operationoperator: 27
operands: 26
25Operationoperator: 27
operands: 28
26ExprTuple29, 30
27Literal
28ExprTuple31, 32
29Operationoperator: 36
operands: 33
30Operationoperator: 36
operands: 34
31Operationoperator: 36
operands: 35
32Operationoperator: 36
operands: 37
33ExprTuple38
34ExprTuple40
35ExprTuple39, 38, 41
36Literal
37ExprTuple39, 40, 41
38ExprRangelambda_map: 42
start_index: 49
end_index: 43
39ExprRangelambda_map: 44
start_index: 49
end_index: 45
40ExprRangelambda_map: 46
start_index: 49
end_index: 47
41ExprRangelambda_map: 48
start_index: 49
end_index: 50
42Lambdaparameter: 60
body: 51
43Variable
44Lambdaparameter: 60
body: 52
45Variable
46Lambdaparameter: 60
body: 53
47Variable
48Lambdaparameter: 60
body: 54
49Literal
50Variable
51IndexedVarvariable: 55
index: 60
52IndexedVarvariable: 56
index: 60
53IndexedVarvariable: 57
index: 60
54IndexedVarvariable: 58
index: 60
55Variable
56Variable
57Variable
58Variable
59ExprTuple60
60Variable