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 Conditional, ExprTuple, 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 = ExprTuple(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(\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..\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
2ExprTuple46, 44, 51, 48
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13, 14
10Lambdaparameters: 15
body: 16
11Operationoperator: 20
operands: 17
12Operationoperator: 20
operands: 18
13Operationoperator: 20
operands: 19
14Operationoperator: 20
operands: 21
15ExprTuple40, 39, 42, 41
16Operationoperator: 22
operands: 23
17ExprTuple46, 24
18ExprTuple44, 24
19ExprTuple51, 24
20Literal
21ExprTuple48, 24
22Literal
23ExprTuple25, 26
24Literal
25Operationoperator: 28
operands: 27
26Operationoperator: 28
operands: 29
27ExprTuple30, 31
28Literal
29ExprTuple32, 33
30Operationoperator: 37
operands: 34
31Operationoperator: 37
operands: 35
32Operationoperator: 37
operands: 36
33Operationoperator: 37
operands: 38
34ExprTuple39
35ExprTuple41
36ExprTuple40, 39, 42
37Literal
38ExprTuple40, 41, 42
39ExprRangelambda_map: 43
start_index: 50
end_index: 44
40ExprRangelambda_map: 45
start_index: 50
end_index: 46
41ExprRangelambda_map: 47
start_index: 50
end_index: 48
42ExprRangelambda_map: 49
start_index: 50
end_index: 51
43Lambdaparameter: 61
body: 52
44Variable
45Lambdaparameter: 61
body: 53
46Variable
47Lambdaparameter: 61
body: 54
48Variable
49Lambdaparameter: 61
body: 55
50Literal
51Variable
52IndexedVarvariable: 56
index: 61
53IndexedVarvariable: 57
index: 61
54IndexedVarvariable: 58
index: 61
55IndexedVarvariable: 59
index: 61
56Variable
57Variable
58Variable
59Variable
60ExprTuple61
61Variable