Global Instance Injective_Roption_None
  : Injective (Roption None None).Global Instance Injective_Roption_None_Some a
  : Injective (Roption None (Some a)).Global Instance Injective_Roption_Some_None a
  : Injective (Roption (Some a) None).Global Instance Injective_Roption_Some_Some a b
  : Injective (Roption (Some a) (Some b)).Global Instance Injective_Proper_Roption_Some x
  : Injective (Proper Roption (Some x)).Global Instance type_option : type (option T) :=
  { equal := Roption equal
  ; proper := fun x => match x with
                         | None => True
                         | Some y => proper y
                       end }.Global Instance typeOk_option : typeOk type_option.Global Instance proper_Some : proper (@Some T).Global Instance proper_None : proper (@None T).(*
Global Instance FunctorLaws_option : FunctorLaws Functor_option type_option.
Proof.
  constructor.
  { simpl. red. destruct x; destruct y; simpl; auto.
    inversion 1; simpl. red in H0.
    unfold id. constructor. etransitivity. eapply H0. 2: eauto.
    eapply proper_left; eauto.
    inversion 1. }
  { intros. simpl in *.
    red. intros.
    destruct H4; simpl.
    - unfold compose. constructor.
    - unfold compose. constructor.
      eapply H3. eapply H2. assumption. }
  { intros; simpl in *.
    red. red. inversion 2. constructor.
    constructor. apply H1. assumption. }
Qed.
*)

Global Instance Injective_Some (T : Type) (a b : T) : Injective (Some a = Some b) :=
{ result := a = b
; injection := 
    fun P : Some a = Some b =>
      match P with 
      | eq_refl => eq_refl
      end
}.Global Instance EqDec_option (T : Type) (EDT : EquivDec.EqDec T (@eq T)) : EquivDec.EqDec (option T) (@eq _).(** Specialization for equality **)
  Global Instance RelDec_eq_option : RelDec (@eq (option T)) :=
  { rel_dec := fun x y =>
    match x , y with
      | None , None => true
      | Some x , Some y => eq_dec x y
      | _ , _ => false
    end }.Global Instance RelDec_Correct_eq_option : RelDec_Correct RelDec_eq_option.

(* Specifications: *)
Lemma eq_option_eq : forall T (a b : T) (pf : a = b) (F : _ -> Type) val, match pf in _ = x return option (F x) with | eq_refl => val end = match val with | None => None | Some val => Some match pf in _ = x return F x with | eq_refl => val end end.