简体   繁体   English

这个 Isabelle 证明中是否需要归纳?

[英]Is induction required in this Isabelle proof?

I'm trying to prove that generator functions produce certain, still very simple, patterns.我试图证明生成器函数会产生某些仍然非常简单的模式。 pattern_0_1 generates a list of alternating 0s and 1s. pattern_0_1生成交替 0 和 1 的列表。 I've succeeded to prove that the first item is zero for any list whose length is greater than 0. Applying the same technique, however, failed to prove the 2nd element is always 1. My guess is induction is not at all required here.我已经成功证明任何长度大于 0 的列表的第一项为零。但是,应用相同的技术未能证明第二个元素始终为 1。我的猜测是这里根本不需要归纳。 I'd appreciate any help on the right approach to complete the second lemma.对于完成第二个引理的正确方法,我将不胜感激。

fun pattern_0_1 :: "nat ⇒ nat ⇒ nat list" where
"pattern_0_1 0 item  = []" |
"pattern_0_1 len item =  item # (pattern_0_1 (len - 1) (if item = 0 then 1 else 0))"

lemma item_0_is_0 : "lng ≥ 1 ⟹ pattern_0_1 lng 0 ! 0 = 0"
  apply(induction lng)
  apply(simp)
  by auto

lemma item_1_is_1 : "lng ≥ 2 ⟹ pattern_0_1 lng 0 ! 1 = 1"
  apply(induction lng)
  apply(simp)
  sorry

Induction is not required (it would be, would you show something about all even or all odd positions).不需要归纳(它会是,你会展示一些关于所有偶数或所有奇数位置的东西)。 Here, case analysis is enough, so that you get the cases 0, 1, and >= 2. So, your proof can be done via在这里,案例分析就足够了,因此您可以得到案例 0、1 和 >= 2。因此,您的证明可以通过

apply(cases lng; cases "lng - 1"; auto)

where the first cases will be on being 0 or >= 1, and the second cases will distinguish between 1 and >= 2.其中第一种cases将是 0 或 >= 1,而第二种cases将区分 1 和 >= 2。

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

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