@@ -23,10 +23,10 @@ Proof.
2323 intros [= <- <- <-]. intuition auto.
2424Qed .
2525
26- Fixpoint lookup_inductive_assoc {A} (Σ : list (inductive × A)) (kn : inductive ) {struct Σ} : option A :=
26+ Fixpoint lookup_kername_assoc {A} (Σ : list (kername × A)) (kn : kername ) {struct Σ} : option A :=
2727 match Σ with
2828 | [] => None
29- | d :: tl => if kn == d.1 then Some d.2 else lookup_inductive_assoc tl kn
29+ | d :: tl => if kn == d.1 then Some d.2 else lookup_kername_assoc tl kn
3030 end .
3131
3232Equations filter_map {A B} (f : A -> option B) (l : list A) : list B :=
@@ -39,9 +39,13 @@ Section Remap.
3939 Context (Σ : global_declarations).
4040 Context (mapping : extract_inductives).
4141
42- Definition lookup_constructor_mapping i c : option kername :=
43- trs <- lookup_inductive_assoc mapping i ;;
44- nth_error trs.(cstrs) c.
42+ Definition lookup_inductive_assoc i : option extract_inductive :=
43+ trs <- lookup_kername_assoc mapping (inductive_mind i) ;;
44+ nth_error trs (inductive_ind i).
45+
46+ Definition lookup_constructor_mapping (i : inductive) c : option kername :=
47+ tri <- lookup_inductive_assoc i ;;
48+ nth_error tri.(cstrs) c.
4549
4650 Definition lookup_constructor_remapping i c args :=
4751 match lookup_constructor_mapping i c with
@@ -62,7 +66,7 @@ Section Remap.
6266 end .
6367
6468 Definition remap_case i c brs :=
65- match lookup_inductive_assoc mapping (fst i) with
69+ match lookup_inductive_assoc (fst i) with
6670 | None => tCase i c brs
6771 | Some tr =>
6872 mkApps (tConst tr.(elim)) (c :: map make_branch brs)
@@ -93,24 +97,26 @@ Section Remap.
9397 Definition remap_constant_decl cb :=
9498 {| cst_body := option_map remap cb.(cst_body) |}.
9599
96- Definition remaped_one_ind kn i (oib : one_inductive_body) : bool :=
97- match lookup_inductive_assoc mapping {| inductive_mind := kn; inductive_ind := i |} with
98- | None => false
99- | Some trs => true
100- end .
100+ Definition axiom (kn : kername) := (kn, ConstantDecl {| cst_body := None |}).
101+ Definition remapping_decls tr :=
102+ let cstrs := map axiom tr.(cstrs) in
103+ axiom tr.(elim) :: cstrs.
101104
102105 Definition remap_inductive_decl kn idecl :=
103- let remapings := mapi (remaped_one_ind kn) idecl.(ind_bodies) in
104- List.forallb (fun b => b) remapings.
106+ match lookup_kername_assoc mapping kn with
107+ | None => [(kn, InductiveDecl idecl)]
108+ | Some trs =>
109+ concat (map remapping_decls trs)
110+ end .
105111
106112 Definition remap_decl d :=
107113 match d.2 with
108- | ConstantDecl cb => Some (d.1, ConstantDecl (remap_constant_decl cb))
109- | InductiveDecl idecl => if remap_inductive_decl d.1 idecl then None else Some d
114+ | ConstantDecl cb => [ (d.1, ConstantDecl (remap_constant_decl cb))]
115+ | InductiveDecl idecl => remap_inductive_decl d.1 idecl
110116 end .
111117
112118 Definition remap_env Σ :=
113- filter_map ( remap_decl) Σ.
119+ concat (map ( remap_decl) Σ) .
114120
115121End Remap.
116122
0 commit comments