26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

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 10. EXAMPLES OF TRANSFORMATIONS<br />

✄<br />

end<br />

push : Element × Stack → Stack<br />

push(elem, stack) ≡ 〈elem〉 stack,<br />

pop : Stack ∼ → Stack<br />

pop(stack) ≡ tl stack<br />

pre ∼ is_empty(stack),<br />

top : Stack ∼ → Element<br />

top(stack) ≡ hd stack<br />

pre ∼ is_empty(stack)<br />

scheme I_STACK =<br />

class<br />

type<br />

Stack = Element ∗ ,<br />

Element<br />

end<br />

variable<br />

stack : Stack<br />

value<br />

empty : Unit → write stack Unit<br />

empty() ≡ stack := 〈〉,<br />

is_empty : Unit → read stack Bool<br />

is_empty() ≡ stack = 〈〉,<br />

push : Element → read stack write stack Unit<br />

push(elem) ≡ stack := 〈elem〉 stack,<br />

pop : Unit ∼ → read stack write stack Unit<br />

pop() ≡ stack := tl stack<br />

pre ∼ is_empty(),<br />

top : Unit ∼ → read stack Element<br />

top() ≡ hd stack<br />

pre ∼ is_empty()<br />

110

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

Saved successfully!

Ooh no, something went wrong!