Obfuscation of Abstract Data-Types - Rowan
Obfuscation of Abstract Data-Types - Rowan
Obfuscation of Abstract Data-Types - Rowan
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CHAPTER 4. SPLITTING HEADACHES 80<br />
Case 2 Suppose that k > 0. We prove Equation (4.20) by structural induction<br />
on xs.<br />
Base Case Suppose that xs = [ ]. Then<br />
unsplit b(k) (split b(k) [ ])<br />
= {definition <strong>of</strong> split b(k) }<br />
unsplit b(k) 〈[ ], [ ]〉 b(k)<br />
= {definition <strong>of</strong> unsplit b(k) }<br />
[ ] + [ ]<br />
= {definition <strong>of</strong> +}<br />
[ ]<br />
Step Case We now suppose that xs = t : ts and let ts ❀ 〈l,r〉 b(k−1) . For<br />
the induction hypothesis, we suppose that ts satisfies Equation (4.20), i.e. ts =<br />
l + r. Then<br />
unsplit b(k) (split b(k) (t : ts))<br />
= {definition <strong>of</strong> split b(k) and refinement <strong>of</strong> ts}<br />
unsplit b(k) 〈t : l,r〉 b(k)<br />
= {definition <strong>of</strong> unsplit b(k) }<br />
(t : l) + r<br />
= {definition <strong>of</strong> +}<br />
t : (l + r)<br />
= {induction hypothesis}<br />
t : ts<br />
so<br />
We can consider unsplit b(k) to be an abstraction function for this split and<br />
xs ❀ 〈l,r〉 b(k) ⇔<br />
xs = unsplit b(k) 〈l,r〉 b(k) ∧ ((|r| = 0 ∧ |l| < k) ∨ (|l| = k))<br />
(4.21)<br />
We would like a function cons b(k) that satisfies:<br />
split b(k) (a : xs) = cons b(k) a (split b(k) xs)<br />
and so we define:<br />
cons b(k) a 〈l,r〉 b(k) =<br />
where the functions init and last satisfy:<br />
xs = init xs + [last xs] where xs ≠ [ ]<br />
{<br />
〈a : l,r〉b(k) if |l| < k<br />
〈a : (init l), (last l) : r〉 b(k) otherwise<br />
From earlier in this chapter, by using Theorem 1, we can define<br />
map b(k) f 〈l,r〉 b(k) = 〈map f l, map f r〉 b(k)