23.11.2013 Views

Obfuscation of Abstract Data-Types - Rowan

Obfuscation of Abstract Data-Types - Rowan

Obfuscation of Abstract Data-Types - Rowan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4. SPLITTING HEADACHES 69<br />

4.2.1 Array-Split properties<br />

In Section 4.1.3 we defined two splits: asp and b(k). Can these be used for<br />

arrays? Yes, in fact, we can use exactly the same definitions as before and the<br />

alternating split matches the array-split defined in Equation (1.4).<br />

When using an array, we may have properties <strong>of</strong> the array which we might<br />

want to preserve. Two such properties are monotonicity and completeness. An<br />

array A is monotone increasing if<br />

(∀x :: N;y :: N) • (0 ≤ x < y < |A|) ⇒ A[x] ≤ A[y]<br />

We can define monotone decreasing similarly and we define strictly monotone<br />

increasing (decreasing) by replacing ≤ (≥) in the consequent by < (>). Monotonic<br />

arrays are sufficient for binary searches.<br />

We say an array A is complete, if<br />

(∀i :: N) • (0 ≤ i < |A|) ⇒ A[i] ≠ Null<br />

We now state a result (without pro<strong>of</strong>) about the splits asp and b(k).<br />

Suppose for an array A that<br />

and<br />

A ❀ 〈P 0 ,P 1 〉 asp<br />

A ❀ 〈Q 0 ,Q 1 〉 b(k)<br />

Then (i) if A is monotone increasing (decreasing) then P 0 , P 1 , Q 0 , Q 1 are<br />

all monotone increasing (decreasing) and (ii) if A is complete then so are P 0 ,<br />

P 1 , Q 0 , Q 1 .<br />

Note that the converse <strong>of</strong> (i) is not always true — consider<br />

[3, 2, 5, 6] ❀ 〈[3, 5], [2, 6]〉 asp<br />

and [3, 5, 2, 6] ❀<br />

〈[3, 5], [2, 6]〉 b2<br />

The arrays [3, 5] and [2, 6] are both monotone increasing but the arrays [3, 2, 5, 6]<br />

and [3, 5, 2, 6] are not.<br />

It is not always the case that splits preserve completeness and monotonicity.<br />

For example, let us consider the following array-split. Let us suppose that we<br />

have an array <strong>of</strong> length N and let sp = (ch, F) with<br />

ch = (λi.i mod 2)<br />

and F = {f 0 ,f 1 } where<br />

f 0 = (λi.(N − i) div 2)<br />

and f 1 = (λi.(i div 2) + 1)<br />

With this split, taking N = 6:<br />

[0, 1, 2, 3, 4, 5] ❀ 〈[Null, 4, 2, 0], [Null, 1, 3, 5]〉 sp<br />

and so this split does not preserve completeness or monotonicity.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!