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, m, n, 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 And, Equals, Forall, InSet
from proveit.numbers import Interval, NaturalPos, 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([k, m, n], Conditional(Forall(instance_param_or_params = [p], instance_expr = 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(), domain = Function(Literal("Perm", latex_format = r"\textrm{Perm}", theory = "proveit.physics.quantum.circuits"), [Interval(one, k)])), And(InSet(k, NaturalPos), InSet(m, NaturalPos), InSet(n, 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(\left(k, m, n\right) \mapsto \left\{\forall_{p \in \textrm{Perm}\left(\{1~\ldotp \ldotp~k\}\right)}~\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}\right] \textrm{ if } k \in \mathbb{N}^+ ,  m \in \mathbb{N}^+ ,  n \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
2ExprTuple88, 72, 74
3Conditionalvalue: 4
condition: 5
4Operationoperator: 20
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameter: 122
body: 13
10Operationoperator: 22
operands: 14
11Operationoperator: 22
operands: 15
12Operationoperator: 22
operands: 16
13Conditionalvalue: 17
condition: 18
14ExprTuple88, 19
15ExprTuple72, 19
16ExprTuple74, 19
17Operationoperator: 20
operand: 24
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24
22Literal
23ExprTuple122, 25
24Lambdaparameters: 26
body: 27
25Operationoperator: 28
operand: 36
26ExprTuple30, 31, 32, 33
27Operationoperator: 34
operands: 35
28Literal
29ExprTuple36
30ExprRangelambda_map: 37
start_index: 87
end_index: 88
31ExprRangelambda_map: 38
start_index: 87
end_index: 88
32ExprRangelambda_map: 39
start_index: 87
end_index: 88
33ExprRangelambda_map: 40
start_index: 87
end_index: 88
34Literal
35ExprTuple41, 42
36Operationoperator: 43
operands: 44
37Lambdaparameter: 124
body: 45
38Lambdaparameter: 124
body: 46
39Lambdaparameter: 124
body: 47
40Lambdaparameter: 124
body: 48
41Operationoperator: 50
operands: 49
42Operationoperator: 50
operands: 51
43Literal
44ExprTuple87, 88
45ExprRangelambda_map: 52
start_index: 87
end_index: 72
46ExprRangelambda_map: 53
start_index: 87
end_index: 72
47ExprRangelambda_map: 54
start_index: 87
end_index: 74
48ExprRangelambda_map: 55
start_index: 87
end_index: 74
49ExprTuple56, 57
50Literal
51ExprTuple58, 59
52Lambdaparameter: 121
body: 99
53Lambdaparameter: 121
body: 100
54Lambdaparameter: 121
body: 101
55Lambdaparameter: 121
body: 102
56Operationoperator: 63
operands: 60
57Operationoperator: 63
operands: 61
58Operationoperator: 63
operands: 62
59Operationoperator: 63
operands: 64
60ExprTuple65
61ExprTuple66
62ExprTuple67
63Literal
64ExprTuple68
65ExprRangelambda_map: 69
start_index: 87
end_index: 72
66ExprRangelambda_map: 70
start_index: 87
end_index: 74
67ExprRangelambda_map: 71
start_index: 87
end_index: 72
68ExprRangelambda_map: 73
start_index: 87
end_index: 74
69Lambdaparameter: 124
body: 75
70Lambdaparameter: 124
body: 76
71Lambdaparameter: 124
body: 77
72Variable
73Lambdaparameter: 124
body: 78
74Variable
75ExprTuple79
76ExprTuple80
77ExprTuple81
78ExprTuple82
79ExprRangelambda_map: 83
start_index: 87
end_index: 88
80ExprRangelambda_map: 84
start_index: 87
end_index: 88
81ExprRangelambda_map: 85
start_index: 87
end_index: 88
82ExprRangelambda_map: 86
start_index: 87
end_index: 88
83Lambdaparameter: 121
body: 89
84Lambdaparameter: 121
body: 90
85Lambdaparameter: 121
body: 91
86Lambdaparameter: 121
body: 93
87Literal
88Variable
89Operationoperator: 97
operands: 94
90Operationoperator: 97
operands: 95
91Operationoperator: 97
operands: 96
92ExprTuple121
93Operationoperator: 97
operands: 98
94NamedExprselement: 99
targets: 100
95NamedExprselement: 101
targets: 102
96NamedExprselement: 103
targets: 104
97Literal
98NamedExprselement: 105
targets: 106
99IndexedVarvariable: 108
indices: 107
100IndexedVarvariable: 117
indices: 107
101IndexedVarvariable: 110
indices: 107
102IndexedVarvariable: 118
indices: 107
103IndexedVarvariable: 108
indices: 119
104Operationoperator: 111
operand: 113
105IndexedVarvariable: 110
indices: 119
106Operationoperator: 111
operand: 116
107ExprTuple124, 121
108Variable
109ExprTuple113
110Variable
111Operationoperator: 114
operand: 122
112ExprTuple116
113IndexedVarvariable: 117
indices: 119
114Literal
115ExprTuple122
116IndexedVarvariable: 118
indices: 119
117Variable
118Variable
119ExprTuple120, 121
120Operationoperator: 122
operand: 124
121Variable
122Variable
123ExprTuple124
124Variable