• Tidak ada hasil yang ditemukan

Decoding of Two-Deletion Correcting Codes

Chapter II: Binary 2-Deletion/Insertion Correcting Codes

2.5 Decoding of Two-Deletion Correcting Codes

In this section it is shown how to decode Construction2.1.1. Recall the encoding function

E (c) =(c, 𝑓(c), β„Ž(c), π‘Ÿ3(𝑓(𝑓(c), β„Ž(c))), π‘Ÿ3(β„Ž(𝑓(c), β„Ž(c)))), (2.39) with redundancy 𝑓(c), β„Ž(c)of length 𝑁1 β‰œ 7 log𝑛+8 and 3-fold repetition redun- dancyπ‘Ÿ3(𝑓(𝑓(c), β„Ž(c))), π‘Ÿ3(β„Ž(𝑓(c), β„Ž(c)))of length 𝑁2 β‰œ 21 log(7 log𝑛+8) +8.

To conveniently describe the decoding algorithm, two building blocks are needed.

The first is a 3-fold repetition decoding function

D1:{0,1}𝑁2βˆ’2β†’ {0,1}𝑁2/3

that takes a subsequence d1 ∈ {0,1}𝑁2βˆ’2of a 3-fold repetition codeword π‘Ÿ3(s1) ∈ {0,1}𝑁2 for some s1 ∈ {0,1}𝑁2/3 as input, and outputs an estimate ˜s1 of the se- quences1. The second is a decoding function which is defined for every positive

integerπ‘žas follows

D2:{0,1}π‘žβˆ’2Γ— {0,1}7 logπ‘ž+2β†’ {0,1}π‘ž.

The function D2 takes a subsequence d2 ∈ {0,1}π‘žβˆ’2 of some s2 ∈ {0,1}π‘ž, re- dundancy 𝑓(s2), and redundancy β„Ž(s2) as input, and outputs an estimate ˜s2 of the sequence s2. In Algorithm 1, the function D2 is used twice with two different values of π‘ž. As will be shown, the two calls of the function D2 aim to recover the redundancy 𝑓(c)andβ„Ž(c) and the sequencecrespectively.

The 3-fold repetition decoding D1 can be implemented by adding two bits to d1 such that the length of each run is a multiple of 3, which can obviously be done in linear time. According to Theorem2.1.2, there exists a decoding functionD2that recovers the original sequence s2 correctly given its 𝑓(s2) and β„Ž(s2) redundancy.

The linear complexity ofD2will be shown later in this section.

The functions D1 and D2 are used as subroutines to describe the decoding pro- cedure that is given in Algorithm1. First, we use the function D1 to recover the redundancy 𝑓(𝑓(c), β„Ž(c))andβ„Ž(𝑓(c), β„Ž(c))from the 3-fold repetition code. Then, by applyingD2and using the redundancy 𝑓(𝑓(c), β„Ž(c))andβ„Ž(𝑓(c), β„Ž(c)), the 𝑓(c) andβ„Ž(c)can be recovered. Finally and similarly, redundancy 𝑓(c)andβ„Ž(c) can be used to recover the original sequencec, again with the help ofD2.

Algorithm 1: Decoding

Input: A subsequenced ∈ {0,1}π‘βˆ’2ofE (c)for somecin the code.

Output: The sequencec.

layer2_redundancy=D1(d(π‘βˆ’π‘2+1, π‘βˆ’2));

if two deletions are detected byD1then returnd(1,𝑛);

else

𝐿 β‰œ The length of the longest suffix ofdthat is a subsequence ofπ‘Ÿ3(layer2_redundancy);

layer1_redundancy=D2(d(π‘βˆ’π‘1+1βˆ’πΏ , π‘βˆ’2βˆ’πΏ),layer2_redundancy);

c=D2(d(1,π‘›βˆ’2),layer1_redundancy); return c.

Theorem 2.5.1. If the functionsD1andD2provide the correct estimates in𝑂(𝑛) time, then given an 𝑁 βˆ’2 subsequence of E (c), Algorithm 1returns the original sequencecin𝑂(𝑛)time.

Proof. To prove the correctness of Algorithm1, it suffices to show the following

(1). d(π‘βˆ’π‘2+1, π‘βˆ’2) is a length𝑁2βˆ’2 subsequence of the repetition code π‘Ÿ3(𝑓(𝑓(c), β„Ž(c))), π‘Ÿ3(β„Ž(𝑓(c), β„Ž(c)))).

(2). d(π‘βˆ’π‘1+1βˆ’πΏ , π‘βˆ’2βˆ’πΏ)is a length𝑁1βˆ’2 subsequence of the 𝑓(c), β„Ž(c)redundancy.

(3). d(1,π‘›βˆ’2) is a lengthπ‘›βˆ’2 subsequence of the sequencec.

Sincedis a length π‘βˆ’2 subsequence ofE (c), π‘‘π‘›βˆ’2must be either the (π‘›βˆ’2)-th, the (π‘›βˆ’ 1)-th or the 𝑛-th bits of E (c), and hence (3) must hold. Similarly, (1) holds by consideringdandE (c) in reversed order. By the definition of 𝐿, π‘‘π‘βˆ’2βˆ’πΏ is the 𝑖1-th bit of E (c) for some 𝑖1 ≀ 𝑛+ 𝑁1. Since (1) holds, we have that 𝐿 is either 𝑁2, 𝑁2βˆ’ 1, or 𝑁2βˆ’2. Therefore, π‘‘π‘βˆ’π‘

1+1βˆ’πΏ is the𝑖2-th bit of E (c) for some𝑖2 β‰₯ π‘βˆ’π‘1+1βˆ’πΏ > 𝑛. Since(𝑓(c), β„Ž(c)) =E (c)(𝑛+1,𝑛+𝑁1), (2)must hold.

Since finding 𝐿 has𝑂(𝑁2) complexity, the complexity of Algorithm1 is𝑂(𝑁) = 𝑂(𝑛), given that the complexities of the functionsD1andD2are linear. β–‘ It can be verified that Algorithm 1 outputs the original sequence c in the case of a single deletion. One can also use a VT decoder (see [64]), which has a simpler implementation and 𝑂(𝑛) time complexity. We are left to implement D2 with linear complexity. In particular, we need to recover the sequence c ∈ {0,1}𝑛 from its length π‘›βˆ’2 subsequence d in time 𝑂(𝑛), given the redundancies 𝑓(c) and β„Ž(c). Note that there are𝑂(𝑛2) supersequences of dof length𝑛, and 𝑓 and β„Ž can be computed on each of them in𝑂(𝑛). Hence, the brute force approach would require𝑂(𝑛3).

To achieve linear time complexity, we first recover110(c)from an(π‘›βˆ’3)-subsequence 110(d) of 110(c) ∈ {0,1}π‘›βˆ’1, and then use it to recover c. In particular, we first find the positions and values of the deleted bits in110(c) by an iterative updating algorithm, rather than by exhaustive search, and hence linear complexity is ob- tained. Furthermore, the uniqueness of the resulting sequence is guaranteed by Lemma2.2.2. After recovering110(c), We can find all length 𝑛supersequencescβ€² ofd such that110(cβ€²) =110(c). It is shown that there are at most 4 such possible supersequences, and since Theorem2.1.2guarantees uniqueness, the rightcis found by computing and comparing β„Ž(c). Therefore, the decoding can be done in linear time in total.

Recovering110(c). For 1 ≀𝑖 ≀ 2π‘›βˆ’2, let

𝑝𝑖 β‰œ





ο£²



ο£³

π‘›βˆ’π‘– if 1 ≀𝑖 ≀ π‘›βˆ’1 π‘–βˆ’π‘›+1 if𝑛 ≀𝑖 ≀ 2π‘›βˆ’2

, and (2.40)

𝑏𝑖 β‰œ





ο£²



ο£³

0 if 1 ≀𝑖 ≀ π‘›βˆ’1 1 if𝑛 ≀𝑖 ≀ 2π‘›βˆ’2

. (2.41)

For example, when𝑛 =5, we have

(𝑝1, 𝑝2, 𝑝3, 𝑝4, 𝑝5, 𝑝6, 𝑝7, 𝑝8) =(4,3,2,1,1,2,3,4) and (𝑏1, 𝑏2, 𝑏3, 𝑏4, 𝑏5, 𝑏6, 𝑏7, 𝑏8) =(0,0,0,0,1,1,1,1).

Given a subsequence d ∈ {0,1}π‘›βˆ’2 of c, let 110(d) = (π‘Ÿ1, . . . , π‘Ÿπ‘›βˆ’3), and let 𝑀 : {0,1}π‘›βˆ’2Γ— [2π‘›βˆ’2] Γ— [2π‘›βˆ’2] β†’ {0,1}π‘›βˆ’1βˆͺ {β˜…}be defined as

𝑀(d, 𝑖, 𝑗) =

















ο£²















ο£³

(π‘Ÿ1, π‘Ÿ2, . . . , π‘Ÿπ‘

π‘–βˆ’1, 𝑏𝑖, π‘Ÿπ‘

𝑖

, . . . , π‘Ÿπ‘

π‘—βˆ’2, 𝑏𝑗, π‘Ÿπ‘

π‘—βˆ’1, . . . , π‘Ÿπ‘›βˆ’3) if 𝑝𝑖 < 𝑝𝑗,

(π‘Ÿ1, π‘Ÿ2, . . . , π‘Ÿπ‘

π‘—βˆ’1, 𝑏𝑗, π‘Ÿπ‘

𝑗, . . . , π‘Ÿπ‘

π‘–βˆ’2, 𝑏𝑖, π‘Ÿπ‘

π‘–βˆ’1, . . . , π‘Ÿπ‘›βˆ’3) if 𝑝𝑖 > 𝑝𝑗,

β˜…

if 𝑝𝑖 = 𝑝𝑗,

that is, 𝑀(d, 𝑖, 𝑗) results from 110(d) inserting 𝑏𝑖 at position 𝑝𝑖 and 𝑏𝑗 in posi- tion 𝑝𝑗 of 110(d), if 𝑝𝑖 β‰  𝑝𝑗. Notice that 𝑀(d, 𝑖, 𝑗) is one possible candidate for110(c). To illustrate𝑀(d, 𝑖, 𝑗), let us consider again the example where 𝑛 = 5.

Let d ∈ {0,1}π‘›βˆ’2 = (1,0,1), which implies that 110(d) = (1,0). Then, we have that 𝑀(d,2,7) = β˜… since 𝑝2 = 𝑝7 = 3, and that 𝑀(d,2,6) = (1,1,0,0) since 𝑝2 =3, 𝑏2=0, 𝑝6 =2, 𝑏6=1.

For𝑒 ∈ {0,1,2}define (2π‘›βˆ’2) Γ— (2π‘›βˆ’2) integer matrices{𝐴(𝑒)}2

𝑒=0as follows.

𝐴(𝑒)

𝑖, 𝑗 =





ο£²



ο£³

𝑀(d, 𝑖, 𝑗) Β·m(𝑒) βˆ’Γπ‘›βˆ’3 π‘˜=1m(𝑒)

π‘˜ 110(d)π‘˜ if𝑀(d, 𝑖, 𝑗) β‰ β˜….

β˜… if𝑀(d, 𝑖, 𝑗) =β˜….

Notice that𝐴(𝑒)

𝑖, 𝑗 is the difference in the weighted sums of𝑀(d, 𝑖, 𝑗)and110(d), with weightsm(𝑒). We now show that the entry of 𝐴(𝑒) that we are looking for is equal modulo𝑛𝑒 to the difference in entry𝑒 of the 𝑓 redundancies ofcand ofd. That is, 𝐴(

𝑒)

𝑖, 𝑗 ≑ (𝑓(c)π‘’βˆ’ 𝑓(d)𝑒)mod𝑛𝑒. On the one hand, since110(c)is obtained after two insertions in110(d), it follows that there exists (𝑖, 𝑗) such that 𝑀(d, 𝑖, 𝑗) = 110(c) and that 𝐴(𝑒)

𝑖, 𝑗 ≑ (𝑓(c)𝑒 βˆ’ 𝑓(d)𝑒) mod𝑛𝑒 for every 𝑒 ∈ {0,1,2}. On the other hand, by Lemma 2.2.2, it follows that this (𝑖, 𝑗) pair is unique, given that the sequence𝑀(d, 𝑖, 𝑗)does not contain consecutive 1’s. Hence, since𝑀(d, 𝑖, 𝑗)which contain consecutive 1’s are skipped in our algorithm (see Algorithm2in the sequel), it follows that𝑀(d, 𝑖, , 𝑗) =110(c).

We prove the following properties of 𝐴(𝑒). In the first property, we give an explicit expression for an entry 𝐴(𝑒)

𝑖, 𝑗 in terms of110(d), 𝑝𝑖, 𝑝𝑗, 𝑏𝑖, and 𝑏𝑗. This expression will be used for calculating 𝐴(

𝑒)

𝑖, 𝑗 in constant time from its neighboring entries during D2. In the following we use 𝛿(π‘₯) to denote the Boolean indicator of an eventπ‘₯, where𝛿(π‘₯) =1 if and only ifπ‘₯is true.

Proposition 2.5.1. If𝐴(𝑒)

𝑖, 𝑗 β‰ β˜…then 𝐴(𝑒)

𝑖, 𝑗 =𝑏𝑖m(𝑒)𝑝𝑖 +𝑏𝑗m(𝑒)𝑝𝑗+

π‘›βˆ’3

βˆ‘οΈ

π‘˜=1

110(d)π‘˜[(π‘˜+1)𝑒𝛿(min{𝑝𝑖, 𝑝𝑗} < π‘˜+1)+

(π‘˜+2)𝑒𝛿(max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2)]. (2.42) Proof. The difference between Γπ‘›βˆ’3

π‘˜=1m(π‘˜π‘’)110(d)π‘˜ and 𝑀(d, 𝑖, 𝑗) Β·m(𝑒) consists of two parts. The first part follows from the two inserted bits, and can be written as

𝑏𝑖m(𝑒)𝑝𝑖 +𝑏𝑗m(𝑒)𝑝𝑗 . (2.43) The second part follows from the shift of bits in 110(d)π‘˜ that is caused by the insertions of two bits𝑏𝑖and𝑏𝑗. Each bit110(d)π‘˜shifts from positionπ‘˜to positionπ‘˜+ 1 if one insertion occurs before110(d)π‘˜, i.e., min{𝑝𝑖, 𝑝𝑗} < π‘˜+1 and max{𝑝𝑖, 𝑝𝑗} β‰₯ π‘˜+2. The resulting difference is given by

π‘›βˆ’3

βˆ‘οΈ

π‘˜=1

110(d)π‘˜π›Ώ(min{𝑝𝑖, 𝑝𝑗} < π‘˜ +1)Β·

𝛿(max{𝑝𝑖, 𝑝𝑗} β‰₯ π‘˜+2) (m(π‘˜π‘’)+1βˆ’m(𝑒)π‘˜ )

=

π‘›βˆ’3

βˆ‘οΈ

π‘˜=1

110(d)π‘˜π›Ώ(min{𝑝𝑖, 𝑝𝑗} < π‘˜ +1)Β·

𝛿(max{𝑝𝑖, 𝑝𝑗} β‰₯ π‘˜+2) (π‘˜+1)𝑒. (2.44) The bit110(d)π‘˜shifts from positionπ‘˜toπ‘˜+2 if two insertions occur before110(d)π‘˜, i.e., max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2. The corresponding difference is given by

π‘›βˆ’3

βˆ‘οΈ

π‘˜=1

110(d)π‘˜π›Ώ(min{𝑝𝑖, 𝑝𝑗} < π‘˜ +1)Β·

𝛿(max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2)110(d)π‘˜(m(π‘˜+2𝑒) βˆ’m(𝑒)

π‘˜ )

=

π‘›βˆ’3

βˆ‘οΈ

π‘˜=1

110(d)π‘˜π›Ώ(max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2) [(π‘˜ +1)𝑒+ (π‘˜ +2)𝑒]. (2.45) Combining (2.44) and (2.45), we have that the difference that results from the second part is given by

π‘›βˆ’3

βˆ‘οΈ

π‘˜=1

110(d)π‘˜[(π‘˜+1)𝑒𝛿(min{𝑝𝑖, 𝑝𝑗} < π‘˜ +1)+

(π‘˜+2)𝑒𝛿(max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2)],

that together with (2.43), implies (2.42). β–‘

The following shows that the entries of each 𝐴(𝑒) are non-decreasing in rows and columns, and that the respective sequences𝑀(d, 𝑖, 𝑗)that lie in the same column or the same row, are unique given each entry value. This property guarantees a simple algorithm for finding a sequence𝑀(d, 𝑖, 𝑗) with a given value 𝐴(

𝑒)

𝑖, 𝑗 by decreasing𝑖 or increasing 𝑗 by 1 in each step.

Proposition 2.5.2. For every𝑖, 𝑗and𝑖1 < 𝑖2, 𝑗1 < 𝑗2, if neither ofd(𝑖1, 𝑗),d(𝑖2, 𝑗), d(𝑖, 𝑗1), and d(𝑖, 𝑗2) equals β˜…, then 𝐴(

𝑒)

𝑖1, 𝑗 ≀ 𝐴(

𝑒)

𝑖2, 𝑗 and 𝐴(

𝑒) 𝑖, 𝑗1 ≀ 𝐴(

𝑒)

𝑖, 𝑗2. Moreover, if𝐴(𝑒)

𝑖1, 𝑗 = 𝐴(𝑒)

𝑖2, 𝑗 (resp.𝐴(𝑒)

𝑖, 𝑗1 = 𝐴(𝑒)

𝑖, 𝑗2), thend(𝑖1, 𝑗) =d(𝑖2, 𝑗)(resp.d(𝑖, 𝑗1)=d(𝑖, 𝑗2)).

Proof. By symmetry we only need to prove that the matrix 𝐴(𝑒) is non-decreasing in each column, for which it suffices to prove that:

(1). 𝐴(𝑒)

𝑖1, 𝑗 ≀ 𝐴(𝑒)

𝑖2, 𝑗 for 1≀ 𝑖1 < 𝑖2 ≀ π‘›βˆ’1.

(2). 𝐴(𝑒)

π‘›βˆ’1, 𝑗 ≀ 𝐴(𝑒)

𝑛, 𝑗. (3). 𝐴(

𝑒) 𝑖1, 𝑗 ≀ 𝐴(

𝑒)

𝑖2, 𝑗 for𝑛 ≀𝑖1< 𝑖2 ≀ 2π‘›βˆ’2.

For(2), the only difference betweend(π‘›βˆ’1, 𝑗)andd(𝑛, 𝑗)is that their first bits are 0 and 1 respectively, and hence 𝐴(

𝑒)

π‘›βˆ’1, 𝑗 +1= 𝐴(

𝑒)

𝑛, 𝑗. We are left to show(1) and(3). (1): For 1 ≀ 𝑖1 < 𝑖2 ≀ π‘›βˆ’1, we have 𝑏𝑖

1 = 𝑏𝑖

2 =0 and 𝑝𝑖

1 > 𝑝𝑖

2. Letdβ€²(𝑖1, 𝑗) ∈ {0,1}π‘›βˆ’2anddβ€²(𝑖2, 𝑗) ∈ {0,1}π‘›βˆ’2be two subsequences ofd(𝑖1, 𝑗) andd(𝑖2, 𝑗), re- spectively, after deleting the𝑝𝑗-th bit from bothd(𝑖1, 𝑗) andd(𝑖2, 𝑗), and similarly, let m(𝑒), 𝑝𝑗 = (m1(𝑒),m2(𝑒), . . . ,m(𝑝𝑒)

π‘—βˆ’1,m(𝑝𝑒)

𝑗+1, . . . ,mπ‘›βˆ’1(𝑒) ) be a subsequence of m(𝑒) after deleting the 𝑝𝑗-th entry. Since dβ€²(𝑖1, 𝑗) ∈ 𝐡1(dβ€²(𝑖2, 𝑗)), the remaining argu- ments follow those in the proof of Proposition2.1.1. According to (2.6) and (2.7), we have that

𝐴(

𝑒) 𝑖2, 𝑗 βˆ’ 𝐴(

𝑒)

𝑖1, 𝑗 =d(𝑖2, 𝑗) Β·m(𝑒) βˆ’d(𝑖1, 𝑗) Β·m(𝑒)

=dβ€²(𝑖2, 𝑗) Β·m(𝑒), 𝑝𝑗 βˆ’dβ€²(𝑖1, 𝑗) Β·m(𝑒), 𝑝𝑗

=𝑔(π‘˜1,dβ€²(𝑖2, 𝑗)(π‘˜1, π‘˜2),dβ€²(𝑖1, 𝑗)π‘˜2)

β‰₯ 0, (2.46)

whereπ‘˜1 =𝑝𝑖

2βˆ’π›Ώ(𝑝𝑖

2 > 𝑝𝑗)andπ‘˜2= 𝑝𝑖

1βˆ’π›Ώ(𝑝𝑖

1 > 𝑝𝑗)are the indices whose dele- tion fromdβ€²(𝑖2, 𝑗) anddβ€²(𝑖1, 𝑗), respectively, results in110(d). Similarly, as in the proof in Proposition2.1.2, the last inequality follows from the fact thatdβ€²(𝑖1, 𝑗)π‘˜2 = 𝑏𝑖

1 =0. Furthermore, equality holds when dβ€²(𝑖2, 𝑗)(π‘˜1, π‘˜2) = 0 and dβ€²(𝑖1, 𝑗)π‘˜2 = 0, which implies thatdβ€²(𝑖1, 𝑗) =dβ€²(𝑖2, 𝑗), and henced(𝑖1, 𝑗) =d(𝑖2, 𝑗).

(3): For 𝑛 ≀ 𝑖1 < 𝑖2 ≀ 2π‘›βˆ’2, we have 𝑏𝑖

1 = 𝑏𝑖

2 = 1 and 𝑝𝑖

1 < 𝑝𝑖

2. Similar to (2.46), we have that

𝐴(𝑒)

𝑖1, 𝑗 βˆ’π΄(𝑒)

𝑖2, 𝑗 =𝑔(π‘˜1,dβ€²(𝑖1, 𝑗)(π‘˜1, π‘˜2),dβ€²(𝑖2, 𝑗)π‘˜2) ≀0, where π‘˜1 = 𝑝𝑖

1 βˆ’π›Ώ(𝑝𝑖

1 > 𝑝𝑗) and π‘˜2 = 𝑝𝑖

2 βˆ’π›Ώ(𝑝𝑖

2 > 𝑝𝑗) are the indices whose deletion from dβ€²(𝑖1, 𝑗) and dβ€²(𝑖2, 𝑗), respectively, results in 110(d). The last in- equality follows from the fact that dβ€²(𝑖2, 𝑗)π‘˜2 = 𝑏𝑖

2 = 1, and equality holds

whend(𝑖1, 𝑗) =d(𝑖2, 𝑗). β–‘

Remark 2.5.1. From Proposition2.5.2, we have that 0= 𝐴(𝑒)

1,2 ≀ 𝐴(𝑒)

𝑖, 𝑗 ≀ 𝐴(𝑒)

2π‘›βˆ’2,2π‘›βˆ’3 ≀m𝑛(𝑒)βˆ’1+m𝑛(𝑒)βˆ’2 ≀ 𝑛𝑒 for1≀ 𝑖, 𝑗 ≀ 2π‘›βˆ’2, 𝐴(𝑒)

𝑖, 𝑗 β‰ β˜…, where𝑛0=2𝑛, 𝑛1 =𝑛2, 𝑛2 =𝑛3. Recall that our goal is to find a sequence𝑀(d, 𝑖, 𝑗) β‰ β˜…for which

𝐴(

𝑒)

𝑖, 𝑗 ≑ 𝑓(c)π‘’βˆ’

π‘›βˆ’3

βˆ‘οΈ

𝑖=π‘˜

m(π‘˜π‘’)110(d)π‘˜ mod𝑛𝑒 (2.47)

*

*

*

*

*

*

*

*

*

*

10 10

10

10 10

* 10

10

10

11 11 11 12 11 12 13 13 11 12 12 13 14 11

9 9 9

9 8 8 8

9 9 7 7 8

8 9

0

1 9

9

2π‘›βˆ’2 2π‘›βˆ’3 2π‘›βˆ’4 2π‘›βˆ’5 2π‘›βˆ’6 2π‘›βˆ’7

2 𝑖 =1

𝑗 =1 2 3 4 5 6 7 2π‘›βˆ’2

...

...

Figure 2.5: The path of Algorithm2on the matrix 𝐴(0).

for every 𝑒 ∈ {0,1,2}. In addition, the sequence 𝑀(d, 𝑖, 𝑗) cannot contain adja- cent 1’s, i.e.,

𝑀(d, 𝑖, 𝑗)π‘π‘–βˆ’1·𝑀(d, 𝑖, 𝑗)𝑝𝑖 =𝑀(d, 𝑖, 𝑗)𝑝𝑖 ·𝑀(d, 𝑖, 𝑗)𝑝𝑖+1 =0

𝑀(d, 𝑖, 𝑗)π‘π‘—βˆ’1·𝑀(d, 𝑖, 𝑗)𝑝𝑗 =𝑀(d, 𝑖, 𝑗)𝑝𝑗 ·𝑀(d, 𝑖, 𝑗)𝑝𝑗+1=0, (2.48) and from Lemma2.2.2, such𝑀(d, 𝑖, 𝑗)equals110(c). Moreover, since Remark2.5.1 implies that 0 ≀ 𝐴(𝑒)

𝑖, 𝑗 ≀ 𝑛𝑒, it follows that the modular equality in (2.47) is unnec- essary, i.e., it suffices to find a sequence𝑀(d, 𝑖, 𝑗) β‰ β˜…that satisfies (2.48) and

𝐴(𝑒)

𝑖, 𝑗 =π‘Žπ‘’ β‰œ 𝑓𝑒(c) βˆ’

π‘›βˆ’3

βˆ‘οΈ

π‘˜=1

m(𝑒)π‘˜ 110(d)π‘˜ mod𝑛𝑒, (2.49) where π‘Žπ‘’ is the target value to be found in matrix 𝐴(𝑒). Eq. (2.49) implies that𝑀(d, 𝑖, 𝑗)satisfies the 𝑓 redundancy.

The procedure to find such 𝑀(d, 𝑖, 𝑗) is given in Algorithm 2. We search for all sequences 𝑀(d, 𝑖, 𝑗) β‰  β˜… with no adjacent 1’s (2.48) such that 𝐴(0)

𝑖, 𝑗 = π‘Ž0. This clearly amounts to a binary search in a sorted matrix3. We start from the bottom left

3The twoβ˜…entries in each row or column can simply be skipped.

corner of the matrix, proceed to the right in each step until reaching the rightmost entry such that𝐴(0)

𝑖, 𝑗 ≀ π‘Ž0, and then go one step up. Figure2.5illustrates an example of how Algorithm2runs on matrix 𝐴(0).

To avoid the computation of the entire matrix, that would require𝑂(𝑛2)time, each entry is computed from previously seen onesonlyupon its discovery. To this end we prove the following lemma, that alongside Proposition2.5.1, provides a way of computing a newly discovered entry.

Proposition 2.5.3. Whenever the (𝑖, 𝑗)-th and (𝑖+1, 𝑗)-th (resp. (𝑖, 𝑗+1)) entries of 𝐴(𝑒) are notβ˜…, we have that

𝐴(

𝑒) 𝑖, 𝑗 βˆ’ 𝐴(

𝑒) 𝑖+1, 𝑗

=𝑏𝑖m(𝑒)𝑝𝑖 βˆ’π‘π‘–+1m(𝑒)𝑝𝑖+1+

min{𝑝1, 𝑝𝑖+1}

βˆ‘οΈ

π‘˜=min{𝑝𝑖, 𝑝𝑖+1}βˆ’1

110(d)π‘˜[(π‘˜+1)𝑒(𝛿(min{𝑝𝑖, 𝑝𝑗} < π‘˜ +1)

βˆ’π›Ώ(min{𝑝𝑖+1, 𝑝𝑗} < π‘˜ +1))+

(π‘˜+2)𝑒(𝛿(max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2)βˆ’

𝛿(max{𝑝𝑖+1, 𝑝𝑗} < π‘˜ +2))], and (2.50) 𝐴(𝑒)

𝑖, 𝑗 βˆ’ 𝐴(𝑒)

𝑖, 𝑗+1

=𝑏𝑗m(𝑒)𝑝𝑗 βˆ’π‘π‘—+1m(𝑒)𝑝𝑗+1+

min{𝑝𝑗, 𝑝𝑗+1}

βˆ‘οΈ

π‘˜=min{𝑝𝑗, 𝑝𝑗+1}βˆ’1

110(d)π‘˜[(π‘˜+1)𝑒(𝛿(min{𝑝𝑖, 𝑝𝑗} < π‘˜ +1)

βˆ’π›Ώ(min{𝑝𝑖, 𝑝𝑗+1} < π‘˜ +1))+

(π‘˜+2)𝑒(𝛿(max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2)βˆ’

𝛿(max{𝑝𝑖, 𝑝𝑗+1} < π‘˜ +2))]. (2.51)

Proof. Note that if𝑖 increases by 1 or if 𝑗 decreases by 1, then 𝑝𝑖 or𝑝𝑗 changes by at most 1 (See (2.40)). Hence,

𝛿(min{𝑝𝑖, 𝑝𝑗} < π‘˜ +1) =𝛿(min{𝑝𝑖+1, 𝑝𝑗} < π‘˜+1), 𝛿(max{𝑝𝑖, 𝑝𝑗} < π‘˜ +2) =𝛿(max{𝑝𝑖+1, 𝑝𝑗} < π‘˜+2)

forπ‘˜ ≀ min{𝑝𝑗, 𝑝𝑖+1} βˆ’2 andπ‘˜ β‰₯ min{𝑝𝑖, 𝑝𝑖+1} +1. According to (2.42), we have that (2.50) holds, and similarly, (2.51) holds as well. β–‘

Algorithm 2: Finding110(c).

Input: Subsequenced∈ {0,1}π‘›βˆ’2ofc, and 𝑓(c) Output: 𝑖and 𝑗 such that𝑀(d, 𝑖, 𝑗) =110(c) Initialization: 𝑖=2π‘›βˆ’2, 𝑗 =1;

π‘₯𝑒 = 𝐴(

𝑒)

1,2π‘›βˆ’2for𝑒 ∈ {0,1,2};

π‘Žπ‘’ = 𝑓𝑒(c) βˆ’Γπ‘›βˆ’3

π‘˜=1mπ‘˜(𝑒)110(d)π‘˜ mod𝑛𝑒for𝑒 ∈ {0,1,2}; while 𝑖 β‰₯ 0do

ifπ‘₯𝑒 =π‘Žπ‘’for every𝑒 ∈ {0,1,2}and𝑀(d, 𝑖, 𝑗) β‰ β˜…and𝑀(d, 𝑖, 𝑗) has no adjacent1’s (𝑀(d, 𝑖, 𝑗) satisfies(2.48))then

return𝑖, 𝑗; else

Find the maximum 𝑗 for which 𝐴(0)

𝑖, 𝑗 ≀ π‘Ž0. if 𝑝𝑖 = 𝑝𝑗 or (π‘₯0 > π‘Ž0)then

𝑑 π‘’π‘š 𝑝_π‘₯𝑒 =π‘₯𝑒+ 𝐴(𝑒)

𝑖, π‘—βˆ’1βˆ’π΄(𝑒)

𝑖, 𝑗 (using (2.51)), for𝑒 ∈ {0,1,2};

𝑑 π‘’π‘š 𝑝_𝑗 = 𝑗 βˆ’1;

while 𝑝𝑑 π‘’π‘š 𝑝_𝑗 =𝑝𝑖do 𝑑 π‘’π‘š 𝑝_π‘₯𝑒 =π‘₯𝑒+ 𝐴(𝑒)

𝑖,𝑑 π‘’π‘š 𝑝_π‘—βˆ’1βˆ’ 𝐴(𝑒)

𝑖,𝑑 π‘’π‘š 𝑝_𝑗 (using (2.51)) for𝑒 ∈ {0,1,2};

𝑑 π‘’π‘š 𝑝_𝑗 =𝑑 π‘’π‘š 𝑝_𝑗 βˆ’1;

if𝑑 π‘’π‘š 𝑝_𝑗 β‰₯ 1then 𝑗 =𝑑 π‘’π‘š 𝑝_𝑗;

π‘₯𝑒 =𝑑 π‘’π‘š 𝑝_π‘₯𝑒 for𝑒 ∈ {0,1,2,}; else

𝑑 π‘’π‘š 𝑝_π‘₯𝑒 =π‘₯𝑒+ 𝐴(𝑒)

𝑖, 𝑗+1βˆ’π΄(𝑒)

𝑖, 𝑗 (using (2.51)), for𝑒 ∈ {0,1,2};

𝑑 π‘’π‘š 𝑝_𝑗 = 𝑗 +1;

while 𝑝𝑑 π‘’π‘š 𝑝_𝑗 =𝑝𝑖do 𝑑 π‘’π‘š 𝑝_π‘₯𝑒 =π‘₯𝑒+ 𝐴(

𝑒)

𝑖,𝑑 π‘’π‘š 𝑝_𝑗+1βˆ’ 𝐴(

𝑒)

𝑖,𝑑 π‘’π‘š 𝑝_𝑗 (using (2.51)) for𝑒 ∈ {0,1,2};

𝑑 π‘’π‘š 𝑝_𝑗 =𝑑 π‘’π‘š 𝑝_𝑗 +1;

if𝑑 π‘’π‘š 𝑝_π‘₯0 ≀ π‘Ž0then 𝑗 =𝑑 π‘’π‘š 𝑝_𝑗;

π‘₯𝑒 =𝑑 π‘’π‘š 𝑝_π‘₯𝑒 for𝑒 ∈ {0,1,2,};

else

π‘₯𝑒 =π‘₯𝑒+𝐴(𝑒)

π‘–βˆ’1, 𝑗 βˆ’ 𝐴(𝑒)

𝑖, 𝑗 (using (2.50));

𝑖 =π‘–βˆ’1;

return (0,0);

We first show that Algorithm2outputs the (𝑖, 𝑗)pair such that𝑀(d, 𝑖, 𝑗) =110(c). Note that by Lemma 2.2.2 there exists a unique sequence 𝑀(d, 𝑖, 𝑗) = 110(c) for which𝑀(d, 𝑖, 𝑗) satisfies Eq. (2.48) and for which (𝑖, 𝑗) satisfies Eq. (2.49). Since the algorithm terminates either when such a sequence 𝑀(d, 𝑖, 𝑗) =110(c) is found or no such sequence is found and𝑖reaches 0, it suffices to show that the latter case does not occur. We prove this by contradiction. Assuming that the latter case occurs, we show that𝑀(d, 𝑖, 𝑗) β‰  110(c) for all (𝑖, 𝑗) pairs, which is a contradiction. For each 𝑖 ∈ {1,2, . . . ,2π‘›βˆ’ 2}, let 𝑗𝑖 be the maximum 𝑗 = 𝑗𝑖 for which 𝐴(0)

𝑖, 𝑗𝑖 ≀ π‘Ž0. If𝐴(0)

𝑖, 𝑗 > π‘Ž0for some𝑖and for all 𝑗, then 𝑗𝑖 =1. Note that each pair(𝑖, 𝑗𝑖)is visited in Algorithm2and by assumption we have thatd(𝑖, 𝑗𝑖) β‰  110(c). We consider the following two cases

(1). 𝑗 > 𝑗𝑖, (2). 𝑗 < 𝑗𝑖

and conclude that no (𝑖, 𝑗) pair in these cases result in 𝑀(d, 𝑖, 𝑗) = 110(c). For 𝑗 > 𝑗𝑖, by Proposition 2.5.2 we have that 𝐴(0)

𝑖, 𝑗 β‰₯ 𝐴(0)

𝑖, 𝑗𝑖 or that 𝑀(d, 𝑖, 𝑗) = β˜…. Hence by definition of 𝑗𝑖 we have that 𝐴(0)

𝑖, 𝑗 > π‘Ž0 or that 𝑀(d, 𝑖, 𝑗) = β˜…, and hence𝑀(d, 𝑖, 𝑗) β‰ 110(c). For 𝑗 < 𝑗𝑖, by Proposition2.5.2we have that𝐴(0)

𝑖, 𝑗 ≀ 𝐴(0)

𝑖, 𝑗𝑖

or that𝑀(d, 𝑖, 𝑗) =β˜…. If 𝐴(0)

𝑖, 𝑗 < 𝐴(0)

𝑖, 𝑗𝑖, then𝐴(0)

𝑖, 𝑗 β‰ π‘Ž0. If𝐴(0)

𝑖, 𝑗 = 𝐴(0)

𝑖, 𝑗𝑖, then according to Proposition2.5.2, we have that𝑀(d, 𝑖, 𝑗) =d(𝑖, 𝑗𝑖)β‰  110(c).

We now show that Algorithm2 terminates in𝑂(𝑛) time. From (2.50) and (2.51) the (𝑖, 𝑗)-th entry of 𝐴(𝑒), 𝑒 ∈ {0,1,2}, can be computed by using the update rule π‘₯𝑒+𝐴(

𝑒) π‘–βˆ’1, 𝑗 βˆ’π΄(

𝑒)

𝑖, 𝑗 andπ‘₯𝑒+𝐴(

𝑒) 𝑖, 𝑗±1βˆ’ 𝐴(

𝑒)

𝑖, 𝑗 (see Algorithm2), that can be computed in constant time. In addition, one can verify in constant time that (2.48) holds.

Note that in each round, either 𝑖 decreases by 1 or 𝑗 increases by 1, with the exception that 𝑗 decreases by 1 every time when 𝐴(0)

𝑖, 𝑗 =β˜…or 𝐴(0)

𝑖, 𝑗 > π‘Ž0. We prove by contradiction that the latter case, in which 𝐴(0)

𝑖, 𝑗 > π‘Ž0 and 𝑗 > 1 is impossible.

Notice that for each current pair(𝑖, 𝑗), the value of next pair (π‘–βˆ—, π‘—βˆ—)falls into either one of the following three case:

(1). (π‘–βˆ—, π‘—βˆ—) = (𝑖, 𝑗′)for some 𝑗′> 𝑗 with𝐴(0)

π‘–βˆ—, π‘—βˆ— ≀ π‘Ž0, (2). (π‘–βˆ—, π‘—βˆ—) = (π‘–βˆ’1, 𝑗),

(3). (π‘–βˆ—, π‘—βˆ—) = (π‘–βˆ’1, 𝑗′) for some 𝑗′< 𝑗 when 𝐴(0)

π‘–βˆ’1, 𝑗 =β˜….

Assume by contradiction that 𝐴(0)

π‘–βˆ—, π‘—βˆ— > π‘Ž0and π‘—βˆ— > 1, and (π‘–βˆ—, π‘—βˆ—) is the first visited pair for which this statement is true. In Case (1), we have that 𝐴(0)

π‘–βˆ—, π‘—βˆ— ≀ π‘Ž0, in contradiction to 𝐴(0)

π‘–βˆ—, π‘—βˆ— > π‘Ž0. In Case (2) or Case (3), Proposition 2.5.2 implies thatπ‘Ž0 < 𝐴(0)

π‘–βˆ—, π‘—βˆ— ≀ 𝐴(0)

𝑖, 𝑗 , contradicting the assumption that (π‘–βˆ—, π‘—βˆ—) is the first visited pair which satisfies 𝐴(0)

π‘–βˆ—, π‘—βˆ— > π‘Ž0. Having proved that 𝐴(0)

𝑖, 𝑗 ≀ π‘Ž0whenever 𝑗 > 1, we have the Algorithm2proceeds to the left only when it encounters a β˜…-entry. We now show that the algorithm terminates in 𝑂(𝑛) time. Notice that unless Algorithm 2encounters a β˜…-entry, it proceeds either up or to the right, for which case, it is clear that only𝑂(𝑛)many steps occur. In cases where Algorithm2encounters aβ˜…-entry, it proceeds to theleftuntil a nonβ˜…-entry is found. Then, thisβ˜…-entry will not be visited again, because in the next step, it either goes up from the nonβ˜…-entry or goes to the right of theβ˜…-entry.

Since the number ofβ˜…-entries is 4π‘›βˆ’4, the number of left strides of the algorithm is at most this quantity, and therefore the algorithm terminates in at most𝑂(𝑛)time.

In the following, we provide a running example of Algorithm2.

Example 2.5.1. Consider a sequencec = (1,1,0,0,1,0,1,0), where the first and the 6-th bits are deleted, resulting in d = (1,0,0,1,1,0). Then 𝑛 = 8, 110(c) = (0,1,0,0,1,0,1), 𝑓(c) = (14,46,200), and 110(d) = (1,0,0,0,1). Hence π‘Ž0 = 8, π‘Ž1 =30, π‘Ž2=144.

Then, Algorithm2proceeds in the following manner. The underlined bits denote the inserted bits to110(d).

𝑖=1, 𝑗 =14, 𝑝𝑖 = 𝑝𝑗, π‘₯0 =7, π‘₯1=28, π‘₯2=140

→𝑖=2, 𝑗 =14, 𝑀(d, 𝑖, 𝑗) =(1,0,0,0,1,0,1), π‘₯0=7, π‘₯1=28, π‘₯2=140

→𝑖=3, 𝑗 =14, 𝑀(d, 𝑖, 𝑗) =(1,0,0,0,0,1,1), π‘₯0=8, π‘₯1=34, π‘₯2=176,

→𝑖=4, 𝑗 =14, 𝑀(d, 𝑖, 𝑗) =(1,0,0,0,0,1,1), π‘₯0=8, π‘₯1=34, π‘₯2=176,

→𝑖=5, 𝑗 =14, 𝑀(d, 𝑖, 𝑗) =(1,0,0,0,0,1,1), π‘₯0=8, π‘₯1=34, π‘₯2=176,

→𝑖=6, 𝑗 =14, 𝑀(d, 𝑖, 𝑗) =(1,0,0,0,0,1,1), π‘₯0=8, π‘₯1=34, π‘₯2=176,

→𝑖=7, 𝑗 =14, 𝑀(d, 𝑖, 𝑗) =(0,1,0,0,0,1,1), π‘₯0=9, π‘₯1=36, π‘₯2=180

→𝑖=7, 𝑗 =13, 𝑀(d, 𝑖, 𝑗) =(0,1,0,0,0,1,1), π‘₯0=9, π‘₯1=36, π‘₯2=180

→𝑖=7, 𝑗 =12, 𝑀(d, 𝑖, 𝑗) =(0,1,0,0,1,0,1), π‘₯0=8, π‘₯1=30, π‘₯2=144

Recover the original sequence c

Let (𝑖, 𝑗) be the output of Algorithm2, for which we have that𝑀(d, 𝑖, 𝑗) =110(c).

Letcβ€²be a length𝑛supersequence after two insertions todsuch that110(cβ€²) =110(c).

If 𝑏𝑖 = 1, then inserting 𝑏𝑖 to 110(d) corresponds to either inserting a 0 to d as the𝑝𝑖+1-th bit incβ€²or inserting a 1 todas the𝑝𝑖-th bit incβ€²(see Table2.1). If𝑏𝑖 =0, then inserting𝑏𝑖 to110(d) corresponds to inserting a 0 or 1 in the first 0 run or 1 run respectively after theπ‘˜β€²-th bit incβ€², where π‘˜β€² =maxπ‘˜{𝑀(d, 𝑖, 𝑗)π‘˜ = 1, π‘˜ < 𝑝𝑖} is the index of the last 10-pattern that occurs before the 𝑝𝑖-th bit in cβ€². The same arguments hold for the insertion of𝑏𝑗.

Therefore, given the (𝑖, 𝑗) pair that Algorithm 2 returns, there are at most four possible cβ€² supersequences of d such that 110(cβ€²) = 110(c). One can check if thecβ€²sequences satisfy β„Ž(c). According to Theorem2.1.2, there is a unique such sequence, the original sequencecthat satisfies both 𝑓(c)andβ„Ž(c)simultaneously.