Library Coq.MSets.MSetGenTree

MSetGenTree : sets via generic trees

This module factorizes common parts in implementations
of finite sets as AVL trees and as Red-Black trees. The nodes
of the trees defined here include an generic information
parameter, that will be the heigth in AVL trees and the color
in Red-Black trees. Without more details here about these
information parameters, trees here are not known to be
well-balanced, but simply binary-search-trees.

The operations we could define and prove correct here are the
one that do not build non-empty trees, but only analyze them :

Comparison of trees

The algorithm here has been suggested by Xavier Leroy,
and transformed into c.p.s. by Benjamin Grégoire.
The original ocaml code (with non-structural recursive calls)
has also been formalized (thanks to Function+measure), see
ocaml_compare in MSetFullAVL. The following code with
continuations computes dramatically faster in Coq, and
should be almost as efficient after extraction.

Enumeration of the elements of a tree. This corresponds
to the "samefringe" notion in the litterature.

Subset test

In ocaml, recursive calls are made on "half-trees" such as
(Node _ l1 x1 Leaf) and (Node _ Leaf x1 r1). Instead of these
non-structural calls, we propose here two specialized functions
for these situations. This version should be almost as efficient
as the one of ocaml (closures as arguments may slow things a bit),
it is simply less compact. The exact ocaml version has also been
formalized (thanks to Function+measure), see ocaml_subset in
MSetFullAVL.