我希望能够通过归纳来证明n(类型为nat)的声明。它由一个条件组成,其前提词仅对于n> = 2是正确的。其前提是假的条件总是为真。所以我想证明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"
,并通过归纳证明最后一种情况。
答案 0 :(得分:3)
最干净的方法可能是证明你想要的那种诱导的自定义诱导规则,如下所示:
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
,然后在基本案例的归纳步骤中进行案例区分。