src/Pure/variable.ML
changeset 20003 aac2c0d29751
parent 19926 feb4d150cfd8
child 20084 aa320957f00c
--- a/src/Pure/variable.ML	Tue Jul 04 19:49:53 2006 +0200
+++ b/src/Pure/variable.ML	Tue Jul 04 19:49:54 2006 +0200
@@ -271,9 +271,8 @@
 fun gen_export inst inner outer ths =
   let
     val ths' = map Thm.adjust_maxidx_thm ths;
-    val maxidx = fold Thm.maxidx_thm ths' ~1;
     val inner' = fold (declare_occs o Thm.full_prop_of) ths' inner;
-  in map (Thm.generalize (inst inner' outer) (maxidx + 1)) ths' end;
+  in map (Thm.generalize (inst inner' outer) (fold Thm.maxidx_thm ths' ~1 + 1)) ths' end;
 
 val exportT = gen_export (rpair [] oo exportT_inst);
 val export = gen_export export_inst;
@@ -368,7 +367,12 @@
   #1 (importT_terms ts (fold declare_term ts ctxt));
 
 fun polymorphic ctxt ts =
-  exportT_terms (fold declare_term ts ctxt) ctxt ts;
+  let
+    val ctxt' = fold declare_term ts ctxt;
+    val types = subtract (op =) (used_types ctxt) (used_types ctxt');
+    val idx = fold (Term.fold_types Term.maxidx_typ) ts ~1 + 1;
+  in map (Term.generalize (types, []) idx) ts end;
+
 
 
 (** term bindings **)