-
Notifications
You must be signed in to change notification settings - Fork 364
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
Cubical Agda: Program rejected by termination checker due to moved dot pattern #4725
Comments
The dot patterns are not actually moved, instead Agda tries to reconstruct the LHS from scratch using iterated case splitting. If after this case splitting there is still some discrepancy, these are registered in the origin of the internal patterns by the code in https://github.com/agda/agda/blob/master/src/full/Agda/TypeChecking/Rules/LHS.hs#L443-L462. One could conceivably emit a warning here if the
The dots are computed by the pattern unifier. It already has a system for priorities that it uses to decide which variable to instantiate: https://github.com/agda/agda/blob/master/src/full/Agda/TypeChecking/Rules/LHS/Problem.hs#L113-L123. So it already prefers to instantiate variables that correspond to a dot pattern written by the user. I'll investigate further why that mechanism doesn't kick in in your test case. |
Ah, I understand what's the problem now. When Agda does the case split on the constructor |
I encountered this problem (but without any explicit dot patterns) in my code, and once I had understood its cause it was easy to fix it. However, the output of |
I think I am running into the same kind of problem, but with perhaps a simpler example, and I don't see any eta getting in the way here. Reporting partly in the hope that this will shed new light, and partly hoping to be told about a workaround. {-# OPTIONS --cubical #-}
mutual
data Ord : Set
data _≤_ : Ord -> Ord -> Set
data Ord where
succ : Ord -> Ord
limit : (x y : Ord) -> (x<y : succ x ≤ y) → Ord
data _≤_ where
≤-limiting : ∀ x y x<y z -> (limit x y x<y) ≤ z
≤-ind : (P : {x y : Ord} → x ≤ y → Set) →
(∀ x y x<y z → P x<y → P (≤-limiting x y x<y z)) →
(x y : Ord) → (x≤y : x ≤ y) → P x≤y
≤-ind P l .(limit x y x<y) .z (≤-limiting x y x<y z) = l x y x<y z (≤-ind P l (succ x) y x<y) This gives the error
because the dot pattern has been "moved" from |
It seems that the dots are moved because of forced constructor arguments. A workaround is to enable the flag |
Note that |
…bles and record constructors even with --cubical
…erns With #4606, --cubical no longer considered dotted patterns as patterns for termination certification. This patch considers dotted variables and dotted record patterns as benign and considers then as pattern always in the termination checker, even in the first phase (no dot-patterns) which is the only phase with --cubical. (The other modes have the dot-pattern termination phase as well.)
…erns With #4606, --cubical no longer considered dotted patterns as patterns for termination certification. This patch considers dotted variables and dotted record patterns as benign and considers then as pattern always in the termination checker, even in the first phase (no dot-patterns) which is the only phase with --cubical. (The other modes have the dot-pattern termination phase as well.)
…erns With #4606, --cubical no longer considered dotted patterns as patterns for termination certification. This patch considers dotted variables and dotted record patterns as benign and considers then as pattern always in the termination checker, even in the first phase (no dot-patterns) which is the only phase with --cubical. (The other modes have the dot-pattern termination phase as well.)
…erns With #4606, --cubical no longer considered dotted patterns as patterns for termination certification. This patch considers dotted variables and dotted record patterns as benign and considers then as pattern always in the termination checker, even in the first phase (no dot-patterns) which is the only phase with --cubical. (The other modes have the dot-pattern termination phase as well.)
This code is not accepted:
Agda seems to move the dot pattern from the
r
constructor to thed
constructor, and because the underscore on the last line is inferred to befst′ (x , r₁)
rather thanx
the code is rejected (after @Saizan's fix of #4606).Can we do better?
The text was updated successfully, but these errors were encountered: