(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*          Xavier Leroy, INRIA Paris-Rocquencourt                     *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the GNU General Public License as published by  *)
(*  the Free Software Foundation, either version 2 of the License, or  *)
(*  (at your option) any later version.  This file is also distributed *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)
(** A persistent union-find data structure. *)
Require Coq.Program.Wf.
Open Scope nat_scope.
Set Implicit Arguments.
(* To avoid useless definitions of inductors in extracted code. *)
Local Unset Elimination Schemes.
Local Unset Case Analysis Schemes.
Module Type MAP.
Parameter elt: Type.
Parameter elt_eq: forall (x y: elt), {x=y} + {x<>y}.
Parameter t: Type -> Type.
Parameter empty: forall (A: Type), t A.
Parameter get: forall (A: Type), elt -> t A -> option A.
Parameter set: forall (A: Type), elt -> A -> t A -> t A.

(* Specifications: *)
Axiom gempty: forall (A: Type) (x: elt), get x (empty A) = None.
Axiom gsspec: forall (A: Type) (x y: elt) (v: A) (m: t A),
get x (set y v m) = if elt_eq x y then Some v else get x m.