繁体   English   中英

通过三个基本案例的归纳证明(Isabelle)

[英]Proof by induction with three base cases (Isabelle)

我希望能够通过对n(类型为nat)的归纳来证明一条陈述。 它由一个条件仅在n> = 2时为真的条件组成。一个条件为false的条件始终为真。 因此,我想证明情况n = 0,n = 1和n = 2均与主要归纳步骤分开。 是否可以通过以下三种基本情况通过归纳来证明:

  lemma "P (n::nat) --> Q"
  proof (induct n)
    case 0
    show ?case sorry
  next
    case 1
    show ?case sorry
  next 
    case 2
    show ?case sorry
  next
    case (Suc n)
    show ?case sorry
  qed

就目前而言,这似乎行不通。 我可以通过归纳法来证明"P (n+2) --> Q" ,但这并不是一个强有力的陈述。 我正在考虑将案例分为"n=0""n=1""n>=2" ,并通过归纳证明最后一种情况。

最干净的方法可能是针对所需的归纳证明自定义归纳规则,如下所示:

lemma nat_0_1_2_induct [case_names 0 1 2 step]:
  assumes "P 0" "P 1" "P 2" "⋀n. n ≥ 2 ⟹ P n ⟹ P (Suc n)"
  shows   "P n"
proof (induction n rule: less_induct)
  case (less n)
  show ?case using assms(4)[OF _ less.IH[of "n - 1"]]
    by (cases "n ≤ 2") (insert assms(1-3), auto simp: eval_nat_numeral le_Suc_eq)
qed

lemma "P (n::nat) ⟶ Q"
proof (induction n rule: nat_0_1_2_induct)

从理论上讲, induction_schema方法对于证明此类自定义归纳规则也非常有用,但是在这种情况下,它并没有太大帮助:

lemma nat_0_1_2_induct [case_names 0 1 2 step]:
  "P 0 ⟹ P 1 ⟹ P 2 ⟹ (⋀n. n ≥ 2 ⟹ P n ⟹ P (Suc n)) ⟹ P n"
proof (induction_schema, goal_cases complete wf terminate)
  case (complete P n)
  thus ?case by (cases n) force+
next
  show "wf (Wellfounded.measure id)" by (rule wf_measure)
qed simp_all

您也可以直接使用less_induct ,然后在基本案例的归纳步骤中进行案例区分。

暂无
暂无

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

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