src/Provers/induct_method.ML
changeset 15703 727ef1b8b3ee
parent 15574 b1d1b5bfc464
child 15708 ef7b74e52f11
equal deleted inserted replaced
15702:2677db44c795 15703:727ef1b8b3ee
   324 val ruleN = "rule";
   324 val ruleN = "rule";
   325 val ofN = "of";
   325 val ofN = "of";
   326 
   326 
   327 local
   327 local
   328 
   328 
   329 fun check k get name =
   329 fun named_rule k arg get =
   330   (case get name of SOME x => x
   330   Scan.lift (Args.$$$ k -- Args.colon) |-- arg :-- (fn name => Scan.peek (fn ctxt =>
   331   | NONE => error ("No rule for " ^ k ^ " " ^ quote name));
   331     (case get ctxt name of SOME x => Scan.succeed x
   332 
   332     | NONE => error ("No rule for " ^ k ^ " " ^ quote name)))) >> #2;
   333 fun spec k = (Args.$$$ k -- Args.colon) |-- Args.!!! Args.name;
       
   334 
   333 
   335 fun rule get_type get_set =
   334 fun rule get_type get_set =
   336   Scan.depend (fn ctxt =>
   335   named_rule InductAttrib.typeN Args.local_tyname get_type ||
   337     let val sg = ProofContext.sign_of ctxt in
   336   named_rule InductAttrib.setN Args.local_const get_set ||
   338       spec InductAttrib.typeN >> (check InductAttrib.typeN (get_type ctxt) o
       
   339         Sign.certify_tyname sg o Sign.intern_tycon sg) ||
       
   340       spec InductAttrib.setN >> (check InductAttrib.setN (get_set ctxt) o
       
   341         Sign.certify_const sg o Sign.intern_const sg)
       
   342     end >> pair ctxt) ||
       
   343   Scan.lift (Args.$$$ ruleN -- Args.colon) |-- Attrib.local_thm;
   337   Scan.lift (Args.$$$ ruleN -- Args.colon) |-- Attrib.local_thm;
   344 
   338 
   345 val cases_rule = rule InductAttrib.lookup_casesT InductAttrib.lookup_casesS;
   339 val cases_rule = rule InductAttrib.lookup_casesT InductAttrib.lookup_casesS;
   346 val induct_rule = rule InductAttrib.lookup_inductT InductAttrib.lookup_inductS;
   340 val induct_rule = rule InductAttrib.lookup_inductT InductAttrib.lookup_inductS;
   347 
   341