UP | HOME
../../

Specifications of Software: Stack ADT

Table of Contents

1 Classic Algebraic Spec Example: The Stack

1.1 Goals

  1. Goal: Hide internals
  2. Goal: Be as abstract as possible
  3. Q: Isn't "hide internals" the same as "abstract"?

1.2 Axioms

  1. pop(push(s, i)) = s
  2. top(push(s, i)) = i
  3. isempty(init()) = true
  4. isempty(push(s, i)) = false
  5. top(init()) = ERROR
  6. pop(init()) = init()

1.3 Discussion

  1. An axiom is some assertion that ought to be true. We work only in the worlds where this is so.
  2. init() is the constructor. Produces the empty stack.
  3. We omitted signatures.
  4. Typical OOPL syntax is s.push(i) for push(s, i).
  5. Lots of Research in this area of Algebraic Specs
  6. In this intro, we skip discussing the value named ERROR.

Copyright © 2016 pmateti@wright.edu www.wright.edu/~pmateti 2016-01-27