Skip to content
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

de Bruijn error on unexpected implicit argument #6043

Closed
mikeshulman opened this issue Aug 21, 2022 · 3 comments · Fixed by #6094
Closed

de Bruijn error on unexpected implicit argument #6043

mikeshulman opened this issue Aug 21, 2022 · 3 comments · Fixed by #6094
Assignees
Labels
de-Bruijn Internal problems with variable scoping ("de Bruijn indices") regression in 2.6.1 Regression that first appeared in Agda 2.6.1 rewriting Rewrite rules, rewrite rule matching status: already-fixed type: bug Issues and pull requests about actual bugs
Milestone

Comments

@mikeshulman
Copy link
Contributor

{-# OPTIONS --type-in-type --rewriting #-}

open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite

infixl 30 _∙_
infixr 30 _,_

postulate
  _=_ : {A : Set}  A  A  Set
  refl' : {A : Set} (a : A)  (a = a)
  Σ : (A : Set) (B : A  Set)  Set
  _,_ : {A : Set} {B : A  Set} (a : A)  B a  Σ A B
  fst : {A : Set} {B : A  Set}  Σ A B  A
  snd : {A : Set} {B : A  Set} (u : Σ A B)  B (fst u)
  fstβ : {A : Set} {B : A  Set} (a : A) (b : B a)  fst {A} {B} (a , b) ≡ a
{-# REWRITE fstβ #-}
postulate
  sndβ : {A : Set} {B : A  Set} (a : A) (b : B a)  snd {A} {B} (a , b) ≡ b
{-# REWRITE sndβ #-}
postulate
  Π : (A : Set) (B : A  Set)  Set
  𝛌 : {A : Set} {B : A  Set} (f : (x : A)  B x)  Π A B
  _∙_ : {A : Set} {B : A  Set} (f : Π A B) (a : A)  B a
  Πβ : {A : Set} {B : A  Set} (f : (x : A)  B x) (a : A)  (𝛌 f ∙ a) ≡ f a
{-# REWRITE Πβ #-}
postulate
  Id : {A : Set} (B : A  Set) {a₀ a₁ : A} (a₂ : a₀ = a₁) (b₀ : B a₀) (b₁ : B a₁)  Set
  Id-const : (A B : Set) {a₀ a₁ : A} (a₂ : a₀ = a₁) 
    Id {A} (λ _  B) a₂ ≡ _=_ {B}
{-# REWRITE Id-const #-}
postulate
  ap : {A : Set} {B : A  Set} (f : (x : A)  B x)
    {a₀ a₁ : A} (a₂ : a₀ = a₁)  Id B a₂ (f a₀) (f a₁)
  =-Σ : {A : Set} {B : A  Set} (u v : Σ A B) 
    (u = v) ≡ Σ (fst u = fst v) (λ p  Id B p (snd u) (snd v))
{-# REWRITE =-Σ #-}
postulate
  Id-Π :: Set} {A : Δ  Set} {B : (x : Δ)  A x  Set}
    {δ₀ δ₁ : Δ} (δ₂ : δ₀ = δ₁)
    (f₀ : Π (A δ₀) (B δ₀)) (f₁ : Π (A δ₁) (B δ₁)) 
    Id (λ x  Π (A x) (B x)) δ₂ f₀ f₁ ≡
    Π (Σ (A δ₀) (λ a₀  Σ (A δ₁) (λ a₁  Id A δ₂ a₀ a₁))) (λ aₓ 
    Id {Σ Δ A} (λ x  B (fst x) (snd x)) {δ₀ , fst aₓ} {δ₁ , fst (snd aₓ)} (δ₂ , snd (snd aₓ))
      (f₀ ∙ fst aₓ) (f₁ ∙ fst (snd aₓ)))
{-# REWRITE Id-Π #-}
postulate
  _↓ : {X₀ X₁ : Set} (X₂ : X₀ = X₁)  (X₀  X₁  Set)
  refl'↓ : (A : Set)  (refl' A ↓) ≡ (_=_ {A})
{-# REWRITE refl'↓ #-}
postulate
  Id-∙ :: Set} {A : Δ  Set} (f :: Δ)  Π (A δ) (λ _  Set))
    (a :: Δ)  A δ) {δ₀ δ₁ : Δ} (δ₂ : δ₀ = δ₁)
    (x₀ : f δ₀ ∙ a δ₀) (x₁ : f δ₁ ∙ a δ₁) 
    Id (λ δ  f δ ∙ a δ) δ₂ x₀ x₁ ≡ ((ap f δ₂ ∙ (a δ₀ , a δ₁ , ap a δ₂) ↓) x₀ x₁)
{-# REWRITE Id-∙ #-}

frob-ap-∙² :: Set} (A B : Π Δ (λ _  Set))
  {δ₀ δ₁ : Δ} (δ₂ : δ₀ = δ₁) (x₀ : A ∙ δ₀) (x₁ : A ∙ δ₁) (x₂ : Id (A ∙_) δ₂ x₀ x₁) (y₀ : B ∙ δ₀) (y₁ : B ∙ δ₁) 
  Id (λ u  B ∙ (fst u)) {δ₀ , x₀} {δ₁ , x₁} (δ₂ , x₂) y₀ y₁ 
  Id (B ∙_) δ₂ y₀ y₁
frob-ap-∙² {Δ} A B f a {δ₀} {δ₁} δ₂ x₀ x₁ x₂ = ?

produces

de Bruijn index out of scope: 9 in context [x]
CallStack (from HasCallStack):
  error, called at src/full/Agda/TypeChecking/Monad/Base.hs:4147:10 in Agda-2.6.3-K939Rz0lK6d4Qhz5rVu9uS:Agda.TypeChecking.Monad.Base

The correct error is "Unexpected implicit argument".

@andreasabel andreasabel added rewriting Rewrite rules, rewrite rule matching de-Bruijn Internal problems with variable scoping ("de Bruijn indices") labels Aug 21, 2022
@jespercockx jespercockx self-assigned this Aug 21, 2022
@jespercockx jespercockx added the type: bug Issues and pull requests about actual bugs label Aug 21, 2022
@jespercockx jespercockx added this to the 2.6.3 milestone Aug 23, 2022
@jespercockx
Copy link
Member

This one turned out to be not easy to minimize, but I managed to do it in the end:

{-# OPTIONS --type-in-type --rewriting #-}

open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite

postulate
  id : Set  Set
  rew-id : (A : Set)  id A ≡ A
{-# REWRITE rew-id #-}

postulate
  F : Set  Set

postulate
  f : Set  Set
  g : Set  Set  Set
  rew-fg : (A : Set)  g A (f A) ≡ Set
{-# REWRITE rew-fg #-}

test :: Set)  g (F δ) (f (F (id δ)))
test _ _ = {!!}

@jespercockx
Copy link
Member

Wait, I spent all this time minimizing this example, and now it turns out it was already fixed and I was just using an old executable of Agda? :/

jespercockx added a commit to jespercockx/agda that referenced this issue Sep 7, 2022
@jespercockx jespercockx linked a pull request Sep 7, 2022 that will close this issue
@andreasabel andreasabel added status: already-fixed regression in 2.6.1 Regression that first appeared in Agda 2.6.1 labels Oct 24, 2022
@andreasabel
Copy link
Member

This worked in 2.6.0 with error (for the MWE):

Cannot eliminate type Set with wildcard pattern _ (did you supply
too many arguments?)
when checking that the clause test _ _ = ? has type
(δ : Set) → g (F δ) (f (F (id δ)))

Broken in 2.6.1 and 2.6.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
de-Bruijn Internal problems with variable scoping ("de Bruijn indices") regression in 2.6.1 Regression that first appeared in Agda 2.6.1 rewriting Rewrite rules, rewrite rule matching status: already-fixed type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants