src/Pure/Isar/method.ML
changeset 63256 74a4299632ae
parent 63252 1ee45339e86d
child 63257 94d1f820130f
equal deleted inserted replaced
63255:3f594efa9504 63256:74a4299632ae
    53   val erule: Proof.context -> int -> thm list -> method
    53   val erule: Proof.context -> int -> thm list -> method
    54   val drule: Proof.context -> int -> thm list -> method
    54   val drule: Proof.context -> int -> thm list -> method
    55   val frule: Proof.context -> int -> thm list -> method
    55   val frule: Proof.context -> int -> thm list -> method
    56   val set_tactic: (morphism -> thm list -> tactic) -> Context.generic -> Context.generic
    56   val set_tactic: (morphism -> thm list -> tactic) -> Context.generic -> Context.generic
    57   val clean_facts: thm list -> thm list
    57   val clean_facts: thm list -> thm list
       
    58   val set_facts: thm list -> Proof.context -> Proof.context
       
    59   val get_facts: Proof.context -> thm list
    58   type combinator_info
    60   type combinator_info
    59   val no_combinator_info: combinator_info
    61   val no_combinator_info: combinator_info
    60   datatype combinator = Then | Then_All_New | Orelse | Try | Repeat1 | Select_Goals of int
    62   datatype combinator = Then | Then_All_New | Orelse | Try | Repeat1 | Select_Goals of int
    61   datatype text =
    63   datatype text =
    62     Source of Token.src |
    64     Source of Token.src |
   375 
   377 
   376 (* method facts *)
   378 (* method facts *)
   377 
   379 
   378 val clean_facts = filter_out Thm.is_dummy;
   380 val clean_facts = filter_out Thm.is_dummy;
   379 
   381 
       
   382 fun set_facts facts =
       
   383   (Context.proof_map o map_data)
       
   384     (fn (methods, ml_tactic, _) => (methods, ml_tactic, SOME (clean_facts facts)));
       
   385 
   380 val get_facts_generic = these o #facts o Data.get;
   386 val get_facts_generic = these o #facts o Data.get;
   381 val get_facts = get_facts_generic o Context.Proof;
   387 val get_facts = get_facts_generic o Context.Proof;
   382 
       
   383 fun update_facts f =
       
   384   (Context.proof_map o map_data)
       
   385     (fn (methods, ml_tactic, facts) => (methods, ml_tactic, SOME (clean_facts (f (these facts)))));
       
   386 
   388 
   387 val _ =
   389 val _ =
   388   Theory.setup
   390   Theory.setup
   389     (Global_Theory.add_thms_dynamic (Binding.make ("method_facts", @{here}), get_facts_generic));
   391     (Global_Theory.add_thms_dynamic (Binding.make ("method_facts", @{here}), get_facts_generic));
   390 
   392 
   569       Seq.single #> Seq.maps_results (fn (ctxt, st) => m (get_facts ctxt) (ctxt, st));
   571       Seq.single #> Seq.maps_results (fn (ctxt, st) => m (get_facts ctxt) (ctxt, st));
   570     fun eval (Basic m) = eval0 (m static_ctxt)
   572     fun eval (Basic m) = eval0 (m static_ctxt)
   571       | eval (Source src) = eval0 (method_cmd static_ctxt src static_ctxt)
   573       | eval (Source src) = eval0 (method_cmd static_ctxt src static_ctxt)
   572       | eval (Combinator (_, c, txts)) = combinator c (map eval txts);
   574       | eval (Combinator (_, c, txts)) = combinator c (map eval txts);
   573     val method = eval text;
   575     val method = eval text;
   574   in fn facts => fn (ctxt, st) => method (Seq.Result (update_facts (K facts) ctxt, st)) end;
   576   in fn facts => fn (ctxt, st) => method (Seq.Result (set_facts facts ctxt, st)) end;
   575 
   577 
   576 end;
   578 end;
   577 
   579 
   578 
   580 
   579 
   581