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, Function, Lambda, Literal, k, p
from proveit.core_expr_types.expr_arrays import A11_to_Akm, B11_to_Bkn, R11_to_Rkm, S11_to_Skn
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_Akm, circuit_Bkn, circuit_permuted_Akm, circuit_permuted_Bkn
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(p, Conditional(Forall(instance_param_or_params = [A11_to_Akm, R11_to_Rkm, B11_to_Bkn, S11_to_Skn], instance_expr = Equals(QcircuitEquiv(circuit_Akm, circuit_Bkn), QcircuitEquiv(circuit_permuted_Akm, circuit_permuted_Bkn)).with_wrapping_at(2)).with_wrapping(), InSet(p, Function(Literal("Perm", latex_format = r"\textrm{Perm}", theory = "proveit.physics.quantum.circuits"), [Interval(one, k)])))))
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(p \mapsto \left\{\begin{array}{l}\forall_{A_{1, 1}, A_{1, 2}, \ldots, A_{1, m}, A_{2, 1}, A_{2, 2}, \ldots, A_{2, m}, \ldots\ldots, A_{k, 1}, A_{k, 2}, \ldots, A_{k, m}, R_{1, 1}, R_{1, 2}, \ldots, R_{1, m}, R_{2, 1}, R_{2, 2}, \ldots, R_{2, m}, \ldots\ldots, R_{k, 1}, R_{k, 2}, \ldots, R_{k, m}, B_{1, 1}, B_{1, 2}, \ldots, B_{1, n}, B_{2, 1}, B_{2, 2}, \ldots, B_{2, n}, \ldots\ldots, B_{k, 1}, B_{k, 2}, \ldots, B_{k, n}, S_{1, 1}, S_{1, 2}, \ldots, S_{1, n}, S_{2, 1}, S_{2, 2}, \ldots, S_{2, n}, \ldots\ldots, S_{k, 1}, S_{k, 2}, \ldots, S_{k, n}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{A_{1, 1}~\mbox{on}~R_{1, 1}} \qwx[1] & \gate{A_{2, 1}~\mbox{on}~R_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{m, 1}~\mbox{on}~R_{m, 1}} \qwx[1] & \qw \\
& \gate{A_{1, 2}~\mbox{on}~R_{1, 2}} \qwx[1] & \gate{A_{2, 2}~\mbox{on}~R_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{m, 2}~\mbox{on}~R_{m, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{A_{1, k}~\mbox{on}~R_{1, k}} & \gate{A_{2, k}~\mbox{on}~R_{2, k}} & \gate{\cdots} & \gate{A_{m, k}~\mbox{on}~R_{m, k}} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{B_{1, 1}~\mbox{on}~S_{1, 1}} \qwx[1] & \gate{B_{2, 1}~\mbox{on}~S_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{n, 1}~\mbox{on}~S_{n, 1}} \qwx[1] & \qw \\
& \gate{B_{1, 2}~\mbox{on}~S_{1, 2}} \qwx[1] & \gate{B_{2, 2}~\mbox{on}~S_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{n, 2}~\mbox{on}~S_{n, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{B_{1, k}~\mbox{on}~S_{1, k}} & \gate{B_{2, k}~\mbox{on}~S_{2, k}} & \gate{\cdots} & \gate{B_{n, k}~\mbox{on}~S_{n, k}} & \qw
} \end{array}\right)\right) =  \\ \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{A_{p\left(1\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), 1}\right)} \qwx[1] & \gate{A_{p\left(2\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), 1}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{p\left(m\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), 1}\right)} \qwx[1] & \qw \\
& \gate{A_{p\left(1\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), 2}\right)} \qwx[1] & \gate{A_{p\left(2\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), 2}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{p\left(m\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), 2}\right)} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{A_{p\left(1\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), k}\right)} & \gate{A_{p\left(2\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), k}\right)} & \gate{\cdots} & \gate{A_{p\left(m\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), k}\right)} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{B_{p\left(1\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), 1}\right)} \qwx[1] & \gate{B_{p\left(2\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 1}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{p\left(n\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 1}\right)} \qwx[1] & \qw \\
& \gate{B_{p\left(1\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), 2}\right)} \qwx[1] & \gate{B_{p\left(2\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 2}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{p\left(n\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 2}\right)} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{B_{p\left(1\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), k}\right)} & \gate{B_{p\left(2\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), k}\right)} & \gate{\cdots} & \gate{B_{p\left(n\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), k}\right)} & \qw
} \end{array}\right)\right) \end{array} \end{array}\right)\end{array} \textrm{ if } p \in \textrm{Perm}\left(\{1~\ldotp \ldotp~k\}\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
0ExprTuple1
1Lambdaparameter: 107
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple107, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operand: 21
11ExprTuple15, 16, 17, 18
12Operationoperator: 19
operands: 20
13Literal
14ExprTuple21
15ExprRangelambda_map: 22
start_index: 72
end_index: 73
16ExprRangelambda_map: 23
start_index: 72
end_index: 73
17ExprRangelambda_map: 24
start_index: 72
end_index: 73
18ExprRangelambda_map: 25
start_index: 72
end_index: 73
19Literal
20ExprTuple26, 27
21Operationoperator: 28
operands: 29
22Lambdaparameter: 109
body: 30
23Lambdaparameter: 109
body: 31
24Lambdaparameter: 109
body: 32
25Lambdaparameter: 109
body: 33
26Operationoperator: 35
operands: 34
27Operationoperator: 35
operands: 36
28Literal
29ExprTuple72, 73
30ExprRangelambda_map: 37
start_index: 72
end_index: 57
31ExprRangelambda_map: 38
start_index: 72
end_index: 57
32ExprRangelambda_map: 39
start_index: 72
end_index: 59
33ExprRangelambda_map: 40
start_index: 72
end_index: 59
34ExprTuple41, 42
35Literal
36ExprTuple43, 44
37Lambdaparameter: 106
body: 84
38Lambdaparameter: 106
body: 85
39Lambdaparameter: 106
body: 86
40Lambdaparameter: 106
body: 87
41Operationoperator: 48
operands: 45
42Operationoperator: 48
operands: 46
43Operationoperator: 48
operands: 47
44Operationoperator: 48
operands: 49
45ExprTuple50
46ExprTuple51
47ExprTuple52
48Literal
49ExprTuple53
50ExprRangelambda_map: 54
start_index: 72
end_index: 57
51ExprRangelambda_map: 55
start_index: 72
end_index: 59
52ExprRangelambda_map: 56
start_index: 72
end_index: 57
53ExprRangelambda_map: 58
start_index: 72
end_index: 59
54Lambdaparameter: 109
body: 60
55Lambdaparameter: 109
body: 61
56Lambdaparameter: 109
body: 62
57Variable
58Lambdaparameter: 109
body: 63
59Variable
60ExprTuple64
61ExprTuple65
62ExprTuple66
63ExprTuple67
64ExprRangelambda_map: 68
start_index: 72
end_index: 73
65ExprRangelambda_map: 69
start_index: 72
end_index: 73
66ExprRangelambda_map: 70
start_index: 72
end_index: 73
67ExprRangelambda_map: 71
start_index: 72
end_index: 73
68Lambdaparameter: 106
body: 74
69Lambdaparameter: 106
body: 75
70Lambdaparameter: 106
body: 76
71Lambdaparameter: 106
body: 78
72Literal
73Variable
74Operationoperator: 82
operands: 79
75Operationoperator: 82
operands: 80
76Operationoperator: 82
operands: 81
77ExprTuple106
78Operationoperator: 82
operands: 83
79NamedExprselement: 84
targets: 85
80NamedExprselement: 86
targets: 87
81NamedExprselement: 88
targets: 89
82Literal
83NamedExprselement: 90
targets: 91
84IndexedVarvariable: 93
indices: 92
85IndexedVarvariable: 102
indices: 92
86IndexedVarvariable: 95
indices: 92
87IndexedVarvariable: 103
indices: 92
88IndexedVarvariable: 93
indices: 104
89Operationoperator: 96
operand: 98
90IndexedVarvariable: 95
indices: 104
91Operationoperator: 96
operand: 101
92ExprTuple109, 106
93Variable
94ExprTuple98
95Variable
96Operationoperator: 99
operand: 107
97ExprTuple101
98IndexedVarvariable: 102
indices: 104
99Literal
100ExprTuple107
101IndexedVarvariable: 103
indices: 104
102Variable
103Variable
104ExprTuple105, 106
105Operationoperator: 107
operand: 109
106Variable
107Variable
108ExprTuple109
109Variable