Printing out / showing detailed steps of proof methods (like simp) in a proof in isabelle

让人想犯罪 __ 提交于 2021-02-05 06:09:43

问题


Suppose I have the following code in Isabelle:

lemma"[| xs@zs = ys@xs ;[]@xs = []@[] |] => ys=zs" (*never mind the lemma body*)
apply simp
done

In the above code, The simp method proves the lemma. I am interested to see and print out the detailed (rewriting /simplification) steps that the simplification method takes to prove this lemma ( and possibly be able to do the same for all the other proof methods). How this is possible?

I am using isabelle 2014 with JEdit editor.

Many Thanks


回答1:


The simplifier trace can be enabled by specifying attributes simp_trace or simp_trace_new:

lemma "⟦xs @ zs = ys @ xs; [] @ xs = [] @ [] ⟧ ⟹ ys = zs"
  using [[simp_trace]]
  apply simp
done

If the cursor is positioned after the simp step, the output pane shows the rewrite trace inline (with the list what rules are added, what are applied and what terms are rewritten).

simp_trace_new allows seeing a more compact variant of the trace (what is rewritten) in a separate window (the trace pane is activated by pressing a highlighted part of a message See simplifier trace in the output pane, the trace itself is shown by pressing a button Show trace). Adding an option mode=full generates a more detailed output similar to simp_trace, but in a more structured way:

lemma "⟦xs @ zs = ys @ xs; [] @ xs = [] @ [] ⟧ ⟹ ys = zs"
  using [[simp_trace_new mode=full]]
  apply simp
done

You can find more details in The Isabelle/Isar Reference Manual that is also included in Isabelle2014 installation.




回答2:


If you are happy downloading a file or two, the l4.verified project includes a tool called Apply Trace written by Daniel Matichuk. It gives you a new command apply_trace that can be used wherever you would ordinarily use apply, but will show you the theorems used in the step.

For example, writing:

lemma "⟦xs @ zs = ys @ xs; [] @ xs = [] @ [] ⟧ ⟹ ys = zs"
  apply_trace simp

produces:

used theorems:
  simp_thms(6): (?x = ?x) = True
  append_Nil: [] @ ?ys = ?ys
  append_Nil2: ?xs @ [] = ?xs

Unlike simp_trace, it will not tell you what order the theorems were applied in. It is, however, capable of working with every method (simp, clarsimp, fastforce, auto, etc), while simp_trace only works with methods based on the simplifier.

To use it, you will need to grab both the files Apply_Trace_Cmd.thy and Apply_Trace.thy and import Apply_Trace_Cmd.



来源:https://stackoverflow.com/questions/26825747/printing-out-showing-detailed-steps-of-proof-methods-like-simp-in-a-proof-in

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!