logo

Expression of type ExprTuple

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 ExprTuple, Lambda
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 Implies
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 = ExprTuple(Lambda([A_1_to_j, B_1_to_k, C_1_to_l, D_1_to_m], Implies(QcircuitEquiv(circuit_Bk, circuit_Dm), QcircuitEquiv(circuit_AjBkCl, circuit_AjDmCl).with_wrapping_at(1)).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(\left(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}\right) \mapsto \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)\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple21, 20, 23, 22
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11Operationoperator: 18
operands: 15
12Operationoperator: 18
operands: 16
13Operationoperator: 18
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple20
16ExprTuple22
17ExprTuple21, 20, 23
18Literal
19ExprTuple21, 22, 23
20ExprRangelambda_map: 24
start_index: 31
end_index: 25
21ExprRangelambda_map: 26
start_index: 31
end_index: 27
22ExprRangelambda_map: 28
start_index: 31
end_index: 29
23ExprRangelambda_map: 30
start_index: 31
end_index: 32
24Lambdaparameter: 42
body: 33
25Variable
26Lambdaparameter: 42
body: 34
27Variable
28Lambdaparameter: 42
body: 35
29Variable
30Lambdaparameter: 42
body: 36
31Literal
32Variable
33IndexedVarvariable: 37
index: 42
34IndexedVarvariable: 38
index: 42
35IndexedVarvariable: 39
index: 42
36IndexedVarvariable: 40
index: 42
37Variable
38Variable
39Variable
40Variable
41ExprTuple42
42Variable