Set Implicit Arguments.
Basics List Plus Program Morphisms Wf Wf_nat Omega
qs_definitions monoid_monad_trans util list_utils sort_order nat_seqs
insertion_sort arith_lems.
Require qs_det_parts.
(* We take as given an arbitrary decidable order: *)
Variable X: E.
(* The Quicksort we'll use is the monadic determinstic one that uses a partition pass, instantiated with the SimplyProfiled monad: *)
Print SimplyProfiled.
Definition counted_cmp (x y: X): (monads.mon SimplyProfiled) comparison := (1%nat, Ecmp _ x y).
Let qs := mon_det_partition.qs _ counted_cmp.
Let part := mon_det_partition.partition _ counted_cmp.
(* By unfolding the (monadic) definition, we can characterize the cost and result of partitioning, and the cost of sorting: *)
Proof with auto.
unfold cost.
induction l...
simpl.
omega.
Qed.

Lemma partition_result c p l: proj1_sig (result (part p l)) c = filter (fun x => unsumbool (cmp_cmp (Ecmp _ x p) c)) l.