made N2M more robust w.r.t. identical nested types
authortraytel
Fri, 14 Feb 2014 14:54:08 +0100
changeset 55478 3a6efda01da4
parent 55477 6ec4d06297a5
child 55479 ece4910c3ea0
made N2M more robust w.r.t. identical nested types
src/HOL/Tools/BNF/bnf_fp_n2m.ML
--- a/src/HOL/Tools/BNF/bnf_fp_n2m.ML	Fri Feb 14 13:45:29 2014 +0100
+++ b/src/HOL/Tools/BNF/bnf_fp_n2m.ML	Fri Feb 14 14:54:08 2014 +0100
@@ -195,9 +195,12 @@
         val approx_fold = un_fold_of raw_iters
           |> force_typ names_lthy
             (replicate (nth ns i) dummyT ---> (if is_rec then TU_rec else TU));
-        val TUs = binder_fun_types (Term.typ_subst_atomic (Xs ~~ fpTs) (fastype_of approx_fold));
-        val js = find_indices Type.could_unify
-          TUs (map (Term.typ_subst_atomic (Xs ~~ fpTs)) fold_strTs);
+        val subst = Term.typ_subst_atomic (Xs ~~ fpTs);
+        val TUs = map_split dest_co_algT (binder_fun_types (fastype_of approx_fold))
+          |>> map subst
+          |> uncurry (map2 mk_co_algT);
+        val js = find_indices Type.could_unify TUs
+          (map2 (fn T => fn U => mk_co_algT (subst T) U) fold_preTs Xs);
         val Tpats = map (fn j => mk_co_algT (nth fold_pre_deads_only_Ts j) (nth Xs j)) js;
         val iter = raw_iters |> (if is_rec then co_rec_of else un_fold_of);
       in