src/HOL/Tools/inductive_package.ML
changeset 30515 bca05b17b618
parent 30486 9cdc7ce0e389
child 30528 7173bf123335
equal deleted inserted replaced
30514:9455ecc7796d 30515:bca05b17b618
   458 
   458 
   459 val inductive_cases = gen_inductive_cases Attrib.intern_src Syntax.read_prop;
   459 val inductive_cases = gen_inductive_cases Attrib.intern_src Syntax.read_prop;
   460 val inductive_cases_i = gen_inductive_cases (K I) Syntax.check_prop;
   460 val inductive_cases_i = gen_inductive_cases (K I) Syntax.check_prop;
   461 
   461 
   462 
   462 
   463 fun ind_cases src = Method.syntax (Scan.lift (Scan.repeat1 Args.name_source --
   463 val ind_cases =
   464     Scan.optional (Args.$$$ "for" |-- Scan.repeat1 Args.name) [])) src
   464   Scan.lift (Scan.repeat1 Args.name_source --
   465   #> (fn ((raw_props, fixes), ctxt) =>
   465     Scan.optional (Args.$$$ "for" |-- Scan.repeat1 Args.name) []) >>
       
   466   (fn (raw_props, fixes) => fn ctxt =>
   466     let
   467     let
   467       val (_, ctxt') = Variable.add_fixes fixes ctxt;
   468       val (_, ctxt') = Variable.add_fixes fixes ctxt;
   468       val props = Syntax.read_props ctxt' raw_props;
   469       val props = Syntax.read_props ctxt' raw_props;
   469       val ctxt'' = fold Variable.declare_term props ctxt';
   470       val ctxt'' = fold Variable.declare_term props ctxt';
   470       val rules = ProofContext.export ctxt'' ctxt (map (mk_cases ctxt'') props)
   471       val rules = ProofContext.export ctxt'' ctxt (map (mk_cases ctxt'') props)
   931 (** package setup **)
   932 (** package setup **)
   932 
   933 
   933 (* setup theory *)
   934 (* setup theory *)
   934 
   935 
   935 val setup =
   936 val setup =
   936   Method.add_methods [("ind_cases", ind_cases,
   937   Method.setup @{binding ind_cases} ind_cases "dynamic case analysis on predicates" #>
   937     "dynamic case analysis on predicates")] #>
       
   938   Attrib.add_attributes [("mono", Attrib.add_del_args mono_add mono_del,
   938   Attrib.add_attributes [("mono", Attrib.add_del_args mono_add mono_del,
   939     "declaration of monotonicity rule")];
   939     "declaration of monotonicity rule")];
   940 
   940 
   941 
   941 
   942 (* outer syntax *)
   942 (* outer syntax *)