Specifications of Software: Stack ADT
1 Classic Algebraic Spec Example: The Stack
1.1 Goals
- Goal: Hide internals
- Goal: Be as abstract as possible
- Q: Isn't "hide internals" the same as "abstract"?
1.2 Axioms
- pop(push(s, i)) = s
- top(push(s, i)) = i
- isempty(init()) = true
- isempty(push(s, i)) = false
- top(init()) = ERROR
- pop(init()) = init()
1.3 Discussion
- An axiom is some assertion that ought to be true. We work only in
the worlds where this is so.
init()
is the constructor. Produces the empty stack.
- We omitted signatures.
- Typical OOPL syntax is
s.push(i)
for push(s, i).
- Lots of Research in this area of Algebraic Specs
- In this intro, we skip discussing the value named ERROR.