src/Pure/Isar/method.ML
changeset 41379 b31d7a1cd08f
parent 39507 839873937ddd
child 42358 b47d41d9f4b5
equal deleted inserted replaced
41378:55286df6a423 41379:b31d7a1cd08f
     6 
     6 
     7 signature BASIC_METHOD =
     7 signature BASIC_METHOD =
     8 sig
     8 sig
     9   val FINDGOAL: (int -> thm -> 'a Seq.seq) -> thm -> 'a Seq.seq
     9   val FINDGOAL: (int -> thm -> 'a Seq.seq) -> thm -> 'a Seq.seq
    10   val HEADGOAL: (int -> thm -> 'a Seq.seq) -> thm -> 'a Seq.seq
    10   val HEADGOAL: (int -> thm -> 'a Seq.seq) -> thm -> 'a Seq.seq
    11   val trace_rules: bool Unsynchronized.ref
    11   val rule_trace: bool Config.T
    12 end;
    12 end;
    13 
    13 
    14 signature METHOD =
    14 signature METHOD =
    15 sig
    15 sig
    16   include BASIC_METHOD
    16   include BASIC_METHOD
   216 end;
   216 end;
   217 
   217 
   218 
   218 
   219 (* rule etc. -- single-step refinements *)
   219 (* rule etc. -- single-step refinements *)
   220 
   220 
   221 val trace_rules = Unsynchronized.ref false;
   221 val (rule_trace, rule_trace_setup) = Attrib.config_bool "rule_trace" (fn _ => false);
   222 
   222 
   223 fun trace ctxt rules =
   223 fun trace ctxt rules =
   224   if ! trace_rules andalso not (null rules) then
   224   if Config.get ctxt rule_trace andalso not (null rules) then
   225     Pretty.big_list "rules:" (map (Display.pretty_thm ctxt) rules)
   225     Pretty.big_list "rules:" (map (Display.pretty_thm ctxt) rules)
   226     |> Pretty.string_of |> tracing
   226     |> Pretty.string_of |> tracing
   227   else ();
   227   else ();
   228 
   228 
   229 local
   229 local
   436 
   436 
   437 
   437 
   438 (* theory setup *)
   438 (* theory setup *)
   439 
   439 
   440 val _ = Context.>> (Context.map_theory
   440 val _ = Context.>> (Context.map_theory
   441  (setup (Binding.name "fail") (Scan.succeed (K fail)) "force failure" #>
   441  (rule_trace_setup #>
       
   442   setup (Binding.name "fail") (Scan.succeed (K fail)) "force failure" #>
   442   setup (Binding.name "succeed") (Scan.succeed (K succeed)) "succeed" #>
   443   setup (Binding.name "succeed") (Scan.succeed (K succeed)) "succeed" #>
   443   setup (Binding.name "-") (Scan.succeed (K insert_facts))
   444   setup (Binding.name "-") (Scan.succeed (K insert_facts))
   444     "do nothing (insert current facts only)" #>
   445     "do nothing (insert current facts only)" #>
   445   setup (Binding.name "insert") (Attrib.thms >> (K o insert))
   446   setup (Binding.name "insert") (Attrib.thms >> (K o insert))
   446     "insert theorems, ignoring facts (improper)" #>
   447     "insert theorems, ignoring facts (improper)" #>