more robust variant_free: avoid clash with consts name space (e.g. consts "x", "xa", etc.);
authorwenzelm
Sun, 26 May 2013 20:03:47 +0200
changeset 52158 d5fa81343322
parent 52157 ba6b2876ef5a
child 52159 432e29ff9f14
more robust variant_free: avoid clash with consts name space (e.g. consts "x", "xa", etc.);
src/HOL/Tools/case_translation.ML
--- a/src/HOL/Tools/case_translation.ML	Sun May 26 19:29:15 2013 +0200
+++ b/src/HOL/Tools/case_translation.ML	Sun May 26 20:03:47 2013 +0200
@@ -107,6 +107,10 @@
         val consts = Proof_Context.consts_of ctxt;
         fun is_const s = can (Consts.the_constraint consts) (Consts.intern consts s);
 
+        fun variant_free x used =
+          let val (x', used') = Name.variant x used
+          in if is_const x' then variant_free x' used' else (x', used') end;
+
         fun abs p tTs t =
           Syntax.const @{const_syntax case_abs} $
             fold constrain_Abs tTs (absfree p t);
@@ -120,7 +124,7 @@
 
         (* replace occurrences of dummy_pattern by distinct variables *)
         fun replace_dummies (Const (@{const_syntax dummy_pattern}, T)) used =
-              let val (x, used') = Name.variant "x" used
+              let val (x, used') = variant_free "x" used
               in (Free (x, T), used') end
           | replace_dummies (t $ u) used =
               let