New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Termination checker stumped by with-abstraction --without-K #2890
Comments
This is a known issue, however, I could not find the number. This specific example, however, passes with increased termination depth: {-# OPTIONS --without-K #-}
{-# OPTIONS --termination-depth=2 #-}
... The reason is that the with-function is implemented as:
and to track also argument increase (
I think you meant:
|
Here is another example that uses records rather than mutual recursion. As demonstrated by the two "ok" examples, using records or {-# OPTIONS --without-K #-}
module WithoutKTermination where
open import Data.List using (List; []; _∷_)
open import Relation.Binary.Core using (Decidable)
open import Relation.Binary.PropositionalEquality using (_≡_)
open import Relation.Nullary using (yes; no)
record ListSet (A : Set) : Set where
constructor listSet
field
set : List A
eq : Decidable {A = A} _≡_
open ListSet
insertOk : {A : Set} → A → ListSet A → ListSet A
insertOk a (listSet [] e) = listSet (a ∷ []) e
insertOk a (listSet (b ∷ l) e) = listSet (b ∷ set (insertOk a (listSet l e))) e
insertOk2 : {A : Set} → Decidable {A = A} _≡_ → A → List A → List A
insertOk2 e a [] = a ∷ []
insertOk2 e a (b ∷ l) with e a b
insertOk2 e a l@(b ∷ _) | yes p = l
insertOk2 e a (b ∷ l) | no ¬p = b ∷ (insertOk2 e a l)
insert : {A : Set} → A → ListSet A → ListSet A
insert a (listSet [] e) = listSet (a ∷ []) e
insert a (listSet (b ∷ l) e) with e a b
insert a (listSet l@(b ∷ _) e) | yes p = listSet l e
insert a (listSet (b ∷ l) e) | no ¬p = listSet (b ∷ set (insert a (listSet l e))) e |
Closing as duplicate of #59. |
When using
--without-K
, Agda fails to see that the two mutually-recursive functions defined below are structurally recursive. Both enabling--with-K
as well as replacing the with-abstraction by a helper function make the program pass the termination check.The text was updated successfully, but these errors were encountered: