15.08.2013 Views

General Computer Science; Problems and Solutions for ... - Kwarc

General Computer Science; Problems and Solutions for ... - Kwarc

General Computer Science; Problems and Solutions for ... - Kwarc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

A Second Abstract Interpreter Problem 1.39: Consider the following abstract procedure<br />

on the abstract data type of natural numbers:<br />

P := 〈f::N → N ; {f(o) o, f(s(o)) o, f(s(s(nN))) s(f(nN))}〉<br />

1. Show the computation process <strong>for</strong> P on the arguments s(s(s(o))) <strong>and</strong> s(s(s(s(s(s(o)))))).<br />

2. Give the recursion relation of P.<br />

3. Does P terminate on all inputs?<br />

4. What function is computed by P?<br />

Solution:<br />

1. f(s(s(s(o)))) s(f(s(o))) s(o), <strong>and</strong> f(s(s(s(s(s(s(o))))))) s(f(s(s(s(s(o)))))) s(s(f(s(s(o))))) s(s(s(f(o)))) s(<br />

2. The recursion relation is {〈s(s(n)), n〉 ∈ (N × N) | n ∈ N} (or 〈n + 2, n〉)<br />

3. the abstract procedure terminates on all inputs.<br />

4. the abstract procedure computes the function f : N → N with 2n ↦→ n <strong>and</strong> 2n − 1 ↦→ n.<br />

41<br />

20pt

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

Saved successfully!

Ooh no, something went wrong!