Definition Map (K V : Type) : Type :=
  list (K * V).Definition well_formed {K V} (m : Map K V) : Prop :=
  NoDup (map fst m).(* no repeat keys *)

Class DecEq (X : Type) := {
  dec_eq : forall x x' : X, { x = x' } + { x <> x' }
  }.(* no repeat keys *)

Class DecEq (X : Type) := {
  dec_eq : forall x x' : X, { x = x' } + { x <> x' }
  }.Fixpoint insert {K V} `{DecEq K} (k : K) (v : V)
  (m : Map K V) : Map K V :=
  match m with
  | [] => [(k,v)]
  | (k',v') :: m' =>
    match dec_eq k k' with
    | left _ => (k',v) :: m'
    | right _ => (k',v') :: insert k v m'
    end
  end.

Lemma well_formed_insert {K V} `{DecEq K} (k : K) (v : V) (m : Map K V) : well_formed m -> well_formed (insert k v m).