Axioms for RA-Stacks
Equations that state relationships among the ADT procedures:
- Pushing an item onto a stack should result in the item being on the top:
(top-minus (push! ra-stack item) 0) = item
- If an item is k elements from the top of a stack, then after the
stack is pushed it is k+1 elements from the top:
(top-minus ra-stack k) = (top-minus (push! ra-stack item) (+ k 1))
- If an item is k elements from the top of a stack, then after the
stack is popped it is k-1 elements from the top:
(top-minus ra-stack k) = (top-minus (pop! ra-stack) (- k 1))
Other axioms state how other ra-stack ADT procedures are related (Exercise
13.6).
These axioms can guide the underlying ra-stack implementation.