簡體   English   中英

伊莎貝爾的終止證明

[英]Termination proof in Isabelle

我正在嘗試為此 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 

isEmpty存在

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

我對此完全陌生,所以我不知道終止證明是如何工作的,或者 pat_completeness 是如何工作的。

任何人都可以提供參考以了解更多信息和/或幫助我解決這個特定的例子嗎?

提前致謝。

該文檔位於https://isabelle.in.tum.de/dist/Isabelle2021/doc/functions.pdf ,第 4 節。

這個想法是提供一個有充分根據的關系,並且遞歸調用的 arguments 正在減少。 在您的情況下,第二個參數的長度正在減少,因此:

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