src/HOL/Tools/inductive_set_package.ML
changeset 29389 0a49f940d729
parent 29288 253bcf2a5854
child 29581 b3b33e0298eb
equal deleted inserted replaced
29388:79eb3649ca9e 29389:0a49f940d729
    18     local_theory -> InductivePackage.inductive_result * local_theory
    18     local_theory -> InductivePackage.inductive_result * local_theory
    19   val add_inductive: bool -> bool ->
    19   val add_inductive: bool -> bool ->
    20     (Binding.T * string option * mixfix) list ->
    20     (Binding.T * string option * mixfix) list ->
    21     (Binding.T * string option * mixfix) list ->
    21     (Binding.T * string option * mixfix) list ->
    22     (Attrib.binding * string) list -> (Facts.ref * Attrib.src list) list ->
    22     (Attrib.binding * string) list -> (Facts.ref * Attrib.src list) list ->
    23     local_theory -> InductivePackage.inductive_result * local_theory
    23     bool -> local_theory -> InductivePackage.inductive_result * local_theory
    24   val codegen_preproc: theory -> thm list -> thm list
    24   val codegen_preproc: theory -> thm list -> thm list
    25   val setup: theory -> theory
    25   val setup: theory -> theory
    26 end;
    26 end;
    27 
    27 
    28 structure InductiveSetPackage: INDUCTIVE_SET_PACKAGE =
    28 structure InductiveSetPackage: INDUCTIVE_SET_PACKAGE =
   401 fun code_ind_att optmod = to_pred_att [] #> InductiveCodegen.add optmod NONE;
   401 fun code_ind_att optmod = to_pred_att [] #> InductiveCodegen.add optmod NONE;
   402 
   402 
   403 
   403 
   404 (**** definition of inductive sets ****)
   404 (**** definition of inductive sets ****)
   405 
   405 
   406 fun add_ind_set_def {quiet_mode, verbose, kind, alt_name, coind, no_elim, no_ind, skip_mono}
   406 fun add_ind_set_def
       
   407     {quiet_mode, verbose, kind, alt_name, coind, no_elim, no_ind, skip_mono, fork_mono}
   407     cs intros monos params cnames_syn ctxt =
   408     cs intros monos params cnames_syn ctxt =
   408   let
   409   let
   409     val thy = ProofContext.theory_of ctxt;
   410     val thy = ProofContext.theory_of ctxt;
   410     val {set_arities, pred_arities, to_pred_simps, ...} =
   411     val {set_arities, pred_arities, to_pred_simps, ...} =
   411       PredSetConvData.get (Context.Proof ctxt);
   412       PredSetConvData.get (Context.Proof ctxt);
   466     val cnames_syn' = map (fn (b, _) => (Binding.map_base (suffix "p") b, NoSyn)) cnames_syn;
   467     val cnames_syn' = map (fn (b, _) => (Binding.map_base (suffix "p") b, NoSyn)) cnames_syn;
   467     val monos' = map (to_pred [] (Context.Proof ctxt)) monos;
   468     val monos' = map (to_pred [] (Context.Proof ctxt)) monos;
   468     val ({preds, intrs, elims, raw_induct, ...}, ctxt1) =
   469     val ({preds, intrs, elims, raw_induct, ...}, ctxt1) =
   469       InductivePackage.add_ind_def
   470       InductivePackage.add_ind_def
   470         {quiet_mode = quiet_mode, verbose = verbose, kind = kind, alt_name = Binding.empty,
   471         {quiet_mode = quiet_mode, verbose = verbose, kind = kind, alt_name = Binding.empty,
   471           coind = coind, no_elim = no_elim, no_ind = no_ind, skip_mono = skip_mono}
   472           coind = coind, no_elim = no_elim, no_ind = no_ind,
       
   473           skip_mono = skip_mono, fork_mono = fork_mono}
   472         cs' intros' monos' params1 cnames_syn' ctxt;
   474         cs' intros' monos' params1 cnames_syn' ctxt;
   473 
   475 
   474     (* define inductive sets using previously defined predicates *)
   476     (* define inductive sets using previously defined predicates *)
   475     val (defs, ctxt2) = fold_map (LocalTheory.define Thm.internalK)
   477     val (defs, ctxt2) = fold_map (LocalTheory.define Thm.internalK)
   476       (map (fn ((c_syn, (fs, U, _)), p) => (c_syn, (Attrib.empty_binding,
   478       (map (fn ((c_syn, (fs, U, _)), p) => (c_syn, (Attrib.empty_binding,
   548 local structure P = OuterParse and K = OuterKeyword in
   550 local structure P = OuterParse and K = OuterKeyword in
   549 
   551 
   550 val ind_set_decl = InductivePackage.gen_ind_decl add_ind_set_def;
   552 val ind_set_decl = InductivePackage.gen_ind_decl add_ind_set_def;
   551 
   553 
   552 val _ =
   554 val _ =
   553   OuterSyntax.local_theory "inductive_set" "define inductive sets" K.thy_decl (ind_set_decl false);
   555   OuterSyntax.local_theory' "inductive_set" "define inductive sets" K.thy_decl (ind_set_decl false);
   554 
   556 
   555 val _ =
   557 val _ =
   556   OuterSyntax.local_theory "coinductive_set" "define coinductive sets" K.thy_decl (ind_set_decl true);
   558   OuterSyntax.local_theory' "coinductive_set" "define coinductive sets" K.thy_decl (ind_set_decl true);
   557 
   559 
   558 end;
   560 end;
   559 
   561 
   560 end;
   562 end;