3.1 Finite Sets
Your assignment is to develop a correct, pure implementation of the finite integer set data-structure. A finite integer set is a finite set of only integers. By "pure", we mean that operations on the set return new sets and do not modify the old set. You should implement the sets using binary search trees.
Your finite sets should support the following operations:
procedure
(empty) → finite-set
procedure
(cardinality t) → integer
t : finite-set
procedure
(isEmptyHuh t) → boolean
t : finite-set
procedure
(member t elt) → boolean
t : finite-set elt : integer
procedure
(add t elt) → finite-set
t : finite-set elt : integer
procedure
(remove t elt) → finite-set
t : finite-set elt : integer
procedure
(union t u) → finite-set
t : finite-set u : finite-set
procedure
(inter t u) → finite-set
t : finite-set u : finite-set
procedure
(diff t u) → finite-set
t : finite-set u : finite-set
procedure
(equal t u) → boolean
t : finite-set u : finite-set
procedure
(subset t u) → boolean
t : finite-set u : finite-set
member (add t x) y = true <-> x = y \/ member t y = true |
|
member (union s s') x = true <-> member s x = true \/ member s' x = true |
I highly suggest you use these properties to randomly generate large numbers of test cases and search for witnesses of their negation.
3.1.1 Turn-in and Grading
You should turn in your source code, a console transcript of your test suite’s execution, and an essay which describes your approach to implementing and verifying the system. Your essay should probably make reference to specific lines in your source code and test transcript.
You will be graded on the persuasiveness of your essay.