logo

Expression of type Conditional

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, Function, 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 = 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\{\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..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 17
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8, 9
6Lambdaparameter: 119
body: 10
7Operationoperator: 19
operands: 11
8Operationoperator: 19
operands: 12
9Operationoperator: 19
operands: 13
10Conditionalvalue: 14
condition: 15
11ExprTuple85, 16
12ExprTuple69, 16
13ExprTuple71, 16
14Operationoperator: 17
operand: 21
15Operationoperator: 19
operands: 20
16Literal
17Literal
18ExprTuple21
19Literal
20ExprTuple119, 22
21Lambdaparameters: 23
body: 24
22Operationoperator: 25
operand: 33
23ExprTuple27, 28, 29, 30
24Operationoperator: 31
operands: 32
25Literal
26ExprTuple33
27ExprRangelambda_map: 34
start_index: 84
end_index: 85
28ExprRangelambda_map: 35
start_index: 84
end_index: 85
29ExprRangelambda_map: 36
start_index: 84
end_index: 85
30ExprRangelambda_map: 37
start_index: 84
end_index: 85
31Literal
32ExprTuple38, 39
33Operationoperator: 40
operands: 41
34Lambdaparameter: 121
body: 42
35Lambdaparameter: 121
body: 43
36Lambdaparameter: 121
body: 44
37Lambdaparameter: 121
body: 45
38Operationoperator: 47
operands: 46
39Operationoperator: 47
operands: 48
40Literal
41ExprTuple84, 85
42ExprRangelambda_map: 49
start_index: 84
end_index: 69
43ExprRangelambda_map: 50
start_index: 84
end_index: 69
44ExprRangelambda_map: 51
start_index: 84
end_index: 71
45ExprRangelambda_map: 52
start_index: 84
end_index: 71
46ExprTuple53, 54
47Literal
48ExprTuple55, 56
49Lambdaparameter: 118
body: 96
50Lambdaparameter: 118
body: 97
51Lambdaparameter: 118
body: 98
52Lambdaparameter: 118
body: 99
53Operationoperator: 60
operands: 57
54Operationoperator: 60
operands: 58
55Operationoperator: 60
operands: 59
56Operationoperator: 60
operands: 61
57ExprTuple62
58ExprTuple63
59ExprTuple64
60Literal
61ExprTuple65
62ExprRangelambda_map: 66
start_index: 84
end_index: 69
63ExprRangelambda_map: 67
start_index: 84
end_index: 71
64ExprRangelambda_map: 68
start_index: 84
end_index: 69
65ExprRangelambda_map: 70
start_index: 84
end_index: 71
66Lambdaparameter: 121
body: 72
67Lambdaparameter: 121
body: 73
68Lambdaparameter: 121
body: 74
69Variable
70Lambdaparameter: 121
body: 75
71Variable
72ExprTuple76
73ExprTuple77
74ExprTuple78
75ExprTuple79
76ExprRangelambda_map: 80
start_index: 84
end_index: 85
77ExprRangelambda_map: 81
start_index: 84
end_index: 85
78ExprRangelambda_map: 82
start_index: 84
end_index: 85
79ExprRangelambda_map: 83
start_index: 84
end_index: 85
80Lambdaparameter: 118
body: 86
81Lambdaparameter: 118
body: 87
82Lambdaparameter: 118
body: 88
83Lambdaparameter: 118
body: 90
84Literal
85Variable
86Operationoperator: 94
operands: 91
87Operationoperator: 94
operands: 92
88Operationoperator: 94
operands: 93
89ExprTuple118
90Operationoperator: 94
operands: 95
91NamedExprselement: 96
targets: 97
92NamedExprselement: 98
targets: 99
93NamedExprselement: 100
targets: 101
94Literal
95NamedExprselement: 102
targets: 103
96IndexedVarvariable: 105
indices: 104
97IndexedVarvariable: 114
indices: 104
98IndexedVarvariable: 107
indices: 104
99IndexedVarvariable: 115
indices: 104
100IndexedVarvariable: 105
indices: 116
101Operationoperator: 108
operand: 110
102IndexedVarvariable: 107
indices: 116
103Operationoperator: 108
operand: 113
104ExprTuple121, 118
105Variable
106ExprTuple110
107Variable
108Operationoperator: 111
operand: 119
109ExprTuple113
110IndexedVarvariable: 114
indices: 116
111Literal
112ExprTuple119
113IndexedVarvariable: 115
indices: 116
114Variable
115Variable
116ExprTuple117, 118
117Operationoperator: 119
operand: 121
118Variable
119Variable
120ExprTuple121
121Variable