(* Hint Extern 4 (_ el map _ _) => eapply in_map_iff. *)
(* Hint Extern 4 (_ el filter _ _) => eapply filter_In. *)
(* Fixpoint count (l : list nat) (n : nat)  := *)
(*   match l with *)
(*   | [] => 0 *)
(*   | m :: l => if Nat.eqb n m then S (count l n) else count l n *)
(*   end. *)
(* Lemma countSplit (A B: list nat) (x: nat)  : count A x + count B x = count (A ++ B) x.  *)
(* Proof.  *)
(*   induction A.  *)
(*   - reflexivity.  *)
(*   - cbn. destruct (x =? a). *)
(*     + cbn. f_equal; exact IHA.  *)
(*     + exact IHA.  *)
(* Qed. *)
(* Lemma notInZero (x: nat) A : *)
(*   not (x el A) <-> count A x = 0. *)
(* Proof. *)
(*   split; induction A. *)
(*   -  reflexivity. *)
(*   - intros H. cbn in *. destruct (Nat.eqb_spec x a). *)
(*     + exfalso. apply H. left. congruence. *)
(*     + apply IHA. intros F. apply H. now right. *)
(*   - tauto. *)
(*   - cbn. destruct (Nat.eqb_spec x a). *)
(*     + subst a. omega. *)
(*     + intros H [E | E]. *)
(*       * now symmetry in E. *)
(*       * tauto. *)
(* Qed. *)
(** Positions and map-products for lists *)
Section Positions.
Variables (X: Type) (d: forall x y : X, {x = y} + {x <> y}).
Implicit Types (x y: X) (A B : list X).
Fixpoint pos x A : option nat :=
match A with
| nil => None
| y :: A' => if d x y then Some 0
else match pos x A' with
| Some n => Some (S n)
| None => None
end
end.

(* Specifications: *)
Lemma el_pos x A :
x el A -> { n | pos x A = Some n }.