src/HOL/Tools/inductive_package.ML
changeset 22102 a89ef7144729
parent 21879 a3efbae45735
child 22275 51411098e49b
equal deleted inserted replaced
22101:6d13239d5f52 22102:a89ef7144729
   843               else error ("Illegal nested case names " ^ quote (NameSpace.append a b))
   843               else error ("Illegal nested case names " ^ quote (NameSpace.append a b))
   844           | ((b, _), _) => error ("Illegal simultaneous specification " ^ quote b))
   844           | ((b, _), _) => error ("Illegal simultaneous specification " ^ quote b))
   845     | (a, _) => error ("Illegal local specification parameters for " ^ quote a));
   845     | (a, _) => error ("Illegal local specification parameters for " ^ quote a));
   846 
   846 
   847 fun ind_decl coind =
   847 fun ind_decl coind =
   848   P.opt_locale_target --
   848   P.opt_target --
   849   P.fixes -- P.for_fixes --
   849   P.fixes -- P.for_fixes --
   850   Scan.optional (P.$$$ "where" |-- P.!!! P.specification) [] --
   850   Scan.optional (P.$$$ "where" |-- P.!!! SpecParse.specification) [] --
   851   Scan.optional (P.$$$ "monos" |-- P.!!! P.xthms1) []
   851   Scan.optional (P.$$$ "monos" |-- P.!!! SpecParse.xthms1) []
   852   >> (fn ((((loc, preds), params), specs), monos) =>
   852   >> (fn ((((loc, preds), params), specs), monos) =>
   853     Toplevel.local_theory loc
   853     Toplevel.local_theory loc
   854       (fn lthy => lthy
   854       (fn lthy => lthy
   855         |> add_inductive true coind preds params (flatten_specification specs) monos |> snd));
   855         |> add_inductive true coind preds params (flatten_specification specs) monos |> snd));
   856 
   856 
   862 
   862 
   863 
   863 
   864 val inductive_casesP =
   864 val inductive_casesP =
   865   OuterSyntax.command "inductive_cases2"
   865   OuterSyntax.command "inductive_cases2"
   866     "create simplified instances of elimination rules (improper)" K.thy_script
   866     "create simplified instances of elimination rules (improper)" K.thy_script
   867     (P.opt_locale_target -- P.and_list1 P.spec
   867     (P.opt_target -- P.and_list1 SpecParse.spec
   868       >> (fn (loc, specs) => Toplevel.local_theory loc (snd o inductive_cases specs)));
   868       >> (fn (loc, specs) => Toplevel.local_theory loc (snd o inductive_cases specs)));
   869 
   869 
   870 val _ = OuterSyntax.add_keywords ["monos"];
   870 val _ = OuterSyntax.add_keywords ["monos"];
   871 val _ = OuterSyntax.add_parsers [inductiveP, coinductiveP, inductive_casesP];
   871 val _ = OuterSyntax.add_parsers [inductiveP, coinductiveP, inductive_casesP];
   872 
   872