
Untitled
By: a guest on
Jun 4th, 2012 | syntax:
None | size: 0.65 KB | hits: 10 | expires: Never
ADT Specifications Modification for Stacks
TYPES
• STACK[G]
FUNCTIONS
• put: STACK[G] x G -> STACK[G]
• remove: STACK[G]-/> STACK[G]
• item: STACK[G] -/> G
• empty: STACK[G] -> BOOLEAN
• new: STACK[G]
• count: STACK[G] -> INTEGER
• change_top: STACK[G] x G -> STACK[G]
• wipe_out: STACK[G]
AXIOMS
For any x:G, s:STACK[G]
• A1 - item(put(s,x)) = x
• A2 - remove(put(s,x)) = s
• A3 - empty(new)
• A4 - not empty(put(s,x))
• A5 - count(new)
PRECONDITIONS
• remove(s:STACK[G]) require not empty(s)
• item (s:STACK[G]) require not empty(s)
• change_top (s:STACK[G]) require not empty(s)