Isabelle 伊莎贝尔的终止证明
我正在尝试为此函数提供自动终止证明:Isabelle 伊莎贝尔的终止证明,isabelle,termination,hol,Isabelle,Termination,Hol,我正在尝试为此函数提供自动终止证明: 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 有空 我在这方面完全是新手,所以我不知道终止证明是如何工作的,或者pat_完整性是如何工作
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
有空
我在这方面完全是新手,所以我不知道终止证明是如何工作的,或者pat_完整性是如何工作的
有谁能提供一个参考来了解更多关于这一点和/或帮助我这个特定的例子吗
提前感谢。文档可在第4节中找到 其思想是提供一个有充分基础的关系,这样递归调用的参数就会减少。在您的情况下,第二个参数的长度正在减少,因此:
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
该文件见第4节 其思想是提供一个有充分基础的关系,这样递归调用的参数就会减少。在您的情况下,第二个参数的长度正在减少,因此:
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
注意:如果递归是显式结构的,我相信证明将完全自动通过:
“auxp[]=[]”|“auxp(x#xs)=(如果px,那么x#auxpxs else[])”
还要注意,编写的惯用方法是空[]
就是xs≠ []
。用最惯用的方式写东西往往会让你的生活更轻松,例如,因为自动化工作得更好。注意:我相信如果你的递归是显式结构的,证明将完全自动进行:“aux p[]=[]”“|”aux p(x#xs)=(如果px那么x#aux p xs else[])”
还要注意,编写的惯用方法是空[]
就是xs≠ []
。用最惯用的方式写东西会使你的生活更轻松,例如,因为自动化工作得更好。