fact: Fixpoint remove_greatest (m : twothree V) {T} (k_oops : unit -> T) (k_ok : K -> V -> twothree V -> T) : T := match m with | Leaf => k_oops tt | Two l k v r => remove_greatest r (fun _ => k_ok k v l) (fun k' v' r' => k_ok k' v' (Two l k v r')) | Three l k v m k' v' r => remove_greatest r (fun _ => k_ok k' v' (Two l k v m)) (fun k'' v'' r'' => k_ok k'' v'' (Three l k v m k' v' r'')) end.
imports: Coq.Lists.List ExtLib.Core.RelDec ExtLib.Structures.Maps ExtLib.Structures.Monads ExtLib.Structures.Reducible