Example Packages
Some example packages are listed below:
- Package Pair:
- Package Word:
- Package Bignum:
- Integer Stack Package
package intstackpkg is
type StackType is private;
Stack_Is_Empty, Stack_Is_Full : Exception;
function IsEmpty (S : StackType) return Boolean;
function IsFull (S : StackType) return Boolean;
procedure Push (I : Integer; S : in out StackType);
procedure Pop (S : in out StackType);
function Top (S : StackType) return Integer;
private
...
Integer Stack Specification
(and prettified)
Integer Stack Implementation
(and prettified)
Digression on Original Definition of Stacks using Axioms
- Assume all operations are functions:
- top(s: Stack) return Integer
- pop(s: Stack) return Stack
- push(s: Stack; i: Integer) return Stack -- Returns new stack
- is_empty(s: Stack) return Boolean
- is_full(s: Stack) return Boolean
- Axioms define stack operations:
- top (push (s, x)) = ??
- pop (push (s, x)) = ??
- push (pop(s), top (s)) = ??
- is_empty (push (s, x)) = ??
- is_full (pop (s)) = ??