src/Pure/theory.ML
changeset 61248 066792098895
parent 61247 76148d288b2e
child 61249 8611f408ec13
equal deleted inserted replaced
61247:76148d288b2e 61248:066792098895
   281 
   281 
   282 (* definitional axioms *)
   282 (* definitional axioms *)
   283 
   283 
   284 local
   284 local
   285 
   285 
   286 fun fold_type_constr f (Type (name, Ts)) = f (name,Ts) #> fold (fold_type_constr f) Ts
       
   287   | fold_type_constr _ _ = I;
       
   288 
       
   289 fun check_def ctxt thy unchecked overloaded (b, tm) defs =
   286 fun check_def ctxt thy unchecked overloaded (b, tm) defs =
   290   let
   287   let
   291     val name = Sign.full_name thy b;
   288     val name = Sign.full_name thy b;
   292     val ((lhs, rhs), _) = Primitive_Defs.dest_def ctxt Term.is_Const (K false) (K false) tm
   289     val ((lhs, rhs), _) = Primitive_Defs.dest_def ctxt Term.is_Const (K false) (K false) tm
   293       handle TERM (msg, _) => error msg;
   290       handle TERM (msg, _) => error msg;
   294     val lhs_const = Term.dest_Const (Term.head_of lhs);
   291     val lhs_const = Term.dest_Const (Term.head_of lhs);
   295     val rhs_consts = fold_aterms (fn Const const => insert (op =) (DConst const) | _ => I) rhs [];
   292 
   296     val rhs_types = fold_types (fold_type_constr (insert (op =) o DType)) rhs []
   293     val rhs_consts = fold_aterms (fn Const c => insert (op =) (DConst c) | _ => I) rhs [];
   297     val rhs_deps = rhs_consts @ rhs_types
   294     val rhs_types =
       
   295       (fold_types o fold_subtypes) (fn Type t => insert (op =) (DType t) | _ => I) rhs [];
       
   296     val rhs_deps = rhs_consts @ rhs_types;
       
   297 
   298     val _ = check_overloading ctxt overloaded lhs_const;
   298     val _ = check_overloading ctxt overloaded lhs_const;
   299   in defs |> dependencies ctxt unchecked (SOME name) name (DConst lhs_const) rhs_deps end
   299   in defs |> dependencies ctxt unchecked (SOME name) name (DConst lhs_const) rhs_deps end
   300   handle ERROR msg => cat_error msg (Pretty.string_of (Pretty.block
   300   handle ERROR msg => cat_error msg (Pretty.string_of (Pretty.block
   301    [Pretty.str ("The error(s) above occurred in definition " ^ Binding.print b ^ ":"),
   301    [Pretty.str ("The error(s) above occurred in definition " ^ Binding.print b ^ ":"),
   302     Pretty.fbrk, Pretty.quote (Syntax.pretty_term ctxt tm)]));
   302     Pretty.fbrk, Pretty.quote (Syntax.pretty_term ctxt tm)]));