简体   繁体   English

Isabelle / HOL通过规则倒置证明

[英]Isabelle/HOL proof by rule inversion

I'm starting out with Isabelle/HOL and working through the prog-prove.pdf tutorial included in the distribution. 我将从Isabelle / HOL开始,并完成分发中包含的prog-prove.pdf教程。 I'm stumped in Section 4.4.5, "Rule Inversion". 我在第4.4.5节“规则倒置”中难以接受。 The tutorial gives (essentially) the following example: 本教程(基本上)给出了以下示例:

theory Structured
imports Main
begin

inductive ev :: "nat ⇒ bool" where
ev0:  "ev 0" |
evSS: "ev n ⟹ ev (Suc (Suc n))"

notepad
begin
  assume "ev n"
  from this have "ev (n - 2)"
  proof cases
    case ev0 thus "ev (n - 2)" by (simp add: ev.ev0)
  next
    case (evSS k) thus "ev (n - 2)" by (simp add: ev.evSS)
  qed
end

This works, although I had to put the notepad around the proof because Isabelle didn't like assume at the top level. 这是有效的,虽然我不得不把notepad放在证据的周围,因为Isabelle不喜欢在顶层assume But now I would like to use the same proof technique by stating the same fact as a lemma, and this doesn't work: 但是现在我想通过说明引理相同的事实来使用相同的证明技术,这不起作用:

lemma "ev n ⟹ ev (n - 2)"
proof cases
  case ev0 thus "ev (n - 2)" by (simp add: ev.ev0)
  (* ... *)

Isabelle stops at ev0 , complaining Undefined case: "ev0" , and then Illegal application of proof command in "state" mode at the by . 伊莎贝尔停止在ev0 ,抱怨Undefined case: "ev0" ,然后Illegal application of proof command in "state" modeby

What's the difference between the two ways of stating this goal? 说明这一目标的两种方式之间有什么区别? How can I use the above proof technique with the lemma statement? 如何将上述证明技术与引理语句一起使用? (I know that I can prove the lemma using sledgehammer , but I am trying to understand Isar proofs.) (我知道我可以用sledgehammer证明这个引理,但我试图理解Isar的证明。)

The cases method tries to pick the right case analysis rule based on ”given facts”. cases方法试图根据“给定事实”选择正确的案例分析规则。 Given facts are those that that you provide using then or from or using . 鉴于事实是您使用thenfromusing事实。

If you put your cursor on have "ev (n - 2)" you see this goal state 如果你把光标放在have "ev (n - 2)"你会看到这个目标状态

proof (prove): depth 1

using this:
  ev n

goal (1 subgoal):
 1. ev (n - 2)

while on lemma "ev n ⟹ ev (n - 2)" you get lemma "ev n ⟹ ev (n - 2)"你得到

proof (prove): depth 0

goal (1 subgoal):
 1. ev n ⟹ ev (n - 2)

The solution is to avoid meta-impliciation ( ==> ) when you can use proper Isar commands to specify the assumptions of the lemma separately, and feed them to the proof using using : 解决方案是当您可以使用适当的Isar命令分别指定引理的假设时,避免元隐含( ==> ),并使用以下using将它们提供给证明:

lemma 
  assumes "ev n"
  shows "ev (n - 2)"
using assms

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM