refine {| result := True |}.
auto.
Defined.
Global Instance Injective_Roption_None_Some a
: Injective (Roption None (Some a)).
refine {| result := False |}.
inversion 1.
Defined.
Global Instance Injective_Roption_Some_None a
: Injective (Roption (Some a) None).
refine {| result := False |}.
inversion 1.
Defined.
Global Instance Injective_Roption_Some_Some a b
: Injective (Roption (Some a) (Some b)).
refine {| result := R a b |}.
inversion 1. auto.
Defined.
Global Instance Injective_Proper_Roption_Some x
: Injective (Proper Roption (Some x)).
refine {| result := R x x |}.
abstract (inversion 1; assumption).
Defined.
End relation.
Section type.
Variable T : Type.
Variable tT : type T.
Global Instance type_option : type (option T) :=
{ equal := Roption equal
; proper := fun x => match x with
| None => True
| Some y => proper y
end }.
Variable tTOk : typeOk tT.
Global Instance typeOk_option : typeOk type_option.
Global Instance proper_Some : proper (@Some T).
*)
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
}.
Require ExtLib.Core.EquivDec.
Global Instance EqDec_option (T : Type) (EDT : EquivDec.EqDec T (@eq T)) : EquivDec.EqDec (option T) (@eq _).
Section OptionEq.
Variable T : Type.
Variable EDT : RelDec (@eq T).
(** 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 }.
Variable EDCT : RelDec_Correct EDT.
Global Instance RelDec_Correct_eq_option : RelDec_Correct RelDec_eq_option.
End OptionEq.

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.