242 fun prep (item, args) = |
242 fun prep (item, args) = |
243 (case fold Term.add_tvarsT args [] of |
243 (case fold Term.add_tvarsT args [] of |
244 [] => (item, map Logic.varifyT_global args) |
244 [] => (item, map Logic.varifyT_global args) |
245 | vs => raise TYPE ("Illegal schematic type variable(s)", map TVar vs, [])); |
245 | vs => raise TYPE ("Illegal schematic type variable(s)", map TVar vs, [])); |
246 |
246 |
247 val lhs_vars = fold Term.add_tfreesT (snd lhs) []; |
247 val lhs_vars = fold Term_Subst.add_tfreesT (snd lhs) Term_Subst.TFrees.empty; |
248 val rhs_extras = |
248 val rhs_extras = |
249 fold (fn (_, args) => args |> (fold o Term.fold_atyps) (fn TFree v => |
249 fold (fn (_, args) => args |> (fold o Term.fold_atyps) (fn TFree v => |
250 if member (op =) lhs_vars v then I else insert (op =) v)) rhs []; |
250 if Term_Subst.TFrees.defined lhs_vars v then I else insert (op =) v)) rhs []; |
251 val _ = |
251 val _ = |
252 if null rhs_extras then () |
252 if null rhs_extras then () |
253 else error ("Specification depends on extra type variables: " ^ |
253 else error ("Specification depends on extra type variables: " ^ |
254 commas_quote (map (Syntax.string_of_typ ctxt o TFree) rhs_extras) ^ |
254 commas_quote (map (Syntax.string_of_typ ctxt o TFree) rhs_extras) ^ |
255 "\nThe error(s) above occurred in " ^ quote description); |
255 "\nThe error(s) above occurred in " ^ quote description); |