Section Ops.
Variables (K : ordType) (V : Type).
Notation fmap := (finMap K V).
Notation key := (@key K V).
Notation value := (@value K V).
Notation predk := (@predk K V).
Notation predCk := (@predCk K V).
Definition nil := FinMap sorted_nil.
Definition fnd k (s : fmap) :=
if (filter (predk k) (seq_of s)) is (_, v):: _
then Some v else None.
Fixpoint ins' (k : K) (v : V) (s : seq (K * V)) {struct s} : seq (K * V) :=
if s is (k1, v1)::s1 then
if ord k k1 then (k, v)::s else
if k == k1 then (k, v)::s1 else (k1, v1)::(ins' k v s1)
else [:: (k, v)].
Definition ins k v s := let: FinMap s' p' := s in FinMap (sorted_ins' k v p').
Variant supp_spec x (s : fmap) : bool -> Type :=
| supp_spec_some v of fnd x s = Some v : supp_spec x s true
| supp_spec_none of fnd x s = None : supp_spec x s false.

Lemma ins_ins k1 k2 v1 v2 (s : fmap) :
ins k1 v1 (ins k2 v2 s) = if k1 == k2 then ins k1 v1 s
else ins k2 v2 (ins k1 v1 s).