src/HOL/Tools/inductive_package.ML
changeset 8277 493707fcd8a6
parent 8100 6186ee807f2e
child 8293 4a0e17cf8f70
equal deleted inserted replaced
8276:2647b7fa6508 8277:493707fcd8a6
    34   val unify_consts: Sign.sg -> term list -> term list -> term list * term list
    34   val unify_consts: Sign.sg -> term list -> term list -> term list * term list
    35   val get_inductive: theory -> string ->
    35   val get_inductive: theory -> string ->
    36     {names: string list, coind: bool} * {defs: thm list, elims: thm list, raw_induct: thm,
    36     {names: string list, coind: bool} * {defs: thm list, elims: thm list, raw_induct: thm,
    37       induct: thm, intrs: thm list, mk_cases: string -> thm, mono: thm, unfold: thm}
    37       induct: thm, intrs: thm list, mk_cases: string -> thm, mono: thm, unfold: thm}
    38   val print_inductives: theory -> unit
    38   val print_inductives: theory -> unit
       
    39   val cases_of: Sign.sg -> string -> thm
       
    40   val cases: Sign.sg -> thm list
    39   val mono_add_global: theory attribute
    41   val mono_add_global: theory attribute
    40   val mono_del_global: theory attribute
    42   val mono_del_global: theory attribute
    41   val get_monos: theory -> thm list
    43   val get_monos: theory -> thm list
    42   val add_inductive_i: bool -> bool -> bstring -> bool -> bool -> bool -> term list ->
    44   val add_inductive_i: bool -> bool -> bstring -> bool -> bool -> bool -> term list ->
    43     theory attribute list -> ((bstring * term) * theory attribute list) list ->
    45     theory attribute list -> ((bstring * term) * theory attribute list) list ->
   100     fun upd ((tab, monos), name) = (Symtab.update_new ((name, info), tab), monos);
   102     fun upd ((tab, monos), name) = (Symtab.update_new ((name, info), tab), monos);
   101     val tab_monos = foldl upd (InductiveData.get thy, names)
   103     val tab_monos = foldl upd (InductiveData.get thy, names)
   102       handle Symtab.DUP name => error ("Duplicate definition of (co)inductive set " ^ quote name);
   104       handle Symtab.DUP name => error ("Duplicate definition of (co)inductive set " ^ quote name);
   103   in InductiveData.put tab_monos thy end;
   105   in InductiveData.put tab_monos thy end;
   104 
   106 
       
   107 
       
   108 (* cases rules *)
       
   109 
       
   110 fun cases_of sg name =
       
   111   let
       
   112     fun find (None, (_, ({names, ...}, {elims, ...}): inductive_info)) =
       
   113           assoc (names ~~ elims, name)
       
   114       | find (some, _) = some;
       
   115     val (tab, _) = InductiveData.get_sg sg;
       
   116   in
       
   117     (case Symtab.foldl find (None, tab) of
       
   118       None => error ("Unknown (co)inductive set " ^ quote name)
       
   119     | Some thm => thm)
       
   120   end;
       
   121 
       
   122 fun cases sg = flat (map (#elims o #2 o #2) (Symtab.dest (#1 (InductiveData.get_sg sg))));
       
   123       
       
   124 
       
   125 
       
   126 (** monotonicity rules **)
       
   127 
   105 val get_monos = snd o InductiveData.get;
   128 val get_monos = snd o InductiveData.get;
   106 
       
   107 fun put_monos thms thy = InductiveData.put (fst (InductiveData.get thy), thms) thy;
   129 fun put_monos thms thy = InductiveData.put (fst (InductiveData.get thy), thms) thy;
   108 
       
   109 (** monotonicity rules **)
       
   110 
   130 
   111 fun mk_mono thm =
   131 fun mk_mono thm =
   112   let
   132   let
   113     fun eq2mono thm' = [standard (thm' RS (thm' RS eq_to_mono))] @
   133     fun eq2mono thm' = [standard (thm' RS (thm' RS eq_to_mono))] @
   114       (case concl_of thm of
   134       (case concl_of thm of