365 (*>*) |
365 (*>*) |
366 |
366 |
367 subsection{*Tracing*} |
367 subsection{*Tracing*} |
368 text{*\indexbold{tracing the simplifier} |
368 text{*\indexbold{tracing the simplifier} |
369 Using the simplifier effectively may take a bit of experimentation. Set the |
369 Using the simplifier effectively may take a bit of experimentation. Set the |
370 \isa{trace_simp}\index{*trace_simp (flag)} flag\index{flags} |
370 Proof General flag \textsf{Isabelle} $>$ \textsf{Settings} $>$ \textsf{Trace Simplifier} to get a better idea of what is going on: |
371 to get a better idea of what is going |
371 *} |
372 on: |
372 |
373 *} |
|
374 |
|
375 ML "set trace_simp" |
|
376 lemma "rev [a] = []" |
373 lemma "rev [a] = []" |
377 apply(simp) |
374 apply(simp) |
378 (*<*)oops(*>*) |
375 (*<*)oops(*>*) |
379 |
376 |
380 text{*\noindent |
377 text{*\noindent |
381 produces the trace |
378 produces the following trace in Proof General's \textsf{Trace} buffer: |
382 |
379 |
383 \begin{ttbox}\makeatother |
380 \begin{ttbox}\makeatother |
384 Applying instance of rewrite rule: |
381 [0]Applying instance of rewrite rule "List.rev.simps_2": |
385 rev (?x1 \# ?xs1) == rev ?xs1 @ [?x1] |
382 rev (?x1 # ?xs1) \(\equiv\) rev ?xs1 @ [?x1] |
386 Rewriting: |
383 |
387 rev [a] == rev [] @ [a] |
384 [0]Rewriting: |
388 Applying instance of rewrite rule: |
385 rev [a] \(\equiv\) rev [] @ [a] |
389 rev [] == [] |
386 |
390 Rewriting: |
387 [0]Applying instance of rewrite rule "List.rev.simps_1": |
391 rev [] == [] |
388 rev [] \(\equiv\) [] |
392 Applying instance of rewrite rule: |
389 |
393 [] @ ?y == ?y |
390 [0]Rewriting: |
394 Rewriting: |
391 rev [] \(\equiv\) [] |
395 [] @ [a] == [a] |
392 |
396 Applying instance of rewrite rule: |
393 [0]Applying instance of rewrite rule "List.op @.append_Nil": |
397 ?x3 \# ?t3 = ?t3 == False |
394 [] @ ?y \(\equiv\) ?y |
398 Rewriting: |
395 |
399 [a] = [] == False |
396 [0]Rewriting: |
|
397 [] @ [a] \(\equiv\) [a] |
|
398 |
|
399 [0]Applying instance of rewrite rule |
|
400 ?x2 # ?t1 = ?t1 \(\equiv\) False |
|
401 |
|
402 [0]Rewriting: |
|
403 [a] = [] \(\equiv\) False |
400 \end{ttbox} |
404 \end{ttbox} |
401 |
405 The trace lists each rule being applied, both in its general form and |
402 The trace lists each rule being applied, both in its general form and the |
406 the instance being used. The \texttt{[}$i$\texttt{]} in front (where |
403 instance being used. For conditional rules, the trace lists the rule |
407 above $i$ is always \texttt{0}) indicates that we are inside the $i$th |
404 it is trying to rewrite and gives the result of attempting to prove |
408 recursive invocation of the simplifier. Each attempt to apply a |
405 each of the rule's conditions. Many other hints about the simplifier's |
409 conditional rule shows the rule followed by the trace of the |
406 actions will appear. |
410 (recursive!) simplification of the conditions, the latter prefixed by |
407 |
411 \texttt{[}$i+1$\texttt{]} instead of \texttt{[}$i$\texttt{]}. |
408 In more complicated cases, the trace can be quite lengthy. Invocations of the |
412 Another source of recursive invocations of the simplifier are |
409 simplifier are often nested, for instance when solving conditions of rewrite |
413 proofs of arithmetic formulae. |
410 rules. Thus it is advisable to reset it: |
414 |
411 *} |
415 Many other hints about the simplifier's actions may appear. |
412 |
416 |
413 ML "reset trace_simp" |
417 In more complicated cases, the trace can be very lengthy. Thus it is |
|
418 advisable to reset the \textsf{Trace Simplifier} flag after having |
|
419 obtained the desired trace. *} |
414 |
420 |
415 (*<*) |
421 (*<*) |
416 end |
422 end |
417 (*>*) |
423 (*>*) |