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

Agsy/Auto crashes with Prelude.!!: index too large #5794

Closed
Trebor-Huang opened this issue Feb 14, 2022 · 4 comments · Fixed by #6150
Closed

Agsy/Auto crashes with Prelude.!!: index too large #5794

Trebor-Huang opened this issue Feb 14, 2022 · 4 comments · Fixed by #6150
Assignees
Labels
auto Issues to do with the Auto proof search (Mimer, Agsy) de-Bruijn Internal problems with variable scoping ("de Bruijn indices") internal-error Concerning internal errors of Agda type: bug Issues and pull requests about actual bugs
Milestone

Comments

@Trebor-Huang
Copy link

When trying to formalize some very dependent inductive-recursive types, Agda crashes when trying to C-c C-a a hole:

data Context : Set
data Type : Context -> Set
data Var :  Γ -> Type Γ -> Set

variable
    Γ Δ Ξ : Context
    α β : Type Γ

data Context where
    : Context
    _◂_ :  Γ -> Type Γ -> Context
infixl 5 _◂_

data Type where
    : Type Γ
    var : Var Γ ⋆ -> Type Γ
    Π_ : Type (Γ ◂ ⋆) -> Type Γ
    _⇒_ : Type Γ -> Type Γ -> Type Γ

data Ren : Context -> Context -> Set
rent : Ren Δ Γ -> Type Γ -> Type Δ  -- renaming on types
𝔭 : Ren (Γ ◂ α) Γ

data Ren where
    stop : Ren ∅ ∅
    drop : Ren Γ Δ -> Ren (Γ ◂ α) Δ
    keep :: Ren Γ Δ) -> Ren (Γ ◂ rent ρ α) (Δ ◂ α)

data Var where
    𝔮 : Var (Γ ◂ α) (rent 𝔭 α)
    𝕤_ : Var Γ α -> Var (Γ ◂ β) (rent 𝔭 α)

fetch :: Ren Γ Δ) -> Var Δ α -> Var Γ (rent ρ α)
fetch ρ 𝔮 = {!   !}  -- Here
fetch ρ (𝕤 i) = {!   !}

rent ρ ⋆ = ⋆
rent ρ (var i) = {!   !} -- var (fetch ρ i)
rent ρ (Π t) = Π {!   !}
rent ρ (t ⇒ s) = rent ρ t ⇒ rent ρ s

The hole is marked with --Here. However, if the hole below in rent is filled with the expression in the comment then the issue disappears.

Agda version: v2.6.2.1-af5bfc0 installed with cabal. I'm using OS X, on VSCode.

@nad
Copy link
Contributor

nad commented Feb 14, 2022

I replaced every (?) occurrence of (Prelude.!!) with a new function that provides better error messages. The following call to (!!) uses an index that is out of bounds:

return (weak (v + 1) (snd $ ctx !! v), id)

@nad
Copy link
Contributor

nad commented Feb 14, 2022

The comment on the previous line looks suspicious to me:

Var v -> -- assuming within scope
return (weak (v + 1) (snd $ ctx !! v), id)

Perhaps one could simply fail if the variable is out of scope.

@nad nad added auto Issues to do with the Auto proof search (Mimer, Agsy) type: bug Issues and pull requests about actual bugs labels Feb 14, 2022
@nad nad added this to the 2.6.3 milestone Feb 14, 2022
@andreasabel andreasabel linked a pull request Feb 14, 2022 that will close this issue
@andreasabel andreasabel added the de-Bruijn Internal problems with variable scoping ("de Bruijn indices") label Feb 15, 2022
@nad nad removed a link to a pull request Feb 16, 2022
@andreasabel andreasabel added the internal-error Concerning internal errors of Agda label Aug 31, 2022
@andreasabel
Copy link
Member

Amelia, I unassigned you since you have enough on your plate already, and this issue doesn't require your expertise.

@andreasabel
Copy link
Member

Perhaps one could simply fail if the variable is out of scope.

This is what I implemented.

@andreasabel andreasabel self-assigned this Sep 30, 2022
@andreasabel andreasabel changed the title Prelude.!!: index too large Agsy/Auto crashes with Prelude.!!: index too large Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto Issues to do with the Auto proof search (Mimer, Agsy) de-Bruijn Internal problems with variable scoping ("de Bruijn indices") internal-error Concerning internal errors of Agda type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants