src/HOL/Tools/inductive_package.ML
changeset 24861 cc669ca5f382
parent 24830 a7b3ab44d993
child 24867 e5b55d7be9bb
equal deleted inserted replaced
24860:ceb634874e0c 24861:cc669ca5f382
   431 
   431 
   432     fun err msg =
   432     fun err msg =
   433       error (Pretty.string_of (Pretty.block
   433       error (Pretty.string_of (Pretty.block
   434         [Pretty.str msg, Pretty.fbrk, ProofContext.pretty_term ctxt prop]));
   434         [Pretty.str msg, Pretty.fbrk, ProofContext.pretty_term ctxt prop]));
   435 
   435 
   436     val elims = Induct.find_casesS ctxt prop;
   436     val elims = Induct.find_casesP ctxt prop;
   437 
   437 
   438     val cprop = Thm.cterm_of thy prop;
   438     val cprop = Thm.cterm_of thy prop;
   439     val tac = ALLGOALS (simp_case_tac ss) THEN prune_params_tac;
   439     val tac = ALLGOALS (simp_case_tac ss) THEN prune_params_tac;
   440     fun mk_elim rl =
   440     fun mk_elim rl =
   441       Thm.implies_intr cprop (Tactic.rule_by_tactic tac (Thm.assume cprop RS rl))
   441       Thm.implies_intr cprop (Tactic.rule_by_tactic tac (Thm.assume cprop RS rl))
   677     val ind_case_names = RuleCases.case_names intr_names;
   677     val ind_case_names = RuleCases.case_names intr_names;
   678     val induct =
   678     val induct =
   679       if coind then
   679       if coind then
   680         (raw_induct, [RuleCases.case_names [rec_name],
   680         (raw_induct, [RuleCases.case_names [rec_name],
   681           RuleCases.case_conclusion (rec_name, intr_names),
   681           RuleCases.case_conclusion (rec_name, intr_names),
   682           RuleCases.consumes 1, Induct.coinduct_set (hd cnames)])
   682           RuleCases.consumes 1, Induct.coinduct_pred (hd cnames)])
   683       else if no_ind orelse length cnames > 1 then
   683       else if no_ind orelse length cnames > 1 then
   684         (raw_induct, [ind_case_names, RuleCases.consumes 0])
   684         (raw_induct, [ind_case_names, RuleCases.consumes 0])
   685       else (raw_induct RSN (2, rev_mp), [ind_case_names, RuleCases.consumes 1]);
   685       else (raw_induct RSN (2, rev_mp), [ind_case_names, RuleCases.consumes 1]);
   686 
   686 
   687     val (intrs', ctxt1) =
   687     val (intrs', ctxt1) =
   696       LocalTheory.note kind ((NameSpace.qualified rec_name "intros", []), intrs') ||>>
   696       LocalTheory.note kind ((NameSpace.qualified rec_name "intros", []), intrs') ||>>
   697       fold_map (fn (name, (elim, cases)) =>
   697       fold_map (fn (name, (elim, cases)) =>
   698         LocalTheory.note kind ((NameSpace.qualified (Sign.base_name name) "cases",
   698         LocalTheory.note kind ((NameSpace.qualified (Sign.base_name name) "cases",
   699           [Attrib.internal (K (RuleCases.case_names cases)),
   699           [Attrib.internal (K (RuleCases.case_names cases)),
   700            Attrib.internal (K (RuleCases.consumes 1)),
   700            Attrib.internal (K (RuleCases.consumes 1)),
   701            Attrib.internal (K (Induct.cases_set name)),
   701            Attrib.internal (K (Induct.cases_pred name)),
   702            Attrib.internal (K (ContextRules.elim_query NONE))]), [elim]) #>
   702            Attrib.internal (K (ContextRules.elim_query NONE))]), [elim]) #>
   703         apfst (hd o snd)) (if null elims then [] else cnames ~~ elims) ||>>
   703         apfst (hd o snd)) (if null elims then [] else cnames ~~ elims) ||>>
   704       LocalTheory.note kind ((NameSpace.qualified rec_name (coind_prefix coind ^ "induct"),
   704       LocalTheory.note kind ((NameSpace.qualified rec_name (coind_prefix coind ^ "induct"),
   705         map (Attrib.internal o K) (#2 induct)), [rulify (#1 induct)]);
   705         map (Attrib.internal o K) (#2 induct)), [rulify (#1 induct)]);
   706 
   706 
   710         ctxt2 |>
   710         ctxt2 |>
   711         LocalTheory.notes kind [((NameSpace.qualified rec_name "inducts", []),
   711         LocalTheory.notes kind [((NameSpace.qualified rec_name "inducts", []),
   712           inducts |> map (fn (name, th) => ([th],
   712           inducts |> map (fn (name, th) => ([th],
   713             [Attrib.internal (K ind_case_names),
   713             [Attrib.internal (K ind_case_names),
   714              Attrib.internal (K (RuleCases.consumes 1)),
   714              Attrib.internal (K (RuleCases.consumes 1)),
   715              Attrib.internal (K (Induct.induct_set name))])))] |> snd
   715              Attrib.internal (K (Induct.induct_pred name))])))] |> snd
   716       end
   716       end
   717   in (intrs', elims', induct', ctxt3) end;
   717   in (intrs', elims', induct', ctxt3) end;
   718 
   718 
   719 type add_ind_def =
   719 type add_ind_def =
   720   {verbose: bool, kind: string, alt_name: bstring, coind: bool, no_elim: bool, no_ind: bool} ->
   720   {verbose: bool, kind: string, alt_name: bstring, coind: bool, no_elim: bool, no_ind: bool} ->