-
Notifications
You must be signed in to change notification settings - Fork 339
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
__IMPOSSIBLE__ at src/full/Agda/TypeChecking/Reduce/Fast.hs:1394:20 #5819
Comments
It is not too hard to shrink the standard-library away from this test case: open import Agda.Builtin.Unit using (⊤; tt)
open import Agda.Builtin.Nat renaming (Nat to ℕ)
open import Agda.Builtin.Equality
open import Agda.Builtin.Sigma renaming (fst to proj₁; snd to proj₂)
data ⊥ : Set where
∃ : {A : Set} (B : A → Set) → Set
∃ B = Σ _ B
_×_ : (A B : Set) → Set
A × B = Σ A λ _ → B
sym : {A : Set} {x y : A} → x ≡ y → y ≡ x
sym refl = refl
_≢_ : {A : Set} (x y : A) → Set
x ≢ y = x ≡ y → ⊥
record Inverse (A B : Set) : Set where
field
f : A → B
f⁻¹ : B → A
inverse : ∀ x → f (f⁻¹ x) ≡ x
open Inverse
data DList : Set
Fresh : (a : ℕ) → (l : DList) → Set
data DList where
dnil : DList
dcons : (a : ℕ) → (l : DList) → Fresh a l → DList
Fresh a dnil = ⊤
Fresh a (dcons b l _) = (a ≢ b) × Fresh a l
data List′ : Set where
nil′ : List′
cons′ : ℕ → List′ → List′
Fresh′ : ℕ → List′ → Set
Fresh′ a nil′ = ⊤
Fresh′ a (cons′ b l) = (a ≢ b) × Fresh′ a l
AllFresh : List′ → Set
AllFresh nil′ = ⊤
AllFresh (cons′ a l) = Fresh′ a l × AllFresh l
data DList′ : List′ → Set → Set₁ where
dnil′ : DList′ nil′ ⊤
dcons′ : ∀{l}{prf} → (a : ℕ) → DList′ l prf → DList′ (cons′ a l) (Fresh′ a l × prf)
data DList″ : Set where
dl″ : (l : List′) → AllFresh l → DList″
undl″-l : DList″ → List′
undl″-l (dl″ l _) = l
undl″-p : DList″ → ∃ AllFresh
undl″-p (dl″ l p) = l , p
-- dl-iso : DList ↔ DList″
dl-iso : Inverse DList DList″
-- f-dl-iso : DList → DList″
-- g-dl-iso : DList″ → DList
-- inverse-dl-iso : ∀ x → f-dl-iso (g-dl-iso x) ≡ x
Fresh→Fresh′ : ∀{a}{l}{l″}
→ (f dl-iso l ≡ l″)
→ Fresh a l
→ Fresh′ a (undl″-l l″)
Fresh→AllFresh : ∀{a}{l}{l″}
→ (f dl-iso l ≡ l″)
→ Fresh a l
→ AllFresh (undl″-l l″)
All/Fresh′→Fresh : ∀{a}{l}{l″}
→ (l ≡ f⁻¹ dl-iso l″)
→ Fresh′ a (undl″-l l″) × AllFresh (undl″-l l″)
→ Fresh a l
f dl-iso dnil = dl″ nil′ tt
f dl-iso (dcons a l p)
= dl″ (cons′ a (undl″-l (f dl-iso l)))
((Fresh→Fresh′ {l = l}{l″ = f dl-iso l} refl p) ,
(Fresh→AllFresh {a = a}{l = l}{l″ = f dl-iso l} refl p))
f⁻¹ dl-iso (dl″ nil′ p) = dnil
f⁻¹ dl-iso (dl″ (cons′ a l′) p)
= dcons a (f⁻¹ dl-iso (dl″ l′ (proj₂ p)))
(All/Fresh′→Fresh {l″ = dl″ l′ (proj₂ p)} refl p)
-- Can't do any further, otherwise an Agda bug occurs.
inverse dl-iso x = invˡ
where
invˡ : ∀{x} → f dl-iso (f⁻¹ dl-iso x) ≡ x
invˡ {dl″ nil′ _} = refl
invˡ {dl″ (cons′ a l) p} rewrite invˡ {dl″ l ?} = {!!} -- the "rewrite invˡ {dl″ l ?}" causes the internal error
Fresh→Fresh′ {a} {dnil} eq p rewrite sym eq = tt
Fresh→Fresh′ {a} {dcons a₁ l x} eq p rewrite sym eq
= proj₁ p , Fresh→Fresh′ {l″ = f dl-iso l} refl (proj₂ p)
Fresh→AllFresh {l = dnil} eq p rewrite sym eq = tt
Fresh→AllFresh {l = dcons a l x} eq p rewrite sym eq
= (Fresh→Fresh′ {l″ = f dl-iso l} refl x) , Fresh→AllFresh {a = a}{l = l}{l″ = f dl-iso l} refl x
All/Fresh′→Fresh {a} {l″ = dl″ nil′ x} eq p rewrite eq = tt
All/Fresh′→Fresh {a} {l″ = dl″ (cons′ b l) x} eq p rewrite eq
= (proj₁ (proj₁ p)) , {!All/Fresh′→Fresh!} -- put "All/Fresh′→Fresh" in the hole and C-c C-r Crash site: agda/src/full/Agda/TypeChecking/Reduce/Fast.hs Lines 1277 to 1280 in 5401dc1
In Agda 2.6.1 you get a termination error, so this is a regression. The internal error goes away if I label
The error persists with agda/src/full/Agda/TypeChecking/CompiledClause/Match.hs Lines 205 to 207 in 5401dc1
Last words:
|
Bisection blames commit 8e0fca8 (ping @jespercockx)
|
Fixed by reverting the blamed commit, which tried to optimize termination checking by getting rid of a |
Produced on MacOs, with Agda version 2.6.3-b4e5b7a (also with 2.6.2.1 but on Line 1380).
The error message is:
There are two places that can trigger the bug. To reproduce, load the following program (which I haven't been able to reduce to a smaller one, sorry), and in the holes in
invˡ
and the one inAll/Fresh′→Fresh
, follow the comments to reproduce.The text was updated successfully, but these errors were encountered: