Avoid a possible variable name conflict in instantiating a theorem.
authorThomas Sewell <tsewell@nicta.com.au>
Mon, 28 Sep 2009 15:37:19 +1000
changeset 32757 4e97fc468a53
parent 32756 fb32a99a7689
child 32758 cd47afaf0d78
Avoid a possible variable name conflict in instantiating a theorem. Instantiating a theorem variable with new variables created a possible variable name conflict if a record was defined with a field named 'f', 'x' etc. Using variable indices of 1 avoids the problem.
src/HOL/Tools/record.ML
--- a/src/HOL/Tools/record.ML	Mon Sep 28 14:16:01 2009 +1000
+++ b/src/HOL/Tools/record.ML	Mon Sep 28 15:37:19 2009 +1000
@@ -2005,9 +2005,6 @@
 
     val r_rec0 = mk_rec all_vars_more 0;
     val r_rec_unit0 = mk_rec (all_vars@[HOLogic.unit]) 0;
-    val r_rec0_Vars = let
-        fun to_Var (Free (c, T)) = Var ((c, 0), T);
-      in mk_rec (map to_Var all_vars_more) 0 end;
 
     fun r n = Free (rN, rec_schemeT n)
     val r0 = r 0;
@@ -2075,6 +2072,12 @@
        pair, from which we can derive the bodies of our selector and
        updator and their convs. *)
     fun get_access_update_thms () = let
+        val r_rec0_Vars = let
+            (* pick variable indices of 1 to avoid possible variable
+               collisions with existing variables in updacc_eq_triv *)
+            fun to_Var (Free (c, T)) = Var ((c, 1), T);
+          in mk_rec (map to_Var all_vars_more) 0 end;
+
         val cterm_rec = cterm_of extension_thy r_rec0;
         val cterm_vrs = cterm_of extension_thy r_rec0_Vars;
         val insts     = [("v", cterm_rec), ("v'", cterm_vrs)];