src/HOL/Tools/inductive.ML
changeset 49324 4f28543ae7fa
parent 49170 03bee3a6a1b7
child 50214 67fb9a168d10
equal deleted inserted replaced
49323:6dff6b1f5417 49324:4f28543ae7fa
    47   val add_inductive: bool -> bool ->
    47   val add_inductive: bool -> bool ->
    48     (binding * string option * mixfix) list ->
    48     (binding * string option * mixfix) list ->
    49     (binding * string option * mixfix) list ->
    49     (binding * string option * mixfix) list ->
    50     (Attrib.binding * string) list ->
    50     (Attrib.binding * string) list ->
    51     (Facts.ref * Attrib.src list) list ->
    51     (Facts.ref * Attrib.src list) list ->
    52     bool -> local_theory -> inductive_result * local_theory
    52     local_theory -> inductive_result * local_theory
    53   val add_inductive_global: inductive_flags ->
    53   val add_inductive_global: inductive_flags ->
    54     ((binding * typ) * mixfix) list -> (string * typ) list -> (Attrib.binding * term) list ->
    54     ((binding * typ) * mixfix) list -> (string * typ) list -> (Attrib.binding * term) list ->
    55     thm list -> theory -> inductive_result * theory
    55     thm list -> theory -> inductive_result * theory
    56   val arities_of: thm -> (string * int) list
    56   val arities_of: thm -> (string * int) list
    57   val params_of: thm -> term list
    57   val params_of: thm -> term list
    79     thm list -> local_theory -> inductive_result * local_theory
    79     thm list -> local_theory -> inductive_result * local_theory
    80   val gen_add_inductive: add_ind_def -> bool -> bool ->
    80   val gen_add_inductive: add_ind_def -> bool -> bool ->
    81     (binding * string option * mixfix) list ->
    81     (binding * string option * mixfix) list ->
    82     (binding * string option * mixfix) list ->
    82     (binding * string option * mixfix) list ->
    83     (Attrib.binding * string) list -> (Facts.ref * Attrib.src list) list ->
    83     (Attrib.binding * string) list -> (Facts.ref * Attrib.src list) list ->
    84     bool -> local_theory -> inductive_result * local_theory
    84     local_theory -> inductive_result * local_theory
    85   val gen_ind_decl: add_ind_def -> bool -> (bool -> local_theory -> local_theory) parser
    85   val gen_ind_decl: add_ind_def -> bool -> (local_theory -> local_theory) parser
    86 end;
    86 end;
    87 
    87 
    88 structure Inductive: INDUCTIVE =
    88 structure Inductive: INDUCTIVE =
    89 struct
    89 struct
    90 
    90 
  1037     lthy
  1037     lthy
  1038     |> mk_def flags cs intros monos ps preds
  1038     |> mk_def flags cs intros monos ps preds
  1039     ||> fold (snd oo Local_Theory.abbrev Syntax.mode_default) abbrevs
  1039     ||> fold (snd oo Local_Theory.abbrev Syntax.mode_default) abbrevs
  1040   end;
  1040   end;
  1041 
  1041 
  1042 fun gen_add_inductive mk_def verbose coind cnames_syn pnames_syn intro_srcs raw_monos int lthy =
  1042 fun gen_add_inductive mk_def verbose coind cnames_syn pnames_syn intro_srcs raw_monos lthy =
  1043   let
  1043   let
  1044     val ((vars, intrs), _) = lthy
  1044     val ((vars, intrs), _) = lthy
  1045       |> Proof_Context.set_mode Proof_Context.mode_abbrev
  1045       |> Proof_Context.set_mode Proof_Context.mode_abbrev
  1046       |> Specification.read_spec (cnames_syn @ pnames_syn) intro_srcs;
  1046       |> Specification.read_spec (cnames_syn @ pnames_syn) intro_srcs;
  1047     val (cs, ps) = chop (length cnames_syn) vars;
  1047     val (cs, ps) = chop (length cnames_syn) vars;
  1141 fun gen_ind_decl mk_def coind =
  1141 fun gen_ind_decl mk_def coind =
  1142   Parse.fixes -- Parse.for_fixes --
  1142   Parse.fixes -- Parse.for_fixes --
  1143   Scan.optional Parse_Spec.where_alt_specs [] --
  1143   Scan.optional Parse_Spec.where_alt_specs [] --
  1144   Scan.optional (@{keyword "monos"} |-- Parse.!!! Parse_Spec.xthms1) []
  1144   Scan.optional (@{keyword "monos"} |-- Parse.!!! Parse_Spec.xthms1) []
  1145   >> (fn (((preds, params), specs), monos) =>
  1145   >> (fn (((preds, params), specs), monos) =>
  1146       (snd oo gen_add_inductive mk_def true coind preds params specs monos));
  1146       (snd o gen_add_inductive mk_def true coind preds params specs monos));
  1147 
  1147 
  1148 val ind_decl = gen_ind_decl add_ind_def;
  1148 val ind_decl = gen_ind_decl add_ind_def;
  1149 
  1149 
  1150 val _ =
  1150 val _ =
  1151   Outer_Syntax.local_theory' @{command_spec "inductive"} "define inductive predicates"
  1151   Outer_Syntax.local_theory @{command_spec "inductive"} "define inductive predicates"
  1152     (ind_decl false);
  1152     (ind_decl false);
  1153 
  1153 
  1154 val _ =
  1154 val _ =
  1155   Outer_Syntax.local_theory' @{command_spec "coinductive"} "define coinductive predicates"
  1155   Outer_Syntax.local_theory @{command_spec "coinductive"} "define coinductive predicates"
  1156     (ind_decl true);
  1156     (ind_decl true);
  1157 
  1157 
  1158 val _ =
  1158 val _ =
  1159   Outer_Syntax.local_theory @{command_spec "inductive_cases"}
  1159   Outer_Syntax.local_theory @{command_spec "inductive_cases"}
  1160     "create simplified instances of elimination rules (improper)"
  1160     "create simplified instances of elimination rules (improper)"