Require Import Coq.Lists.List.
Require Import compcert.lib.Coqlib.
Require Import VST.msl.Coqlib2 VST.floyd.coqlib3.
Require Import VST.floyd.jmeq_lemmas.

Fixpoint compact_prod (T: list Type): Type :=
  match T with
  | nil => unit
  | t :: nil => t
  | t :: T0 => (t * compact_prod T0)%type
  end.

Fixpoint compact_sum (T: list Type): Type :=
  match T with
  | nil => unit
  | t :: nil => t
  | t :: T0 => (t + compact_sum T0)%type
  end.

Definition compact_prod_gen {A} {F} (gen: forall a: A, F a) (l: list A): compact_prod (map F l).
Proof.
(* Goal: compact_sum (@map A Type F l) *)
  destruct l; [exact tt |].
(* Goal: compact_sum (@map A Type F (@cons A a l)) *)
  revert a; induction l; intros.
  + exact (gen a).
  + exact (gen a0, IHl a).
Defined.

Definition compact_sum_gen {A} {F} (filter: A -> bool) (gen: forall a: A, F a) (l: list A): compact_sum (map F l).
Proof.
(* Goal: compact_sum (@map A Type F l) *)
  destruct l; [exact tt |].
(* Goal: compact_sum (@map A Type F (@cons A a l)) *)
  revert a; induction l; intros.
  + exact (gen a).
  + destruct (filter a0).
    - exact (inl (gen a0)).
    - exact (inr (IHl a)).
Defined.

Definition upd_compact_prod {A} {F} (l: list A) (v: compact_prod (map F l)) (a: A) (v0: F a) (H: forall a b: A, {a = b} + {a <> b}) : compact_prod (map F l).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: compact_prod (@map A Type F l) *)
  destruct l; [exact v |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v; induction l; intros.
  + destruct (H a a0).
    - subst.
(* Goal: compact_sum (@map A Type F (@cons A a0 (@nil A))) *)
      exact v0.
    - exact v.
  + destruct (H a a1).
    - subst.
(* Goal: compact_prod (@map A Type F (@cons A a1 (@cons A a0 l))) *)
      exact (v0, (snd v)).
    - exact ((fst v), IHl a0 (snd v)).
Defined.

Lemma compact_prod_eq: forall {A} {F1: A -> Type} {F2: A -> Type} (l: list A), (forall a, In a l -> @eq Type (F1 a) (F2 a)) -> @eq Type (compact_prod (map F1 l)) (compact_prod (map F2 l)).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (@compact_sum_gen A F1 filter gen1 l) (compact_sum (@map A Type F2 l)) (@compact_sum_gen A F2 filter gen2 l) *)
  destruct l; auto.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a H; induction l; intros.
  + simpl.
(* Goal: @JMeq (F1 a) (gen1 a) (F2 a) (gen2 a) *)
    apply H.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
    simpl; auto.
  + simpl.
(* Goal: @eq Type (sum (F1 a0) match @map A Type F1 l with | nil => F1 a | cons T l0 => sum (F1 a) (compact_sum (@map A Type F1 l)) end) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a | cons T l0 => sum (F2 a) (compact_sum (@map A Type F2 l)) end) *)
    rewrite H by (left; auto).
    change (match @map A Type F1 l with
                       | nil => F1 a
                       | cons _ _ => prod (F1 a) (compact_prod (@map A Type F1 l))
                       end) with
           (compact_prod (@map A Type F1 (@cons A a l))).
(* Goal: @eq Type (sum (F2 a0) (compact_sum (@map A Type F1 (@cons A a l)))) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a | cons T l0 => sum (F2 a) (compact_sum (@map A Type F2 l)) end) *)
    rewrite IHl; [apply eq_refl |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
    intros.
(* Goal: @JMeq (F1 a) (gen1 a) (F2 a) (gen2 a) *)
    apply H.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
    simpl; auto.
Qed.

Lemma compact_sum_eq: forall {A} {F1: A -> Type} {F2: A -> Type} (l: list A), (forall a, In a l -> @eq Type (F1 a) (F2 a)) -> @eq Type (compact_sum (map F1 l)) (compact_sum (map F2 l)).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (@compact_sum_gen A F1 filter gen1 l) (compact_sum (@map A Type F2 l)) (@compact_sum_gen A F2 filter gen2 l) *)
  destruct l; auto.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a H; induction l; intros.
  + simpl.
(* Goal: @JMeq (F1 a) (gen1 a) (F2 a) (gen2 a) *)
    apply H.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
    simpl; auto.
  + simpl.
(* Goal: @eq Type (sum (F1 a0) match @map A Type F1 l with | nil => F1 a | cons T l0 => sum (F1 a) (compact_sum (@map A Type F1 l)) end) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a | cons T l0 => sum (F2 a) (compact_sum (@map A Type F2 l)) end) *)
    rewrite H by (left; auto).
    change (match @map A Type F1 l with
                       | nil => F1 a
                       | cons _ _ => sum (F1 a) (compact_sum (@map A Type F1 l))
                       end) with
           (compact_sum (@map A Type F1 (@cons A a l))).
(* Goal: @eq Type (sum (F2 a0) (compact_sum (@map A Type F1 (@cons A a l)))) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a | cons T l0 => sum (F2 a) (compact_sum (@map A Type F2 l)) end) *)
    rewrite IHl; [apply eq_refl |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
    intros.
(* Goal: @JMeq (F1 a) (gen1 a) (F2 a) (gen2 a) *)
    apply H.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
    simpl; auto.
Qed.

Lemma compact_prod_gen_JMeq: forall {A} {F1} {F2} (gen1: forall a: A, F1 a) (gen2: forall a: A, F2 a)  (l: list A), (forall a, In a l -> JMeq (gen1 a) (gen2 a)) -> JMeq (compact_prod_gen gen1 l) (compact_prod_gen gen2 l).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (@compact_sum_gen A F1 filter gen1 l) (compact_sum (@map A Type F2 l)) (@compact_sum_gen A F2 filter gen2 l) *)
  destruct l; auto.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a H; induction l; intros.
  + simpl.
(* Goal: @JMeq (F1 a) (gen1 a) (F2 a) (gen2 a) *)
    apply H.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
    simpl; auto.
  + simpl.
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a | cons T l0 => prod (F1 a) (compact_prod (@map A Type F1 l)) end) (@pair (F1 a0) match @map A Type F1 l with | nil => F1 a | cons T l0 => prod (F1 a) (compact_prod (@map A Type F1 l)) end (gen1 a0) (@list_rect A (fun l : list A => forall a : A, match @map A Type F1 l with | nil => F1 a | cons T l0 => prod (F1 a) (compact_prod (@map A Type F1 l)) end) (fun a : A => gen1 a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (a0 : A) => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a | cons T l0 => prod (F1 a) (compact_prod (@map A Type F1 l)) end (gen1 a0) (IHl a)) l a)) (prod (F2 a0) match @map A Type F2 l with | nil => F2 a | cons T l0 => prod (F2 a) (compact_prod (@map A Type F2 l)) end) (@pair (F2 a0) match @map A Type F2 l with | nil => F2 a | cons T l0 => prod (F2 a) (compact_prod (@map A Type F2 l)) end (gen2 a0) (@list_rect A (fun l : list A => forall a : A, match @map A Type F2 l with | nil => F2 a | cons T l0 => prod (F2 a) (compact_prod (@map A Type F2 l)) end) (fun a : A => gen2 a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (a0 : A) => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a | cons T l0 => prod (F2 a) (compact_prod (@map A Type F2 l)) end (gen2 a0) (IHl a)) l a)) *)
    apply JMeq_pair; [apply H; left; auto |].
(* Goal: @JMeq match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) *)
    apply IHl.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
    intros.
(* Goal: @JMeq (F1 a) (gen1 a) (F2 a) (gen2 a) *)
    apply H.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
    simpl; auto.
Qed.

Lemma compact_sum_gen_JMeq: forall {A} {F1} {F2} (filter: A -> bool) (gen1: forall a: A, F1 a) (gen2: forall a: A, F2 a)  (l: list A), (forall a, In a l -> JMeq (gen1 a) (gen2 a)) -> JMeq (compact_sum_gen filter gen1 l) (compact_sum_gen filter gen2 l).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (@compact_sum_gen A F1 filter gen1 l) (compact_sum (@map A Type F2 l)) (@compact_sum_gen A F2 filter gen2 l) *)
  destruct l; auto.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a H; induction l; intros.
  + simpl.
(* Goal: @JMeq (F1 a) (gen1 a) (F2 a) (gen2 a) *)
    apply H.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
    simpl; auto.
  + simpl.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a0) => match (if filter a0 then @inl (F a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a1 | cons T l0 => sum (F a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl0 : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) (a0 : A) => if filter a0 then @inl (F a0) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l with | nil => F a | cons T l0 => sum (F a) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end (IHl0 a)) l a1)) with | inl v => v | inr v => default end) a e df (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 df | right n => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e0 df IHl | right n => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l) | right n => match (if filter a0 then @inl (F a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a1 | cons T l0 => sum (F a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) (a0 : A) => if filter a0 then @inl (F a0) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l with | nil => F a | cons T l0 => sum (F a) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end (IHl a)) l a1)) with | inl v => df | inr v => @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v0 : F a0) => match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v0) a e df | right n0 => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v0 : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v0 with | inl v1 => v1 | inr v1 => default end) a e df IHl | right n0 => match v0 with | inl v1 => df | inr v1 => IHl a0 v1 end end) l a1 v end end (gen a) *)
    destruct (filter a0).
    - apply @JMeq_inl.
      * apply (@compact_sum_eq A F1 F2 (a :: l)).
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
        intros.
(* Goal: @eq Type (F1 a1) (F2 a1) *)
        apply H; right; auto.
      * apply H; left; auto.
    - apply @JMeq_inr.
      * apply H; left; auto.
(* Goal: @JMeq match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) *)
      * apply IHl.
(* Goal: @eq Type (F1 a1) (F2 a1) *)
        intros; apply H; right; auto.
Qed.

Lemma aux0: forall {A} {a a0: A}, In a (a0 :: nil) -> a <> a0 -> False.
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @In A a l *)
  destruct H; [congruence | tauto].
Defined.

Lemma aux1: forall {A} {a a0: A} {l}, In a (a0 :: l) -> a <> a0 -> In a l.
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @In A a l *)
  destruct H; [congruence | tauto].
Defined.

Definition upd_compact_sum {A} {F} (l: list A) (v: compact_sum (map F l)) (a: A) (v0: F a) (H: forall a b: A, {a = b} + {a <> b}) : compact_sum (map F l).
Proof.
(* Goal: compact_sum (@map A Type F l) *)
  destruct (in_dec H a l); [| exact v].
(* Goal: compact_sum (@map A Type F l) *)
  clear v.
(* Goal: compact_sum (@map A Type F l) *)
  destruct l; [exact tt |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 i; induction l; intros.
  + destruct (H a a0).
    - subst.
(* Goal: compact_sum (@map A Type F (@cons A a0 (@nil A))) *)
      exact v0.
    - pose proof aux0 i n.
(* Goal: compact_sum (@map A Type F (@cons A a0 (@nil A))) *)
      inversion H0.
  + destruct (H a a1).
    - subst.
(* Goal: compact_sum (@map A Type F (@cons A a1 (@cons A a0 l))) *)
      exact (inl v0).
    - exact (inr (IHl a0 (aux1 i n))).
Defined.

Definition proj_compact_prod {A: Type} {F: A -> Type} (a: A) (l: list A) (v: compact_prod (map F l)) (default: F a) (H: forall a b: A, {a = b} + {a <> b}) : F a.
Proof.
(* Goal: F a *)
  destruct l; [exact default |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v; induction l; intros.
  + destruct (H a a0).
    - subst.
(* Goal: F a1 *)
      exact v.
    - exact default.
  + destruct (H a a1).
    - subst.
(* Goal: F a1 *)
      exact (fst v).
    - exact (IHl a0 (snd v)).
Defined.

Definition proj_compact_sum {A: Type} {F: A -> Type} (a: A) (l: list A) (v: compact_sum (map F l)) (default: F a) (H: forall a b: A, {a = b} + {a <> b}) : F a.
Proof.
(* Goal: F a *)
  destruct l; [exact default |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v; induction l; intros.
  + destruct (H a a0).
    - subst.
(* Goal: F a1 *)
      exact v.
    - exact default.
  + destruct (H a a1).
    - subst.
(* Goal: @In A a (@cons A a0 (@cons A a1 l)) *)
      destruct v as [v | v].
(* Goal: F a1 *)
      * exact v.
      * exact default.
    - destruct v as [v | v].
      * exact default.
      * exact (IHl a0 v).
Defined.

Definition compact_sum_inj {A: Type} {F: A -> Type} {l: list A} (v: compact_sum (map F l)) (a: A) (H: forall a b: A, {a = b} + {a <> b}): Prop.
(* Goal: Prop *)
  destruct l as [| a0 l]; [exact False |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v; induction l as [| a1 l]; intros.
  + exact (if H a a0 then True else False).
  + destruct v as [v | v].
    - exact (if H a a0 then True else False).
    - exact (if H a a0 then False else IHl a1 v).
Defined.

Lemma compact_sum_inj_in: forall {A: Type} {F: A -> Type} {l: list A} (v: compact_sum (map F l)) (a: A) H,
  compact_sum_inj v a H ->
  In a l.
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @eq (F a) (@proj_compact_sum A F a l (@compact_sum_gen A F filter gen l) df H) (gen a) *)
  destruct l as [| a0 l]; [simpl in H0; tauto |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v H0; induction l as [| a1 l]; intros.
  + simpl in H0 |- *.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a), F a) (fun (_ : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a0) => gen a0) a e df (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 df | right n => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e0 df IHl | right n => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l) | right n => df end (gen a) *)
    destruct (H a a0); [| tauto].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    auto.
  + destruct v as [v | v].
    - simpl in H0 |- *.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a), F a) (fun (_ : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a0) => gen a0) a e df (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 df | right n => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e0 df IHl | right n => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l) | right n => df end (gen a) *)
      destruct (H a a0); [| tauto].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      auto.
    - simpl in H0 |- *.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a0) => default) a e df (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 df | right n => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e0 df IHl | right n => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l) | right n => @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e df | right n0 => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e df IHl | right n0 => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l a1 (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) (a0 : A) => if filter a0 then @inl (F a0) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l with | nil => F a | cons T l0 => sum (F a) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end (IHl a)) l a1) end (gen a) *)
      destruct (H a a0); [tauto |].
(* Goal: or (@eq A a0 a) (or (@eq A a1 a) (@In A a l)) *)
      right.
(* Goal: or (@eq A a1 a) (@In A a l) *)
      apply (IHl a1 v).
(* Goal: @compact_sum_inj A F (@cons A a1 l) v a H *)
      exact H0.
Qed.

Lemma compact_prod_proj_gen: forall {A: Type} {F: A -> Type} {l: list A} a d (gen: forall a, F a) (H: forall a b : A, {a = b} + {a <> b}),
  In a l ->
  proj_compact_prod a l (compact_prod_gen gen l) d H = gen a.
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @eq (F a) (@proj_compact_prod A F a l (@compact_prod_gen A F gen l) d H) (gen a) *)
  destruct l as [| a0 l]; [inversion H0 |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 H0; induction l as [| a1 l]; intros.
  + destruct H0; [| inversion H0].
    simpl in H |- *; subst.
(* Goal: @eq (F a) match H a a with | left e => @eq_rect_r A a (fun a : A => forall _ : F a, F a) (fun _ : F a => gen a) a e d | right n => d end (gen a) *)
    destruct (H a a); [| congruence].
    unfold eq_rect_r; rewrite <- eq_rect_eq; auto.
  + destruct (H a a0).
    - simpl.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end), F a), F a) (fun (_ : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => prod (F a1) (compact_prod (@map A Type F l)) end), F a0) => gen a0) a e d (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 d | right n => d end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => prod (F a1) (compact_prod (@map A Type F l)) end), F a) (a1 : A) (v : prod (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a), F a) (fun (_ : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a1) => @fst (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) a e0 d IHl | right n => IHl a0 (@snd (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) end) l) | right n => @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e d | right n0 => d end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => prod (F a1) (compact_prod (@map A Type F l)) end), F a) (a1 : A) (v : prod (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end) => match H a a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a), F a) (fun (_ : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a1) => @fst (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) a e d IHl | right n0 => IHl a0 (@snd (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) end) l a1 (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => prod (F a) (compact_prod (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end) (a0 : A) => @pair (F a0) match @map A Type F l with | nil => F a | cons T l0 => prod (F a) (compact_prod (@map A Type F l)) end (gen a0) (IHl a)) l a1) end (gen a) *)
      destruct (H a a0); [| congruence].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
      subst.
      unfold eq_rect_r; rewrite <- eq_rect_eq; auto.
    - inversion H0; [congruence |].
(* Goal: @JMeq (compact_sum (@map A Type F1 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F1 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) (fun (v0 : F1 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F1 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F1 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) (compact_sum (@map A Type F1 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) (compact_sum (@map A Type F2 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F2 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) (fun (v0 : F2 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F2 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F2 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) (compact_sum (@map A Type F2 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) *)
      simpl.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end), F a), F a) (fun (_ : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => prod (F a1) (compact_prod (@map A Type F l)) end), F a0) => gen a0) a e d (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 d | right n => d end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => prod (F a1) (compact_prod (@map A Type F l)) end), F a) (a1 : A) (v : prod (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a), F a) (fun (_ : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a1) => @fst (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) a e0 d IHl | right n => IHl a0 (@snd (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) end) l) | right n => @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e d | right n0 => d end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => prod (F a1) (compact_prod (@map A Type F l)) end), F a) (a1 : A) (v : prod (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end) => match H a a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a), F a) (fun (_ : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => prod (F a2) (compact_prod (@map A Type F l)) end), F a1) => @fst (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) a e d IHl | right n0 => IHl a0 (@snd (F a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a0 | cons T l0 => prod (F a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end v) end) l a1 (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => prod (F a) (compact_prod (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => prod (F a0) (compact_prod (@map A Type F l)) end) (a0 : A) => @pair (F a0) match @map A Type F l with | nil => F a | cons T l0 => prod (F a) (compact_prod (@map A Type F l)) end (gen a0) (IHl a)) l a1) end (gen a) *)
      destruct (H a a0); [congruence |].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply IHl; auto.
Qed.

Lemma compact_sum_proj_gen: forall {A: Type} {F: A -> Type} {l: list A} a df (filter: A -> bool) (gen: forall a, F a) (H: forall a b : A, {a = b} + {a <> b}),
  compact_sum_inj (compact_sum_gen filter gen l) a H ->
  proj_compact_sum a l (compact_sum_gen filter gen l) df H = gen a.
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @eq (F a) (@proj_compact_sum A F a l (@compact_sum_gen A F filter gen l) df H) (gen a) *)
  destruct l as [| a0 l]; [simpl in H0; tauto |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 H0; induction l as [| a1 l]; intros.
  + simpl in *.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a), F a) (fun (_ : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a0) => gen a0) a e df (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 df | right n => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e0 df IHl | right n => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l) | right n => df end (gen a) *)
    destruct (H a a0); [| tauto].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
    subst.
    unfold eq_rect_r; rewrite <- eq_rect_eq; auto.
  + simpl in *.
(* Goal: @eq (F a) match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F a) (_ : forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a0) (_ : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a0) => match (if filter a0 then @inl (F a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a1 | cons T l0 => sum (F a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl0 : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) (a0 : A) => if filter a0 then @inl (F a0) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l with | nil => F a | cons T l0 => sum (F a) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end (IHl0 a)) l a1)) with | inl v => v | inr v => default end) a e df (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e0 df | right n => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e0 df IHl | right n => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l) | right n => match (if filter a0 then @inl (F a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l with | nil => F a1 | cons T l0 => sum (F a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F a) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) (a0 : A) => if filter a0 then @inl (F a0) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l with | nil => F a | cons T l0 => sum (F a) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end (IHl a)) l a1)) with | inl v => df | inr v => @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v0 : F a0) => match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v0) a e df | right n0 => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v0 : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v0 with | inl v1 => v1 | inr v1 => default end) a e df IHl | right n0 => match v0 with | inl v1 => df | inr v1 => IHl a0 v1 end end) l a1 v end end (gen a) *)
    destruct (filter a0).
    - destruct (H a a0); [| tauto].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
      subst.
      unfold eq_rect_r; rewrite <- eq_rect_eq; auto.
    - destruct (H a a0); [tauto |].
(* Goal: @eq (F a) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end), F a) (fun (a0 : A) (v : F a0) => match H a a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F a, F a) (fun _ : F a0 => v) a e df | right n => df end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F l with | nil => F a1 | cons T l0 => sum (F a1) (compact_sum (@map A Type F l)) end), F a) (a1 : A) (v : sum (F a1) match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) => match H a a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F a) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a), F a) (fun (default : F a1) (_ : forall (a2 : A) (_ : match @map A Type F l with | nil => F a2 | cons T l0 => sum (F a2) (compact_sum (@map A Type F l)) end), F a1) => match v with | inl v0 => v0 | inr v0 => default end) a e df IHl | right n => match v with | inl v0 => df | inr v0 => IHl a0 v0 end end) l a1 (@list_rect A (fun l : list A => forall a : A, match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end) (fun a : A => gen a) (fun (a : A) (l : list A) (IHl : forall a0 : A, match @map A Type F l with | nil => F a0 | cons T l0 => sum (F a0) (compact_sum (@map A Type F l)) end) (a0 : A) => if filter a0 then @inl (F a0) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l with | nil => F a | cons T l0 => sum (F a) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a1 t => @cons Type (F a1) (map t) end) l)) end (gen a0) else @inr (F a0) match @map A Type F l with | nil => F a | cons T l0 => sum (F a) (compact_sum (@map A Type F l)) end (IHl a)) l a1)) (gen a) *)
      apply (IHl a1).
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      auto.
Qed.

Lemma proj_compact_prod_JMeq: forall A i (l: list A) {F1: A -> Type} {F2: A -> Type} d1 d2 (v1: compact_prod (map F1 l)) (v2: compact_prod (map F2 l)) H,
  (forall i, In i l -> @eq Type (F1 i) (F2 i)) ->
  In i l ->
  JMeq v1 v2 ->
  JMeq (proj_compact_prod i l v1 d1 H) (proj_compact_prod i l v2 d2 H).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (F1 i) (@proj_compact_prod A F1 i l v1 d1 H) (F2 i) (@proj_compact_prod A F2 i l v2 d2 H) *)
  destruct l as [| a0 l]; [inversion H1 |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v1 v2 H0 H1 H2; induction l as [| a1 l]; intros.
  + inversion H1; [simpl in H3 | inversion H3].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
    subst.
(* Goal: @JMeq (compact_sum (@map A Type F1 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F1 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) (fun (v0 : F1 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F1 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F1 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) (compact_sum (@map A Type F1 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) (compact_sum (@map A Type F2 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F2 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) (fun (v0 : F2 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F2 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F2 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) (compact_sum (@map A Type F2 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) *)
    revert v2 H1 H2; simpl.
(* Goal: forall (v2 : F2 i) (_ : or (@eq A i i) False) (_ : @JMeq (F1 i) v1 (F2 i) v2), @JMeq (F1 i) match H i i with | left e => @eq_rect_r A i (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 i => v1) i e d1 | right n => d1 end (F2 i) match H i i with | left e => @eq_rect_r A i (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 i => v2) i e d2 | right n => d2 end *)
    destruct (H i i); [intros | congruence].
    unfold eq_rect_r; rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    auto.
  + assert (@eq Type (F1 a0) (F2 a0)). {
      clear - H0.
(* Goal: @eq Type (F1 a0) (F2 a0) *)
      specialize (H0 a0).
(* Goal: @eq Type (F1 i0) (F2 i0) *)
      apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
      left; simpl; auto.
    }
(* Goal: @JMeq (F1 i) (@proj_compact_prod A F1 i (@cons A a0 (@cons A a1 l)) v1 d1 H) (F2 i) (@proj_compact_prod A F2 i (@cons A a0 (@cons A a1 l)) v2 d2 H) *)
    assert (@eq Type (compact_prod (map F1 (a1 :: l))) (compact_prod (map F2 (a1 :: l)))).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
(* Goal: @eq Type (compact_prod (@map A Type F1 (@cons A a1 l))) (compact_prod (@map A Type F2 (@cons A a1 l))) *)
      apply compact_prod_eq.
      clear - H0.
(* Goal: forall (a : A) (_ : @In A a (@cons A a1 l)), @eq Type (F1 a) (F2 a) *)
      intros i ?H.
(* Goal: @eq Type (F1 i) (F2 i) *)
      specialize (H0 i).
(* Goal: @eq Type (F1 i) (F2 i) *)
      spec H0; [right; auto |].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      symmetry; auto.
    }
(* Goal: @JMeq (F1 i) (@proj_compact_prod A F1 i (@cons A a0 (@cons A a1 l)) v1 d1 H) (F2 i) (@proj_compact_prod A F2 i (@cons A a0 (@cons A a1 l)) v2 d2 H) *)
    destruct (H i a0) as [?H | ?H].
    - subst.
(* Goal: @JMeq (F1 a0) (@proj_compact_prod A F1 a0 (@cons A a0 (@cons A a1 l)) v1 d1 H) (F2 a0) (@proj_compact_prod A F2 a0 (@cons A a0 (@cons A a1 l)) v2 d2 H) *)
      clear IHl.
(* Goal: @JMeq (compact_sum (@map A Type F1 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F1 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) (fun (v0 : F1 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F1 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F1 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) (compact_sum (@map A Type F1 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) (compact_sum (@map A Type F2 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F2 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) (fun (v0 : F2 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F2 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F2 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) (compact_sum (@map A Type F2 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) *)
      revert v1 v2 H0 H2; simpl.
(* Goal: forall (v1 : prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (v2 : prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (_ : forall (i : A) (_ : or (@eq A a0 i) (or (@eq A a1 i) (@In A i l))), @eq Type (F1 i) (F2 i)) (_ : @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) v1 (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) v2), @JMeq (F1 a0) match H a0 a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), F1 a0) => @fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) a0 e d1 (@list_rect A (fun l : list A => forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), F1 a0) (fun (a1 : A) (v : F1 a1) => match H a0 a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a1 => v) a0 e0 d1 | right n => d1 end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => prod (F1 a2) (compact_prod (@map A Type F1 l)) end), F1 a0) (a2 : A) (v : prod (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) => match H a0 a2 with | left e0 => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a2) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 a2) => @fst (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) a0 e0 d1 IHl | right n => IHl a1 (@snd (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) end) l) | right n => @list_rect A (fun l : list A => forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), F1 a0) (fun (a1 : A) (v : F1 a1) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a1 => v) a0 e d1 | right n0 => d1 end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => prod (F1 a2) (compact_prod (@map A Type F1 l)) end), F1 a0) (a2 : A) (v : prod (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a2) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 a2) => @fst (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) a0 e d1 IHl | right n0 => IHl a1 (@snd (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) end (F2 a0) match H a0 a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), F2 a0) => @fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) a0 e d2 (@list_rect A (fun l : list A => forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), F2 a0) (fun (a1 : A) (v : F2 a1) => match H a0 a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a1 => v) a0 e0 d2 | right n => d2 end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => prod (F2 a2) (compact_prod (@map A Type F2 l)) end), F2 a0) (a2 : A) (v : prod (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) => match H a0 a2 with | left e0 => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a2) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 a2) => @fst (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) a0 e0 d2 IHl | right n => IHl a1 (@snd (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) end) l) | right n => @list_rect A (fun l : list A => forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), F2 a0) (fun (a1 : A) (v : F2 a1) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a1 => v) a0 e d2 | right n0 => d2 end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => prod (F2 a2) (compact_prod (@map A Type F2 l)) end), F2 a0) (a2 : A) (v : prod (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a2) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 a2) => @fst (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) a0 e d2 IHl | right n0 => IHl a1 (@snd (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) end *)
      destruct (H a0 a0); [intros | congruence].
      unfold eq_rect_r; rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply @JMeq_fst; auto.
    - inversion H1; [congruence |].
(* Goal: @JMeq (compact_sum (@map A Type F1 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F1 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) (fun (v0 : F1 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F1 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F1 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F1 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F1 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) (compact_sum (@map A Type F1 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) (compact_sum (@map A Type F2 (@cons A a0 (@cons A a1 l)))) (@list_rect A (fun l : list A => forall (a0 : A) (_ : @In A i (@cons A a0 l)), compact_sum (@map A Type F2 (@cons A a0 l))) (fun (a0 : A) (i0 : @In A i (@cons A a0 (@nil A))) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : @In A a (@cons A a0 (@nil A))), compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) (fun (v0 : F2 a0) (_ : @In A a0 (@cons A a0 (@nil A))) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (compact_sum (@map A Type F2 (@cons A a0 (@nil A)))) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : @In A i (@cons A a1 l)), compact_sum (@map A Type F2 (@cons A a1 l))) (a1 : A) (i0 : @In A i (@cons A a1 (@cons A a0 l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : @In A a (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a (@cons A a1 (@cons A a0 l))), compact_sum (@map A Type F2 (@cons A a1 (@cons A a0 l)))) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : @In A a1 (@cons A a2 l)), compact_sum (@map A Type F2 (@cons A a2 l))) (_ : @In A a1 (@cons A a1 (@cons A a0 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) (compact_sum (@map A Type F2 (@cons A a0 l))) (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) (@cons A a1 l) a0 H3) *)
      revert v1 v2 H2 H3; simpl.
(* Goal: forall (v1 : prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (v2 : prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (_ : @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) v1 (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) v2) (_ : @eq Type (F1 a0) (F2 a0)), @JMeq (F1 i) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), F1 a0) => @fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e0 d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), F1 i) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => prod (F1 a2) (compact_prod (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => prod (F1 a2) (compact_prod (@map A Type F1 l)) end), F1 a1) => @fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) i e0 d1 IHl | right n => IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) end) l) | right n => @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n0 => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), F1 i) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => prod (F1 a2) (compact_prod (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => prod (F1 a2) (compact_prod (@map A Type F1 l)) end), F1 a1) => @fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) i e d1 IHl | right n0 => IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) end (F2 i) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), F2 a0) => @fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e0 d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), F2 i) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => prod (F2 a2) (compact_prod (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => prod (F2 a2) (compact_prod (@map A Type F2 l)) end), F2 a1) => @fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) i e0 d2 IHl | right n => IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) end) l) | right n => @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n0 => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), F2 i) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => prod (F2 a2) (compact_prod (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => prod (F2 a2) (compact_prod (@map A Type F2 l)) end), F2 a1) => @fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) i e d2 IHl | right n0 => IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) end *)
      destruct (H i a0); [congruence |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
      intros.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply (IHl a1 (snd v1) (snd v2)); auto.
      * clear - H0.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
        intros i ?.
(* Goal: @eq Type (F1 i) (F2 i) *)
        specialize (H0 i).
(* Goal: @eq Type (F1 i0) (F2 i0) *)
        apply H0.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
        right; auto.
      * apply @JMeq_snd; auto.
Qed.

Lemma proj_compact_sum_JMeq': forall A i (l: list A) {F1: A -> Type} {F2: A -> Type} d1 d2 (v1: compact_sum (map F1 l)) (v2: compact_sum (map F2 l)) H,
  (forall i, In i l -> @eq Type (F1 i) (F2 i)) ->
  JMeq d1 d2 ->
  JMeq v1 v2 ->
  JMeq (proj_compact_sum i l v1 d1 H) (proj_compact_sum i l v2 d2 H).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (F1 i) (@proj_compact_sum A F1 i l v1 d1 H) (F2 i) (@proj_compact_sum A F2 i l v2 d2 H) *)
  destruct l as [| a0 l]; [simpl in H1; tauto |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v1 v2 H0 H1 H2; induction l as [| a1 l]; intros.
  + simpl in H1 |- *.
(* Goal: iff (if H i a0 then True else False) (if H i a0 then True else False) *)
    destruct (H i a0); [| tauto].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
    subst.
    unfold eq_rect_r; rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    auto.
  + assert (@eq Type (F1 a0) (F2 a0)).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
      clear - H0.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
      apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
      left; simpl; auto.
    }
(* Goal: iff (@compact_sum_inj A F1 (@cons A a0 (@cons A a1 l)) v1 i H) (@compact_sum_inj A F2 (@cons A a0 (@cons A a1 l)) v2 i H) *)
    assert (@eq Type (compact_sum (map F1 (a1 :: l))) (compact_sum (map F2 (a1 :: l)))).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
(* Goal: @eq Type (compact_sum (@map A Type F1 (@cons A a1 l))) (compact_sum (@map A Type F2 (@cons A a1 l))) *)
      apply compact_sum_eq.
      clear - H0.
(* Goal: forall (a : A) (_ : @In A a (@cons A a1 l)), @eq Type (F1 a) (F2 a) *)
      intros i ?H.
(* Goal: @eq Type (F1 i) (F2 i) *)
      specialize (H0 i).
(* Goal: @eq Type (F1 i) (F2 i) *)
      spec H0; [right; auto |].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      symmetry; auto.
    }
(* Goal: @JMeq (F1 i) (@proj_compact_sum A F1 i (@cons A a0 (@cons A a1 l)) v1 d1 H) (F2 i) (@proj_compact_sum A F2 i (@cons A a0 (@cons A a1 l)) v2 d2 H) *)
    simpl in H2.
(* Goal: @JMeq (F1 i) (@proj_compact_sum A F1 i (@cons A a0 (@cons A a1 l)) v1 d1 H) (F2 i) (@proj_compact_sum A F2 i (@cons A a0 (@cons A a1 l)) v2 d2 H) *)
    solve_JMeq_sumtype H2.
    - simpl in H1 |- *.
(* Goal: iff (if H i a0 then True else False) (if H i a0 then True else False) *)
      destruct (H i a0); [| tauto].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
      subst.
      unfold eq_rect_r; rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      auto.
    - simpl in H1 |- *.
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e0 d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e0 d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3 | right n => @inr (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n0 => match @aux0 A i a0 i0 n0 return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n0 => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n0)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) end (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e0 d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e0 d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3 | right n => @inr (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n0 => match @aux0 A i a0 i0 n0 return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n0 => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n0)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) end *)
      destruct (H i a0).
      * subst i.
        unfold eq_rect_r; rewrite <- !eq_rect_eq; auto.
      * apply (IHl a1 c c0); auto.
        clear - H0.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
        intros ?i ?.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
        apply H0.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
        right; auto.
Qed.

Lemma proj_compact_sum_JMeq: forall A i (l: list A) {F1: A -> Type} {F2: A -> Type} d1 d2 (v1: compact_sum (map F1 l)) (v2: compact_sum (map F2 l)) H,
  (forall i, In i l -> @eq Type (F1 i) (F2 i)) ->
  compact_sum_inj v1 i H ->
  JMeq v1 v2 ->
  JMeq (proj_compact_sum i l v1 d1 H) (proj_compact_sum i l v2 d2 H).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (F1 i) (@proj_compact_sum A F1 i l v1 d1 H) (F2 i) (@proj_compact_sum A F2 i l v2 d2 H) *)
  destruct l as [| a0 l]; [simpl in H1; tauto |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v1 v2 H0 H1 H2; induction l as [| a1 l]; intros.
  + simpl in H1 |- *.
(* Goal: iff (if H i a0 then True else False) (if H i a0 then True else False) *)
    destruct (H i a0); [| tauto].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
    subst.
    unfold eq_rect_r; rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    auto.
  + assert (@eq Type (F1 a0) (F2 a0)).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
      clear - H0.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
      apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
      left; simpl; auto.
    }
(* Goal: iff (@compact_sum_inj A F1 (@cons A a0 (@cons A a1 l)) v1 i H) (@compact_sum_inj A F2 (@cons A a0 (@cons A a1 l)) v2 i H) *)
    assert (@eq Type (compact_sum (map F1 (a1 :: l))) (compact_sum (map F2 (a1 :: l)))).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
(* Goal: @eq Type (compact_sum (@map A Type F1 (@cons A a1 l))) (compact_sum (@map A Type F2 (@cons A a1 l))) *)
      apply compact_sum_eq.
      clear - H0.
(* Goal: forall (a : A) (_ : @In A a (@cons A a1 l)), @eq Type (F1 a) (F2 a) *)
      intros i ?H.
(* Goal: @eq Type (F1 i) (F2 i) *)
      specialize (H0 i).
(* Goal: @eq Type (F1 i) (F2 i) *)
      spec H0; [right; auto |].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      symmetry; auto.
    }
(* Goal: @JMeq (F1 i) (@proj_compact_sum A F1 i (@cons A a0 (@cons A a1 l)) v1 d1 H) (F2 i) (@proj_compact_sum A F2 i (@cons A a0 (@cons A a1 l)) v2 d2 H) *)
    simpl in H2.
(* Goal: @JMeq (F1 i) (@proj_compact_sum A F1 i (@cons A a0 (@cons A a1 l)) v1 d1 H) (F2 i) (@proj_compact_sum A F2 i (@cons A a0 (@cons A a1 l)) v2 d2 H) *)
    solve_JMeq_sumtype H2.
    - simpl in H1 |- *.
(* Goal: iff (if H i a0 then True else False) (if H i a0 then True else False) *)
      destruct (H i a0); [| tauto].
(* Goal: @JMeq (F1 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (_ : F1 a0) (_ : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 a0) => f) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), F1 i) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a) (fun _ : F1 a0 => v) i e d1 | right n => d1 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end), F1 i) (a1 : A) (v : sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a), F1 a) (fun (default : F1 a1) (_ : forall (a2 : A) (_ : match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end), F1 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d1 IHl | right n => match v with | inl v0 => d1 | inr v0 => IHl a0 v0 end end) l)) (F2 i) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (_ : F2 a0) (_ : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 a0) => f0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), F2 i) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a) (fun _ : F2 a0 => v) i e d2 | right n => d2 end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end), F2 i) (a1 : A) (v : sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a), F2 a) (fun (default : F2 a1) (_ : forall (a2 : A) (_ : match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end), F2 a1) => match v with | inl v0 => v0 | inr v0 => default end) i e d2 IHl | right n => match v with | inl v0 => d2 | inr v0 => IHl a0 v0 end end) l)) *)
      subst.
      unfold eq_rect_r; rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      auto.
    - simpl in H1 |- *.
(* Goal: iff (if H i a0 then False else @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), Prop) (fun (a0 : A) (_ : F1 a0) => if H i a0 then True else False) (fun (a1 : A) (l : list A) (IHl : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), Prop) (a0 : A) (v : sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) => match v with | inl v0 => if H i a0 then True else False | inr v0 => if H i a0 then False else IHl a1 v0 end) l a1 c) (if H i a0 then False else @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), Prop) (fun (a0 : A) (_ : F2 a0) => if H i a0 then True else False) (fun (a1 : A) (l : list A) (IHl : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), Prop) (a0 : A) (v : sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) => match v with | inl v0 => if H i a0 then True else False | inr v0 => if H i a0 then False else IHl a1 v0 end) l a1 c0) *)
      destruct (H i a0); [tauto |].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply (IHl a1 c c0); auto.
      clear - H0.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
      intros ?i ?.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
      apply H0.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      right; auto.
Qed.

Lemma compact_sum_inj_JMeq: forall {A} (l: list A) {F1: A -> Type} {F2: A -> Type} (v1: compact_sum (map F1 l)) (v2: compact_sum (map F2 l)) H,
  (forall i, In i l -> @eq Type (F1 i) (F2 i)) ->
  JMeq v1 v2 ->
  (forall i, compact_sum_inj v1 i H <-> compact_sum_inj v2 i H).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: iff (@compact_sum_inj A F1 l v1 i H) (@compact_sum_inj A F2 l v2 i H) *)
  destruct l as [| a0 l]; [simpl; tauto |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v1 v2 H0 H1; induction l as [| a1 l]; intros.
  + simpl in *.
(* Goal: iff (if H i a0 then True else False) (if H i a0 then True else False) *)
    destruct (H i a0); [| tauto].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    tauto.
  + assert (@eq Type (F1 a0) (F2 a0)).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
      clear - H0.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
      apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
      left; simpl; auto.
    }
(* Goal: iff (@compact_sum_inj A F1 (@cons A a0 (@cons A a1 l)) v1 i H) (@compact_sum_inj A F2 (@cons A a0 (@cons A a1 l)) v2 i H) *)
    assert (@eq Type (compact_sum (map F1 (a1 :: l))) (compact_sum (map F2 (a1 :: l)))).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
(* Goal: @eq Type (compact_sum (@map A Type F1 (@cons A a1 l))) (compact_sum (@map A Type F2 (@cons A a1 l))) *)
      apply compact_sum_eq.
      clear - H0.
(* Goal: forall (a : A) (_ : @In A a (@cons A a1 l)), @eq Type (F1 a) (F2 a) *)
      intros i ?H.
(* Goal: @eq Type (F1 i) (F2 i) *)
      specialize (H0 i).
(* Goal: @eq Type (F1 i) (F2 i) *)
      spec H0; [right; auto |].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      symmetry; auto.
    }
(* Goal: iff (@compact_sum_inj A F1 (@cons A a0 (@cons A a1 l)) v1 i H) (@compact_sum_inj A F2 (@cons A a0 (@cons A a1 l)) v2 i H) *)
    simpl in H1.
(* Goal: iff (@compact_sum_inj A F1 (@cons A a0 (@cons A a1 l)) v1 i H) (@compact_sum_inj A F2 (@cons A a0 (@cons A a1 l)) v2 i H) *)
    solve_JMeq_sumtype H1.
    - simpl in *.
(* Goal: iff (if H i a0 then True else False) (if H i a0 then True else False) *)
      destruct (H i a0); [| tauto].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      tauto.
    - simpl in *.
(* Goal: iff (if H i a0 then False else @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), Prop) (fun (a0 : A) (_ : F1 a0) => if H i a0 then True else False) (fun (a1 : A) (l : list A) (IHl : forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end), Prop) (a0 : A) (v : sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) => match v with | inl v0 => if H i a0 then True else False | inr v0 => if H i a0 then False else IHl a1 v0 end) l a1 c) (if H i a0 then False else @list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), Prop) (fun (a0 : A) (_ : F2 a0) => if H i a0 then True else False) (fun (a1 : A) (l : list A) (IHl : forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end), Prop) (a0 : A) (v : sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) => match v with | inl v0 => if H i a0 then True else False | inr v0 => if H i a0 then False else IHl a1 v0 end) l a1 c0) *)
      destruct (H i a0); [tauto |].
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply (IHl a1 c c0); auto.
Qed.

Lemma upd_compact_prod_JMeq: forall A i (l: list A) {F1: A -> Type} {F2: A -> Type} d1 d2 (v1: compact_prod (map F1 l)) (v2: compact_prod (map F2 l)) H,
  (forall i, In i l -> @eq Type (F1 i) (F2 i)) ->
  JMeq d1 d2 ->
  JMeq v1 v2 ->
  JMeq (upd_compact_prod l v1 i d1 H) (upd_compact_prod l v2 i d2 H).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (match l return (forall _ : @In A i l, compact_sum (@map A Type F1 l)) with | nil => fun _ : @In A i (@nil A) => tt | cons a0 l => fun i0 : @In A i (@cons A a0 l) => @list_rect A (fun l0 : list A => forall (a1 : A) (_ : @In A i (@cons A a1 l0)), compact_sum (@map A Type F1 (@cons A a1 l0))) (fun (a1 : A) (i1 : @In A i (@cons A a1 (@nil A))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : @In A a (@cons A a1 (@nil A))), compact_sum (@map A Type F1 (@cons A a1 (@nil A)))) (fun (v0 : F1 a1) (_ : @In A a1 (@cons A a1 (@nil A))) => v0) i e d1 i1 | right n => match @aux0 A i a1 i1 n return (compact_sum (@map A Type F1 (@cons A a1 (@nil A)))) with end end) (fun (a1 : A) (l0 : list A) (IHl : forall (a2 : A) (_ : @In A i (@cons A a2 l0)), compact_sum (@map A Type F1 (@cons A a2 l0))) (a2 : A) (i1 : @In A i (@cons A a2 (@cons A a1 l0))) => match H i a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a3 : A) (_ : @In A a (@cons A a3 l0)), compact_sum (@map A Type F1 (@cons A a3 l0))) (_ : @In A a (@cons A a2 (@cons A a1 l0))), compact_sum (@map A Type F1 (@cons A a2 (@cons A a1 l0)))) (fun (v0 : F1 a2) (_ : forall (a3 : A) (_ : @In A a2 (@cons A a3 l0)), compact_sum (@map A Type F1 (@cons A a3 l0))) (_ : @In A a2 (@cons A a2 (@cons A a1 l0))) => @inl (F1 a2) match (fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l0 with | nil => F1 a1 | cons T l1 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l2 as T1) => sum t (compact_sum T1) end) ((fix map (l2 : list A) : list Type := match l2 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l0)) end v0) i e d1 IHl i1 | right n => @inr (F1 a2) (compact_sum (@map A Type F1 (@cons A a1 l0))) (IHl a1 (@aux1 A i a2 (@cons A a1 l0) i1 n)) end) l a0 i0 end H3) (compact_sum (@map A Type F2 l)) (match l return (forall _ : @In A i l, compact_sum (@map A Type F2 l)) with | nil => fun _ : @In A i (@nil A) => tt | cons a0 l => fun i0 : @In A i (@cons A a0 l) => @list_rect A (fun l0 : list A => forall (a1 : A) (_ : @In A i (@cons A a1 l0)), compact_sum (@map A Type F2 (@cons A a1 l0))) (fun (a1 : A) (i1 : @In A i (@cons A a1 (@nil A))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : @In A a (@cons A a1 (@nil A))), compact_sum (@map A Type F2 (@cons A a1 (@nil A)))) (fun (v0 : F2 a1) (_ : @In A a1 (@cons A a1 (@nil A))) => v0) i e d2 i1 | right n => match @aux0 A i a1 i1 n return (compact_sum (@map A Type F2 (@cons A a1 (@nil A)))) with end end) (fun (a1 : A) (l0 : list A) (IHl : forall (a2 : A) (_ : @In A i (@cons A a2 l0)), compact_sum (@map A Type F2 (@cons A a2 l0))) (a2 : A) (i1 : @In A i (@cons A a2 (@cons A a1 l0))) => match H i a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a3 : A) (_ : @In A a (@cons A a3 l0)), compact_sum (@map A Type F2 (@cons A a3 l0))) (_ : @In A a (@cons A a2 (@cons A a1 l0))), compact_sum (@map A Type F2 (@cons A a2 (@cons A a1 l0)))) (fun (v0 : F2 a2) (_ : forall (a3 : A) (_ : @In A a2 (@cons A a3 l0)), compact_sum (@map A Type F2 (@cons A a3 l0))) (_ : @In A a2 (@cons A a2 (@cons A a1 l0))) => @inl (F2 a2) match (fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l0 with | nil => F2 a1 | cons T l1 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l2 as T1) => sum t (compact_sum T1) end) ((fix map (l2 : list A) : list Type := match l2 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l0)) end v0) i e d2 IHl i1 | right n => @inr (F2 a2) (compact_sum (@map A Type F2 (@cons A a1 l0))) (IHl a1 (@aux1 A i a2 (@cons A a1 l0) i1 n)) end) l a0 i0 end H3) *)
  destruct l as [| a0 l]; [simpl; auto |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 v1 v2 H2 H0; induction l as [| a1 l]; intros.
  + simpl.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    destruct (H i a0); auto.
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3) *)
    subst i.
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d1 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a1 a) False), F1 a1) (fun (v0 : F1 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d1 i | right n => match @aux0 A a0 a1 i n return (F1 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 e d1 IHl i | right n => @inr (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d2 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a1 a) False), F2 a1) (fun (v0 : F2 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d2 i | right n => match @aux0 A a0 a1 i n return (F2 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 e d2 IHl i | right n => @inr (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) *)
    unfold eq_rect_r.
    rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    auto.
  + simpl.
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    assert (JMeq (fst v1) (fst v2)).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply @JMeq_fst; auto.
      + apply H0; simpl; auto.
      + apply (@compact_prod_eq _ F1 F2 (a1 :: l)).
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
        intros.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
        apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
        simpl; auto.
    }
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    assert (JMeq (snd v1) (snd v2)).
(* Goal: @JMeq match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) *)
(* Goal: @JMeq (prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, prod (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a0 => @pair (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) i e d1 | right n => @pair (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end (@fst (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun (a0 : A) (v : F1 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F1 a, F1 a0) (fun v0 : F1 a0 => v0) i e d1 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => prod (F1 a1) (compact_prod (@map A Type F1 l)) end) (a1 : A) (v : prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F1 a, prod (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end) (fun v0 : F1 a1 => @pair (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) i e d1 | right n0 => @pair (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => prod (F1 a0) (compact_prod (@map A Type F1 l)) end (@fst (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v) (IHl a0 (@snd (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => prod (F1 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v)) end) l a1 (@snd (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => prod (F1 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v1)) end (prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, prod (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a0 => @pair (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) i e d2 | right n => @pair (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end (@fst (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2) (@list_rect A (fun l : list A => forall (a0 : A) (_ : match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun (a0 : A) (v : F2 a0) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall _ : F2 a, F2 a0) (fun v0 : F2 a0 => v0) i e d2 | right n0 => v end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => prod (F2 a1) (compact_prod (@map A Type F2 l)) end) (a1 : A) (v : prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall _ : F2 a, prod (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end) (fun v0 : F2 a1 => @pair (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) i e d2 | right n0 => @pair (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => prod (F2 a0) (compact_prod (@map A Type F2 l)) end (@fst (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v) (IHl a0 (@snd (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => prod (F2 a0) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => prod t (compact_prod T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v)) end) l a1 (@snd (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => prod (F2 a1) ((fix compact_prod (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => prod t (compact_prod T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v2)) end *)
    {
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply @JMeq_snd; auto.
      + apply H0; simpl; auto.
      + apply (@compact_prod_eq _ F1 F2 (a1 :: l)).
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
        intros.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
        apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
        simpl; auto.
    }
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e0 d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e0 d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3 | right n => @inr (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n0 => match @aux0 A i a0 i0 n0 return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n0 => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n0)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) end (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e0 d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e0 d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3 | right n => @inr (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n0 => match @aux0 A i a0 i0 n0 return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n0 => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n0)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) end *)
    destruct (H i a0).
    - subst i.
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d1 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a1 a) False), F1 a1) (fun (v0 : F1 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d1 i | right n => match @aux0 A a0 a1 i n return (F1 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 e d1 IHl i | right n => @inr (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d2 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a1 a) False), F2 a1) (fun (v0 : F2 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d2 i | right n => match @aux0 A a0 a1 i n return (F2 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 e d2 IHl i | right n => @inr (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) *)
      unfold eq_rect_r.
      rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply @JMeq_pair; auto.
    - apply @JMeq_pair; auto.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply IHl; auto.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
      intros; apply H0; simpl; auto.
Qed.

Lemma upd_compact_sum_JMeq: forall A i (l: list A) {F1: A -> Type} {F2: A -> Type} d1 d2 (v1: compact_sum (map F1 l)) (v2: compact_sum (map F2 l)) H,
  (forall i, In i l -> @eq Type (F1 i) (F2 i)) ->
  JMeq d1 d2 ->
  JMeq v1 v2 ->
  JMeq (upd_compact_sum l v1 i d1 H) (upd_compact_sum l v2 i d2 H).
Proof.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  intros.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (@upd_compact_sum A F1 l v1 i d1 H) (compact_sum (@map A Type F2 l)) (@upd_compact_sum A F2 l v2 i d2 H) *)
  unfold upd_compact_sum.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
  destruct (in_dec H i l) as [?H | ?H]; auto.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (match l return (forall _ : @In A i l, compact_sum (@map A Type F1 l)) with | nil => fun _ : @In A i (@nil A) => tt | cons a0 l => fun i0 : @In A i (@cons A a0 l) => @list_rect A (fun l0 : list A => forall (a1 : A) (_ : @In A i (@cons A a1 l0)), compact_sum (@map A Type F1 (@cons A a1 l0))) (fun (a1 : A) (i1 : @In A i (@cons A a1 (@nil A))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : @In A a (@cons A a1 (@nil A))), compact_sum (@map A Type F1 (@cons A a1 (@nil A)))) (fun (v0 : F1 a1) (_ : @In A a1 (@cons A a1 (@nil A))) => v0) i e d1 i1 | right n => match @aux0 A i a1 i1 n return (compact_sum (@map A Type F1 (@cons A a1 (@nil A)))) with end end) (fun (a1 : A) (l0 : list A) (IHl : forall (a2 : A) (_ : @In A i (@cons A a2 l0)), compact_sum (@map A Type F1 (@cons A a2 l0))) (a2 : A) (i1 : @In A i (@cons A a2 (@cons A a1 l0))) => match H i a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a3 : A) (_ : @In A a (@cons A a3 l0)), compact_sum (@map A Type F1 (@cons A a3 l0))) (_ : @In A a (@cons A a2 (@cons A a1 l0))), compact_sum (@map A Type F1 (@cons A a2 (@cons A a1 l0)))) (fun (v0 : F1 a2) (_ : forall (a3 : A) (_ : @In A a2 (@cons A a3 l0)), compact_sum (@map A Type F1 (@cons A a3 l0))) (_ : @In A a2 (@cons A a2 (@cons A a1 l0))) => @inl (F1 a2) match (fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l0 with | nil => F1 a1 | cons T l1 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l2 as T1) => sum t (compact_sum T1) end) ((fix map (l2 : list A) : list Type := match l2 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l0)) end v0) i e d1 IHl i1 | right n => @inr (F1 a2) (compact_sum (@map A Type F1 (@cons A a1 l0))) (IHl a1 (@aux1 A i a2 (@cons A a1 l0) i1 n)) end) l a0 i0 end H3) (compact_sum (@map A Type F2 l)) (match l return (forall _ : @In A i l, compact_sum (@map A Type F2 l)) with | nil => fun _ : @In A i (@nil A) => tt | cons a0 l => fun i0 : @In A i (@cons A a0 l) => @list_rect A (fun l0 : list A => forall (a1 : A) (_ : @In A i (@cons A a1 l0)), compact_sum (@map A Type F2 (@cons A a1 l0))) (fun (a1 : A) (i1 : @In A i (@cons A a1 (@nil A))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : @In A a (@cons A a1 (@nil A))), compact_sum (@map A Type F2 (@cons A a1 (@nil A)))) (fun (v0 : F2 a1) (_ : @In A a1 (@cons A a1 (@nil A))) => v0) i e d2 i1 | right n => match @aux0 A i a1 i1 n return (compact_sum (@map A Type F2 (@cons A a1 (@nil A)))) with end end) (fun (a1 : A) (l0 : list A) (IHl : forall (a2 : A) (_ : @In A i (@cons A a2 l0)), compact_sum (@map A Type F2 (@cons A a2 l0))) (a2 : A) (i1 : @In A i (@cons A a2 (@cons A a1 l0))) => match H i a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a3 : A) (_ : @In A a (@cons A a3 l0)), compact_sum (@map A Type F2 (@cons A a3 l0))) (_ : @In A a (@cons A a2 (@cons A a1 l0))), compact_sum (@map A Type F2 (@cons A a2 (@cons A a1 l0)))) (fun (v0 : F2 a2) (_ : forall (a3 : A) (_ : @In A a2 (@cons A a3 l0)), compact_sum (@map A Type F2 (@cons A a3 l0))) (_ : @In A a2 (@cons A a2 (@cons A a1 l0))) => @inl (F2 a2) match (fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l0 with | nil => F2 a1 | cons T l1 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l2 as T1) => sum t (compact_sum T1) end) ((fix map (l2 : list A) : list Type := match l2 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l0)) end v0) i e d2 IHl i1 | right n => @inr (F2 a2) (compact_sum (@map A Type F2 (@cons A a1 l0))) (IHl a1 (@aux1 A i a2 (@cons A a1 l0) i1 n)) end) l a0 i0 end H3) *)
  clear v1 v2 H2.
(* Goal: @JMeq (compact_sum (@map A Type F1 l)) (match l return (forall _ : @In A i l, compact_sum (@map A Type F1 l)) with | nil => fun _ : @In A i (@nil A) => tt | cons a0 l => fun i0 : @In A i (@cons A a0 l) => @list_rect A (fun l0 : list A => forall (a1 : A) (_ : @In A i (@cons A a1 l0)), compact_sum (@map A Type F1 (@cons A a1 l0))) (fun (a1 : A) (i1 : @In A i (@cons A a1 (@nil A))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : @In A a (@cons A a1 (@nil A))), compact_sum (@map A Type F1 (@cons A a1 (@nil A)))) (fun (v0 : F1 a1) (_ : @In A a1 (@cons A a1 (@nil A))) => v0) i e d1 i1 | right n => match @aux0 A i a1 i1 n return (compact_sum (@map A Type F1 (@cons A a1 (@nil A)))) with end end) (fun (a1 : A) (l0 : list A) (IHl : forall (a2 : A) (_ : @In A i (@cons A a2 l0)), compact_sum (@map A Type F1 (@cons A a2 l0))) (a2 : A) (i1 : @In A i (@cons A a2 (@cons A a1 l0))) => match H i a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a3 : A) (_ : @In A a (@cons A a3 l0)), compact_sum (@map A Type F1 (@cons A a3 l0))) (_ : @In A a (@cons A a2 (@cons A a1 l0))), compact_sum (@map A Type F1 (@cons A a2 (@cons A a1 l0)))) (fun (v0 : F1 a2) (_ : forall (a3 : A) (_ : @In A a2 (@cons A a3 l0)), compact_sum (@map A Type F1 (@cons A a3 l0))) (_ : @In A a2 (@cons A a2 (@cons A a1 l0))) => @inl (F1 a2) match (fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l0 with | nil => F1 a1 | cons T l1 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l2 as T1) => sum t (compact_sum T1) end) ((fix map (l2 : list A) : list Type := match l2 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l0)) end v0) i e d1 IHl i1 | right n => @inr (F1 a2) (compact_sum (@map A Type F1 (@cons A a1 l0))) (IHl a1 (@aux1 A i a2 (@cons A a1 l0) i1 n)) end) l a0 i0 end H3) (compact_sum (@map A Type F2 l)) (match l return (forall _ : @In A i l, compact_sum (@map A Type F2 l)) with | nil => fun _ : @In A i (@nil A) => tt | cons a0 l => fun i0 : @In A i (@cons A a0 l) => @list_rect A (fun l0 : list A => forall (a1 : A) (_ : @In A i (@cons A a1 l0)), compact_sum (@map A Type F2 (@cons A a1 l0))) (fun (a1 : A) (i1 : @In A i (@cons A a1 (@nil A))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : @In A a (@cons A a1 (@nil A))), compact_sum (@map A Type F2 (@cons A a1 (@nil A)))) (fun (v0 : F2 a1) (_ : @In A a1 (@cons A a1 (@nil A))) => v0) i e d2 i1 | right n => match @aux0 A i a1 i1 n return (compact_sum (@map A Type F2 (@cons A a1 (@nil A)))) with end end) (fun (a1 : A) (l0 : list A) (IHl : forall (a2 : A) (_ : @In A i (@cons A a2 l0)), compact_sum (@map A Type F2 (@cons A a2 l0))) (a2 : A) (i1 : @In A i (@cons A a2 (@cons A a1 l0))) => match H i a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a3 : A) (_ : @In A a (@cons A a3 l0)), compact_sum (@map A Type F2 (@cons A a3 l0))) (_ : @In A a (@cons A a2 (@cons A a1 l0))), compact_sum (@map A Type F2 (@cons A a2 (@cons A a1 l0)))) (fun (v0 : F2 a2) (_ : forall (a3 : A) (_ : @In A a2 (@cons A a3 l0)), compact_sum (@map A Type F2 (@cons A a3 l0))) (_ : @In A a2 (@cons A a2 (@cons A a1 l0))) => @inl (F2 a2) match (fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l0 with | nil => F2 a1 | cons T l1 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l2 as T1) => sum t (compact_sum T1) end) ((fix map (l2 : list A) : list Type := match l2 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l0)) end v0) i e d2 IHl i1 | right n => @inr (F2 a2) (compact_sum (@map A Type F2 (@cons A a1 l0))) (IHl a1 (@aux1 A i a2 (@cons A a1 l0) i1 n)) end) l a0 i0 end H3) *)
  destruct l as [| a0 l]; [simpl; auto |].
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
  revert a0 H0 H3; induction l as [| a1 l]; intros.
  + simpl.
(* Goal: @JMeq (F1 a0) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 H3 | right n => match @aux0 A i a0 H3 n return (F1 a0) with end end (F2 a0) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 H3 | right n => match @aux0 A i a0 H3 n return (F2 a0) with end end *)
    destruct (H i a0); [| destruct H3; [congruence | inv i0]].
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3) *)
    subst i.
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d1 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a1 a) False), F1 a1) (fun (v0 : F1 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d1 i | right n => match @aux0 A a0 a1 i n return (F1 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 e d1 IHl i | right n => @inr (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d2 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a1 a) False), F2 a1) (fun (v0 : F2 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d2 i | right n => match @aux0 A a0 a1 i n return (F2 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 e d2 IHl i | right n => @inr (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) *)
    unfold eq_rect_r.
    rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
    auto.
  + simpl.
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e0 d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e0 d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3 | right n => @inr (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n0 => match @aux0 A i a0 i0 n0 return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n0 => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n0)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) end (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e0 => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e0 d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e0 => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e0 d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l) H3 | right n => @inr (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n0 => match @aux0 A i a0 i0 n0 return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n0 => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n0)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) end *)
    destruct (H i a0).
    - subst i.
(* Goal: @JMeq (sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a0) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F1 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d1 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a1 a) False), F1 a1) (fun (v0 : F1 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d1 i | right n => match @aux0 A a0 a1 i n return (F1 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F1 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F1 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) a0 e d1 IHl i | right n => @inr (F1 a2) match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) (sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (@eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a0) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a0) (_ : forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a0 a0) (or (@eq A a1 a0) (@In A a0 l))) => @inl (F2 a0) match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 (@eq_refl A a0) d2 (@list_rect A (fun l : list A => forall (a1 : A) (_ : or (@eq A a1 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (a1 : A) (i : or (@eq A a1 a0) False) => match H a0 a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a1 a) False), F2 a1) (fun (v0 : F2 a1) (_ : or (@eq A a1 a1) False) => v0) a0 e d2 i | right n => match @aux0 A a0 a1 i n return (F2 a1) with end end) (fun (a1 : A) (l : list A) (IHl : forall (a2 : A) (_ : or (@eq A a2 a0) (@In A a0 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (a2 : A) (i : or (@eq A a2 a0) (or (@eq A a1 a0) (@In A a0 l))) => match H a0 a2 with | left e => @eq_rect_r A a2 (fun a : A => forall (_ : F2 a) (_ : forall (a0 : A) (_ : or (@eq A a0 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a) (or (@eq A a1 a) (@In A a l))), sum (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a2) (_ : forall (a0 : A) (_ : or (@eq A a0 a2) (@In A a2 l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a2 a2) (or (@eq A a1 a2) (@In A a2 l))) => @inl (F2 a2) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) a0 e d2 IHl i | right n => @inr (F2 a2) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (IHl a1 (@aux1 A a0 a2 (@cons A a1 l) i n)) end) l) H3) *)
      unfold eq_rect_r.
      rewrite <- !eq_rect_eq.
(* Goal: @JMeq (F1 a0) d1 (F2 a0) d2 *)
      apply @JMeq_inl; auto.
(* Goal: @eq Type match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a1 | cons T l0 => sum (F1 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end match (fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a1 | cons T l0 => sum (F2 a1) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l as T1) => sum t (compact_sum T1) end) ((fix map (l : list A) : list Type := match l with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end *)
      apply (@compact_sum_eq _ F1 F2 (a1 :: l)).
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
      intros.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
      apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
      simpl; auto.
    - apply @JMeq_inr; auto.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
      * apply H0; simpl; auto.
(* Goal: @JMeq match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F1 a) (_ : or (@eq A a0 a) False), F1 a0) (fun (v0 : F1 a0) (_ : or (@eq A a0 a0) False) => v0) i e d1 i0 | right n => match @aux0 A i a0 i0 n return (F1 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F1 l with | nil => F1 a1 | cons T l0 => sum (F1 a1) (compact_sum (@map A Type F1 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F1 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end) (fun (v0 : F1 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F1 l with | nil => F1 a2 | cons T l0 => sum (F1 a2) (compact_sum (@map A Type F1 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F1 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l with | nil => F1 a0 | cons T l0 => sum (F1 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F1 a) (map t) end) l)) end v0) i e d1 IHl i0 | right n => @inr (F1 a1) match @map A Type F1 l with | nil => F1 a0 | cons T l0 => sum (F1 a0) (compact_sum (@map A Type F1 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end (@list_rect A (fun l : list A => forall (a0 : A) (_ : or (@eq A a0 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (a0 : A) (i0 : or (@eq A a0 i) False) => match H i a0 with | left e => @eq_rect_r A a0 (fun a : A => forall (_ : F2 a) (_ : or (@eq A a0 a) False), F2 a0) (fun (v0 : F2 a0) (_ : or (@eq A a0 a0) False) => v0) i e d2 i0 | right n => match @aux0 A i a0 i0 n return (F2 a0) with end end) (fun (a0 : A) (l : list A) (IHl : forall (a1 : A) (_ : or (@eq A a1 i) (@In A i l)), match @map A Type F2 l with | nil => F2 a1 | cons T l0 => sum (F2 a1) (compact_sum (@map A Type F2 l)) end) (a1 : A) (i0 : or (@eq A a1 i) (or (@eq A a0 i) (@In A i l))) => match H i a1 with | left e => @eq_rect_r A a1 (fun a : A => forall (_ : F2 a) (_ : forall (a2 : A) (_ : or (@eq A a2 a) (@In A a l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a) (or (@eq A a0 a) (@In A a l))), sum (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end) (fun (v0 : F2 a1) (_ : forall (a2 : A) (_ : or (@eq A a2 a1) (@In A a1 l)), match @map A Type F2 l with | nil => F2 a2 | cons T l0 => sum (F2 a2) (compact_sum (@map A Type F2 l)) end) (_ : or (@eq A a1 a1) (or (@eq A a0 a1) (@In A a1 l))) => @inl (F2 a1) match (fix map (l0 : list A) : list Type := match l0 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l with | nil => F2 a0 | cons T l0 => sum (F2 a0) ((fix compact_sum (T0 : list Type) : Type := match T0 with | nil => unit | cons t (nil as T1) => t | cons t (cons T2 l1 as T1) => sum t (compact_sum T1) end) ((fix map (l1 : list A) : list Type := match l1 with | nil => @nil Type | cons a t => @cons Type (F2 a) (map t) end) l)) end v0) i e d2 IHl i0 | right n => @inr (F2 a1) match @map A Type F2 l with | nil => F2 a0 | cons T l0 => sum (F2 a0) (compact_sum (@map A Type F2 l)) end (IHl a0 (@aux1 A i a1 (@cons A a0 l) i0 n)) end) l a1 (@aux1 A i a0 (@cons A a1 l) H3 n)) *)
      * apply IHl.
(* Goal: forall (i : A) (_ : @In A i (@cons A a1 l)), @eq Type (F1 i) (F2 i) *)
        intros.
(* Goal: @eq Type (F1 i0) (F2 i0) *)
        apply H0.
(* Goal: @In A i0 (@cons A a0 (@cons A a1 l)) *)
        simpl; auto.
Qed.
