Definition valid f := if f is Def _ _ then true else false.
Definition empty := @Def (finmap.nil K V) is_true_true.
Definition upd k v f :=
if f is Def fs fpf then
if decP (@idP (p k)) is left pf then
Def (all_supp_insP v pf fpf)
else Undef
else Undef.
Definition dom f : seq K :=
if f is Def fs _ then supp fs else [::].
Definition dom_eq f1 f2 :=
match f1, f2 with
Def fs1 _, Def fs2 _ => supp fs1 == supp fs2
| Undef, Undef => true
| _, _ => false
end.
Definition free k f :=
if f is Def fs pf then Def (all_supp_remP k pf) else Undef.
Definition find k f := if f is Def fs _ then fnd k fs else None.
Definition union f1 f2 :=
if (f1, f2) is (Def fs1 pf1, Def fs2 pf2) then
if disj fs1 fs2 then
Def (all_supp_fcatP pf1 pf2)
else Undef
else Undef.
Definition um_filter q f :=
if f is Def fs pf then Def (all_supp_kfilterP q pf) else Undef.
Definition empb f := if f is Def fs _ then supp fs == [::] else false.
Definition undefb f := if f is Undef then true else false.
Definition pts k v := upd k v empty.

(* forward induction *)
Lemma base_indf (P : base -> Prop) :
P Undef -> P empty ->
(forall k v f, P f -> valid (union (pts k v) f) ->
path ord k (dom f) ->
P (union (pts k v) f)) ->
forall f, P f.