Structure tagged_elem := XTag {xuntag :> A}.Structure tagged_elem := XTag {xuntag :> A}.Structure tagged_elem := XTag {xuntag :> A}.(* Local Coercion untag : tagged_elem >-> A. *)

Definition extend_tag := XTag.Definition recurse_tag := extend_tag.Canonical found_tag x := recurse_tag x.(* Main structure:                                                  *)
(* - xs1 : input sequence                                           *)
(* - xs2 : output sequence; if pivot is found, then xs2 = xs1, else *)
(*   xs2 = pivot :: xs1                                             *)
(* - i : output index of pivot in xs2                               *)

Definition axiom xs1 xs2 i (pivot : tagged_elem) := 
  onth xs2 i = Some (xuntag pivot) /\ prefix xs1 xs2.Structure xfind (xs1 xs2 : seq A) (i : nat) := 
  Form {pivot :> tagged_elem; _ : axiom xs1 xs2 i pivot}.Structure xfind (xs1 xs2 : seq A) (i : nat) := 
  Form {pivot :> tagged_elem; _ : axiom xs1 xs2 i pivot}.Structure xfind (xs1 xs2 : seq A) (i : nat) := 
  Form {pivot :> tagged_elem; _ : axiom xs1 xs2 i pivot}.

(* Specifications: *)
Lemma found_pf x t : axiom (x :: t) (x :: t) 0 (found_tag x).