src/HOL/Tools/refute.ML
changeset 36692 54b64d4ad524
parent 36555 8ff45c2076da
child 37117 59cee8807c29
equal deleted inserted replaced
36674:d95f39448121 36692:54b64d4ad524
   461   let
   461   let
   462     val class_const_names = map Logic.const_of_class (Sign.all_classes thy)
   462     val class_const_names = map Logic.const_of_class (Sign.all_classes thy)
   463   in
   463   in
   464     (* I'm not quite sure if checking the name 's' is sufficient, *)
   464     (* I'm not quite sure if checking the name 's' is sufficient, *)
   465     (* or if we should also check the type 'T'.                   *)
   465     (* or if we should also check the type 'T'.                   *)
   466     s mem_string class_const_names
   466     member (op =) class_const_names s
   467   end;
   467   end;
   468 
   468 
   469 (* ------------------------------------------------------------------------- *)
   469 (* ------------------------------------------------------------------------- *)
   470 (* is_IDT_constructor: returns 'true' iff 'Const (s, T)' is the constructor  *)
   470 (* is_IDT_constructor: returns 'true' iff 'Const (s, T)' is the constructor  *)
   471 (*                     of an inductive datatype in 'thy'                     *)
   471 (*                     of an inductive datatype in 'thy'                     *)
   497     val rec_names = Symtab.fold (append o #rec_names o snd)
   497     val rec_names = Symtab.fold (append o #rec_names o snd)
   498       (Datatype.get_all thy) []
   498       (Datatype.get_all thy) []
   499   in
   499   in
   500     (* I'm not quite sure if checking the name 's' is sufficient, *)
   500     (* I'm not quite sure if checking the name 's' is sufficient, *)
   501     (* or if we should also check the type 'T'.                   *)
   501     (* or if we should also check the type 'T'.                   *)
   502     s mem_string rec_names
   502     member (op =) rec_names s
   503   end;
   503   end;
   504 
   504 
   505 (* ------------------------------------------------------------------------- *)
   505 (* ------------------------------------------------------------------------- *)
   506 (* norm_rhs: maps  f ?t1 ... ?tn == rhs  to  %t1...tn. rhs                   *)
   506 (* norm_rhs: maps  f ?t1 ... ?tn == rhs  to  %t1...tn. rhs                   *)
   507 (* ------------------------------------------------------------------------- *)
   507 (* ------------------------------------------------------------------------- *)
   930                 Datatype_Aux.DtTFree _ =>
   930                 Datatype_Aux.DtTFree _ =>
   931                 collect_types dT acc
   931                 collect_types dT acc
   932               | Datatype_Aux.DtType (_, ds) =>
   932               | Datatype_Aux.DtType (_, ds) =>
   933                 collect_types dT (fold_rev collect_dtyp ds acc)
   933                 collect_types dT (fold_rev collect_dtyp ds acc)
   934               | Datatype_Aux.DtRec i =>
   934               | Datatype_Aux.DtRec i =>
   935                 if dT mem acc then
   935                 if member (op =) acc dT then
   936                   acc  (* prevent infinite recursion *)
   936                   acc  (* prevent infinite recursion *)
   937                 else
   937                 else
   938                   let
   938                   let
   939                     val (_, dtyps, dconstrs) = the (AList.lookup (op =) descr i)
   939                     val (_, dtyps, dconstrs) = the (AList.lookup (op =) descr i)
   940                     (* if the current type is a recursive IDT (i.e. a depth *)
   940                     (* if the current type is a recursive IDT (i.e. a depth *)
  2246                       val (intrs, new_offset) =
  2246                       val (intrs, new_offset) =
  2247                         fold_map (fn t_elem => fn off =>
  2247                         fold_map (fn t_elem => fn off =>
  2248                           (* if 't_elem' existed at the previous depth,    *)
  2248                           (* if 't_elem' existed at the previous depth,    *)
  2249                           (* proceed recursively, otherwise map the entire *)
  2249                           (* proceed recursively, otherwise map the entire *)
  2250                           (* subtree to "undefined"                        *)
  2250                           (* subtree to "undefined"                        *)
  2251                           if t_elem mem terms' then
  2251                           if member (op =) terms' t_elem then
  2252                             make_constr ds off
  2252                             make_constr ds off
  2253                           else
  2253                           else
  2254                             (make_undef ds, off))
  2254                             (make_undef ds, off))
  2255                         terms offset
  2255                         terms offset
  2256                     in
  2256                     in