(* Copyright (C) 2012  G. Gonthier, B. Ziliani, A. Nanevski, D. Dreyer  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.  You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>. *)
From mathcomp
From LemmaOverloading
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Section Def.
Variables (K : ordType) (V : Type).
Definition key (x : K * V) := x.1.
Definition value (x : K * V) := x.2.
Definition predk k := preim key (pred1 k).
Definition predCk k := preim key (predC1 k).
Structure finMap : Type := FinMap {
seq_of : seq (K * V);
_ : sorted ord (map key seq_of)}.
Definition finMap_for of phant (K -> V) := finMap.
Identity Coercion finMap_for_finMap : finMap_for >-> finMap.
End Def.
Notation "{ 'finMap' fT }" := (finMap_for (Phant fT))
(at level 0, format "{ 'finMap'  '[hv' fT ']' }") : type_scope.
Prenex Implicits key value predk predCk seq_of.
Section Ops.
Variables (K : ordType) (V : Type).
Notation fmap := (finMap K V).
Notation key := (@key K V).
Notation predk := (@predk K V).
Notation predCk := (@predCk K V).

Lemma fmapE (s1 s2 : fmap) : s1 = s2 <-> seq_of s1 = seq_of s2.