Length fix for nested recursions.
authorCezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 02 Mar 2010 13:28:54 +0100
changeset 1302 d3101a5b9c4d
parent 1301 c145c380e195
child 1303 c28403308b34
Length fix for nested recursions.
Nominal/Fv.thy
Nominal/Test.thy
--- a/Nominal/Fv.thy	Tue Mar 02 12:28:07 2010 +0100
+++ b/Nominal/Fv.thy	Tue Mar 02 13:28:54 2010 +0100
@@ -54,6 +54,13 @@
       in the database.
 *)
 
+ML {*
+fun map2i _ [] [] = []
+  | map2i f (x :: xs) (y :: ys) = f x y :: map2i f xs ys
+  | map2i f (x :: xs) [] = f x [] :: map2i f xs []
+  | map2i _ _ _ = raise UnequalLengths;
+*}
+
 (* TODO: should be const_name union *)
 ML {*
   open Datatype_Aux; (* typ_of_dtyp, DtRec, ... *);
@@ -185,8 +192,8 @@
     in
       (fv_eq, alpha_eq)
     end;
-  fun fv_alpha_eq (i, (_, _, constrs)) binds = map2 (fv_alpha_constr i) constrs binds;
-  val (fv_eqs, alpha_eqs) = split_list (flat (map2 fv_alpha_eq descr bindsall))
+  fun fv_alpha_eq (i, (_, _, constrs)) binds = map2i (fv_alpha_constr i) constrs binds;
+  val (fv_eqs, alpha_eqs) = split_list (flat (map2i fv_alpha_eq descr bindsall))
   val add_binds = map (fn x => (Attrib.empty_binding, x))
   val (fvs, lthy') = (Primrec.add_primrec
     (map (fn s => (Binding.name s, NONE, NoSyn)) fv_names) (add_binds fv_eqs) lthy)
--- a/Nominal/Test.thy	Tue Mar 02 12:28:07 2010 +0100
+++ b/Nominal/Test.thy	Tue Mar 02 13:28:54 2010 +0100
@@ -68,12 +68,12 @@
 
 text {* example type schemes *}
 
-(* does not work yet 
-nominal_datatype t = 
-  Var "name" 
+nominal_datatype t =
+  Var "name"
 | Fun "t" "t"
 
-nominal_datatype tyS = 
+(* does not work yet
+nominal_datatype tyS =
   All xs::"name list" ty::"t_raw" bind xs in ty
 *)
 
@@ -137,12 +137,12 @@
 
 (* example 4 from Terms.thy *)
 
-(* does not work yet
+
 nominal_datatype trm4 =
   Vr4 "name"
 | Ap4 "trm4" "trm4 list"
 | Lm4 x::"name" t::"trm4"  bind x in t
-*)
+
 
 (* example 5 from Terms.thy *)