Set Implicit Arguments.
Unset Strict Implicit.

Transparent eq_rect eq_rect_r eq_rec_r sym_eq.

Scheme eq_ind2 := Induction for eq Sort Prop.
Lemma eq_rect_ind :
 forall (A : Set) (T : A -> Type) (P : forall x : A, T x -> Prop) 
   (x : A) (t : T x),
 P x t -> forall (y : A) (H : x = y), P y (eq_rect _ _ t _ H).
Proof.
  intros A T P x t HP y H; pattern y, H in |- *; apply eq_ind2 with (x := x);
   unfold eq_rect in |- *; simpl in |- *; auto.
Qed.


Axiom
  eq_refl_idT :
    forall (A : Set) (x : A) (H : x = x), identity H (refl_equal x).

Lemma eq_rect_rect :
 forall (A : Set) (T : A -> Type) (P : forall x : A, T x -> Type) 
   (x : A) (t : T x),
 P x t -> forall (y : A) (H : x = y), P y (eq_rect _ _ t _ H).
Proof.
  intros A T P x t HP y H; cut (identity x y). 
    intro H1;
     cut
      (identity (identity_rect _ (fun x _ => T x) t _ H1) (eq_rect _ _ t _ H)).
      intros H2.
      pattern (eq_rect x T t y H), H2 in |- *.
      apply identity_rect.
      case H1; auto.
      generalize H; case H1; intro H2; simpl in |- *;
       rewrite (eq_refl_idT H2); trivial.
    rewrite H; auto.
Qed.

Lemma eq_rect_r_rect :
 forall (A : Set) (T : A -> Type) (P : forall x : A, T x -> Type) 
   (x : A) (t : T x),
 P x t -> forall (y : A) (H : y = x), P y (eq_rect_r _ t H).
Proof.
  intros A T P x t HP y H; cut (identity x y). 
    intro H1;
     cut
      (identity (identity_rect _ (fun x _ => T x) t _ H1) (eq_rect_r _ t H)).
      intros H2.
      pattern (eq_rect_r T t H), H2 in |- *.
      apply identity_rect.
      case H1; auto.
      generalize H; case H1; intro H2; simpl in |- *;
       rewrite (eq_refl_idT H2); trivial.
    rewrite H; auto.
Qed.

Lemma eq_rec_r_rect :
 forall (A : Set) (T : A -> Set) (P : forall x : A, T x -> Type) 
   (x : A) (t : T x),
 P x t -> forall (y : A) (H : y = x), P y (eq_rec_r _ t H).
Proof.
  intros A T P x t HP y H; cut (identity x y). 
    intro H1;
     cut
      (identity (identity_rect _ (fun x _ => T x) t _ H1) (eq_rec_r _ t H)).
      intros H2.
      pattern (eq_rec_r T t H), H2 in |- *.
      apply identity_rect.
      case H1; auto.
      generalize H; case H1; intro H2; simpl in |- *;
       rewrite (eq_refl_idT H2); trivial.
    rewrite H; auto.
Qed.
