fixed bugs in lambda-lifting code -- ensure distinct names for variables
authorblanchet
Fri, 18 Nov 2011 11:47:12 +0100
changeset 45565 9c335d69a362
parent 45564 2231a151db59
child 45566 da05ce2de5a8
fixed bugs in lambda-lifting code -- ensure distinct names for variables
src/HOL/Tools/ATP/atp_translate.ML
src/HOL/Tools/Metis/metis_translate.ML
--- a/src/HOL/Tools/ATP/atp_translate.ML	Fri Nov 18 11:47:12 2011 +0100
+++ b/src/HOL/Tools/ATP/atp_translate.ML	Fri Nov 18 11:47:12 2011 +0100
@@ -684,10 +684,11 @@
     (if String.isPrefix lam_lifted_prefix s then Const else Free) x
   | constify_lifted t = t
 
-(* Requires bound variables to have distinct names and not to clash with any
-   schematic variables (as should be the case right after lambda-lifting). *)
-fun open_form (Const (@{const_name All}, _) $ Abs (s, T, t)) =
-    open_form (subst_bound (Var ((s, 0), T), t))
+(* Requires bound variables not to clash with any schematic variables (as should
+   be the case right after lambda-lifting). *)
+fun open_form (Const (@{const_name All}, _) $ Abs (_, T, t)) =
+    subst_bound (Var ((Name.uu ^ Int.toString (size_of_term t), 0), T), t)
+    |> open_form
   | open_form t = t
 
 fun lift_lams_part_1 ctxt type_enc =
--- a/src/HOL/Tools/Metis/metis_translate.ML	Fri Nov 18 11:47:12 2011 +0100
+++ b/src/HOL/Tools/Metis/metis_translate.ML	Fri Nov 18 11:47:12 2011 +0100
@@ -116,7 +116,8 @@
                    case AList.lookup (op =) lambdas s of
                      SOME t =>
                      Const (@{const_name Metis.lambda}, dummyT)
-                     $ map_types (map_type_tvar (K dummyT)) t
+                     $ map_types (map_type_tvar (K dummyT))
+                                 (reveal_lambda_lifted lambdas t)
                    | NONE => t
                  else
                    t