simplifier: no trace info from simprocs unless simp_debug = true.
authornipkow
Tue, 27 Feb 2024 10:49:48 +0100
changeset 79731 6dbe7910dcfc
parent 79730 4031aafc2dda
child 79732 a53287d9add3
child 79735 d11cee9c3a7c
child 79737 9c00a46d69d0
simplifier: no trace info from simprocs unless simp_debug = true.
src/Doc/Isar_Ref/Generic.thy
src/Pure/raw_simplifier.ML
--- a/src/Doc/Isar_Ref/Generic.thy	Mon Feb 26 13:10:37 2024 +0100
+++ b/src/Doc/Isar_Ref/Generic.thy	Tue Feb 27 10:49:48 2024 +0100
@@ -743,8 +743,8 @@
   Simplifier tracing and debugging.
 
   \<^descr> @{attribute simp_trace} makes the Simplifier output internal operations.
-  This includes rewrite steps, but also bookkeeping like modifications of the
-  simpset.
+  This includes rewrite steps (but not traces from simproc calls),
+  but also bookkeeping like modifications of the simpset.
 
   \<^descr> @{attribute simp_trace_depth_limit} limits the effect of @{attribute
   simp_trace} to the given depth of recursive Simplifier invocations (when
@@ -752,7 +752,7 @@
 
   \<^descr> @{attribute simp_debug} makes the Simplifier output some extra information
   about internal operations. This includes any attempted invocation of
-  simplification procedures.
+  simplification procedures and the corresponding traces.
 
   \<^descr> @{attribute simp_trace_new} controls Simplifier tracing within
   Isabelle/PIDE applications, notably Isabelle/jEdit \<^cite>\<open>"isabelle-jedit"\<close>.
--- a/src/Pure/raw_simplifier.ML	Mon Feb 26 13:10:37 2024 +0100
+++ b/src/Pure/raw_simplifier.ML	Tue Feb 27 10:49:48 2024 +0100
@@ -1057,19 +1057,21 @@
           if Pattern.matches (Proof_Context.theory_of ctxt) (lhs, Thm.term_of t) then
             (cond_tracing' ctxt simp_debug (fn () =>
               print_term ctxt ("Trying procedure " ^ quote name ^ " on:") eta_t);
-             (case Morphism.form_context' ctxt proc eta_t' of
-               NONE => (cond_tracing' ctxt simp_debug (fn () => "FAILED"); proc_rews ps)
-             | SOME raw_thm =>
-                 (cond_tracing ctxt (fn () =>
-                    print_thm ctxt ("Procedure " ^ quote name ^ " produced rewrite rule:")
-                      ("", raw_thm));
-                  (case rews (mk_procrule ctxt raw_thm) of
-                    NONE =>
-                     (cond_tracing ctxt (fn () =>
-                        print_term ctxt ("IGNORED result of simproc " ^ quote name ^
-                            " -- does not match") (Thm.term_of t));
-                      proc_rews ps)
-                  | some => some))))
+             (let val ctxt' = Config.put simp_trace (Config.get ctxt simp_debug) ctxt
+              in case Morphism.form_context' ctxt' proc eta_t' of
+                NONE => (cond_tracing' ctxt simp_debug (fn () => "FAILED"); proc_rews ps)
+              | SOME raw_thm =>
+                  (cond_tracing ctxt (fn () =>
+                     print_thm ctxt ("Procedure " ^ quote name ^ " produced rewrite rule:")
+                       ("", raw_thm));
+                   (case rews (mk_procrule ctxt raw_thm) of
+                     NONE =>
+                      (cond_tracing ctxt (fn () =>
+                         print_term ctxt ("IGNORED result of simproc " ^ quote name ^
+                             " -- does not match") (Thm.term_of t));
+                       proc_rews ps)
+                   | some => some))
+              end))
           else proc_rews ps;
   in
     (case eta_t of