简体   繁体   English

伊莎贝尔的终止证明

[英]Termination proof in Isabelle

I'm trying to provide an automatic termination proof for this function:我正在尝试为此 function 提供自动终止证明:

function aux :: "('a ⇒ bool) ⇒ 'a list ⇒ 'a list" where
  "aux p xs = (if ¬isEmpty xs ∧ p (hd xs) then hd xs#aux p (drop 1 xs) else [])"
  by pat_completeness auto 

with isEmpty being isEmpty存在

fun isEmpty :: "'a list ⇒ bool" where
  "isEmpty [] = True"
| "isEmpty (_#_) = False"

I'm totally new at this, so I don't know how termination proofs work, or how pat_completeness works, for that matter.我对此完全陌生,所以我不知道终止证明是如何工作的,或者 pat_completeness 是如何工作的。

Could anyone provide a reference to learn more about this and/or help me with this particular example?任何人都可以提供参考以了解更多信息和/或帮助我解决这个特定的例子吗?

Thanks in advance.提前致谢。

The documentation is available at https://isabelle.in.tum.de/dist/Isabelle2021/doc/functions.pdf , Section 4.该文档位于https://isabelle.in.tum.de/dist/Isabelle2021/doc/functions.pdf ,第 4 节。

The idea is to provide a relation that is well-founded and such that the arguments of the recursive calls are decreasing.这个想法是提供一个有充分根据的关系,并且递归调用的 arguments 正在减少。 In your case, the length of the second argument is decreasing, so:在您的情况下,第二个参数的长度正在减少,因此:

function aux :: "('a ⇒ bool) ⇒ 'a list ⇒ 'a list" where
  "aux p xs = (if xs≠ [] ∧ p (hd xs) then hd xs#aux p (drop 1 xs) else [])"
   by pat_completeness auto
termination
  by (relation ‹measure (λ(_, xs). length xs)›)
    auto

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

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