factured out common functionality of prefixing the dt-names with a string
authorChristian Urban <urbanc@in.tum.de>
Wed, 28 Apr 2010 06:40:10 +0200
changeset 1966 b6b3374a402d
parent 1965 4a3c05fe2bc5
child 1967 700024ec18da
factured out common functionality of prefixing the dt-names with a string
Nominal/NewFv.thy
Nominal/Perm.thy
--- a/Nominal/NewFv.thy	Wed Apr 28 06:24:10 2010 +0200
+++ b/Nominal/NewFv.thy	Wed Apr 28 06:40:10 2010 +0200
@@ -225,8 +225,7 @@
   val thy = ProofContext.theory_of lthy;
   val {descr, sorts, ...} = dt_info;
 
-  val fv_names = Datatype_Prop.indexify_names (map (fn (i, _) =>
-    "fv_" ^ Datatype_Aux.name_of_typ (nth_dtyp descr sorts i)) descr);
+  val fv_names = prefix_dt_names descr sorts "fv_"
 
   val fv_types = map (fn (i, _) => nth_dtyp descr sorts i --> @{typ "atom set"}) descr;
   val fv_frees = map Free (fv_names ~~ fv_types);
--- a/Nominal/Perm.thy	Wed Apr 28 06:24:10 2010 +0200
+++ b/Nominal/Perm.thy	Wed Apr 28 06:40:10 2010 +0200
@@ -12,6 +12,19 @@
 *}
 
 ML {*
+(* generates for every datatype a name str ^ dt_name *)
+fun prefix_dt_names dt_descr sorts str = 
+let
+  fun get_nth_name (i, _) = 
+    Datatype_Aux.name_of_typ (nth_dtyp dt_descr sorts i) 
+in
+  Datatype_Prop.indexify_names 
+    (map (prefix str o get_nth_name) dt_descr)
+end
+*}
+
+
+ML {*
 (* permutation function for one argument 
    
     - in case the argument is recursive it returns 
@@ -108,8 +121,7 @@
   val all_full_tnames = map (fn (_, (n, _, _)) => n) dt_descr;
   val full_tnames = List.take (all_full_tnames, dt_nos);
 
-  val perm_fn_names = Datatype_Prop.indexify_names (map (fn (i, _) =>
-    "permute_" ^ Datatype_Aux.name_of_typ (nth_dtyp dt_descr sorts i)) dt_descr);
+  val perm_fn_names = prefix_dt_names dt_descr sorts "permute_"
 
   val perm_types = map (fn (i, _) => perm_ty (nth_dtyp dt_descr sorts i)) dt_descr