src/HOL/Tools/inductive_set_package.ML
changeset 26128 fe2d24c26e0c
parent 26047 d27b89c95b29
child 26336 a0e2b706ce73
equal deleted inserted replaced
26127:70ef56eb650a 26128:fe2d24c26e0c
    10 sig
    10 sig
    11   val to_set_att: thm list -> attribute
    11   val to_set_att: thm list -> attribute
    12   val to_pred_att: thm list -> attribute
    12   val to_pred_att: thm list -> attribute
    13   val pred_set_conv_att: attribute
    13   val pred_set_conv_att: attribute
    14   val add_inductive_i:
    14   val add_inductive_i:
    15     {verbose: bool, kind: string, group: string, alt_name: bstring,
    15     {verbose: bool, kind: string, alt_name: bstring, coind: bool, no_elim: bool, no_ind: bool} ->
    16       coind: bool, no_elim: bool, no_ind: bool} ->
       
    17     ((string * typ) * mixfix) list ->
    16     ((string * typ) * mixfix) list ->
    18     (string * typ) list -> ((bstring * Attrib.src list) * term) list -> thm list ->
    17     (string * typ) list -> ((bstring * Attrib.src list) * term) list -> thm list ->
    19       local_theory -> InductivePackage.inductive_result * local_theory
    18       local_theory -> InductivePackage.inductive_result * local_theory
    20   val add_inductive: bool -> bool -> (string * string option * mixfix) list ->
    19   val add_inductive: bool -> bool -> (string * string option * mixfix) list ->
    21     (string * string option * mixfix) list ->
    20     (string * string option * mixfix) list ->
   400 fun code_ind_att optmod = to_pred_att [] #> InductiveCodegen.add optmod NONE;
   399 fun code_ind_att optmod = to_pred_att [] #> InductiveCodegen.add optmod NONE;
   401 
   400 
   402 
   401 
   403 (**** definition of inductive sets ****)
   402 (**** definition of inductive sets ****)
   404 
   403 
   405 fun add_ind_set_def {verbose, kind, group, alt_name, coind, no_elim, no_ind}
   404 fun add_ind_set_def {verbose, kind, alt_name, coind, no_elim, no_ind}
   406     cs intros monos params cnames_syn ctxt =
   405     cs intros monos params cnames_syn ctxt =
   407   let
   406   let
   408     val thy = ProofContext.theory_of ctxt;
   407     val thy = ProofContext.theory_of ctxt;
   409     val {set_arities, pred_arities, to_pred_simps, ...} =
   408     val {set_arities, pred_arities, to_pred_simps, ...} =
   410       PredSetConvData.get (Context.Proof ctxt);
   409       PredSetConvData.get (Context.Proof ctxt);
   463         Pattern.rewrite_term thy [] [to_pred_proc thy eqns'] |>
   462         Pattern.rewrite_term thy [] [to_pred_proc thy eqns'] |>
   464         eta_contract (member op = cs' orf is_pred pred_arities))) intros;
   463         eta_contract (member op = cs' orf is_pred pred_arities))) intros;
   465     val cnames_syn' = map (fn (s, _) => (s ^ "p", NoSyn)) cnames_syn;
   464     val cnames_syn' = map (fn (s, _) => (s ^ "p", NoSyn)) cnames_syn;
   466     val monos' = map (to_pred [] (Context.Proof ctxt)) monos;
   465     val monos' = map (to_pred [] (Context.Proof ctxt)) monos;
   467     val ({preds, intrs, elims, raw_induct, ...}, ctxt1) =
   466     val ({preds, intrs, elims, raw_induct, ...}, ctxt1) =
   468       InductivePackage.add_ind_def {verbose = verbose, kind = kind, group = group,
   467       InductivePackage.add_ind_def {verbose = verbose, kind = kind, alt_name = "",
   469           alt_name = "",  (* FIXME pass alt_name (!?) *)
       
   470           coind = coind, no_elim = no_elim, no_ind = no_ind}
   468           coind = coind, no_elim = no_elim, no_ind = no_ind}
   471         cs' intros' monos' params1 cnames_syn' ctxt;
   469         cs' intros' monos' params1 cnames_syn' ctxt;
   472 
   470 
   473     (* define inductive sets using previously defined predicates *)
   471     (* define inductive sets using previously defined predicates *)
   474     val (defs, ctxt2) = fold_map (LocalTheory.define Thm.internalK)
   472     val (defs, ctxt2) = fold_map (LocalTheory.define Thm.internalK)
   500       space_implode "_" (map fst cnames_syn) else alt_name;
   498       space_implode "_" (map fst cnames_syn) else alt_name;
   501     val cnames = map (Sign.full_name (ProofContext.theory_of ctxt3) o #1) cnames_syn;  (* FIXME *)
   499     val cnames = map (Sign.full_name (ProofContext.theory_of ctxt3) o #1) cnames_syn;  (* FIXME *)
   502     val (intr_names, intr_atts) = split_list (map fst intros);
   500     val (intr_names, intr_atts) = split_list (map fst intros);
   503     val raw_induct' = to_set [] (Context.Proof ctxt3) raw_induct;
   501     val raw_induct' = to_set [] (Context.Proof ctxt3) raw_induct;
   504     val (intrs', elims', induct, ctxt4) =
   502     val (intrs', elims', induct, ctxt4) =
   505       InductivePackage.declare_rules kind group rec_name coind no_ind cnames
   503       InductivePackage.declare_rules kind rec_name coind no_ind cnames
   506       (map (to_set [] (Context.Proof ctxt3)) intrs) intr_names intr_atts
   504       (map (to_set [] (Context.Proof ctxt3)) intrs) intr_names intr_atts
   507       (map (fn th => (to_set [] (Context.Proof ctxt3) th,
   505       (map (fn th => (to_set [] (Context.Proof ctxt3) th,
   508          map fst (fst (RuleCases.get th)))) elims)
   506          map fst (fst (RuleCases.get th)))) elims)
   509       raw_induct' ctxt3
   507       raw_induct' ctxt3
   510   in
   508   in