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

Internal error with src/full/Agda/TypeChecking/Substitute.hs:140:33 using Cubical Agda #7629

Open
anshwad10 opened this issue Nov 29, 2024 · 1 comment
Labels
cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp internal-error Concerning internal errors of Agda
Milestone

Comments

@anshwad10
Copy link

anshwad10 commented Nov 29, 2024

I'm using Agda 2.7.0.1 and the cubical library

{-# OPTIONS --cubical #-}

open import Cubical.Foundations.Prelude
open import Cubical.Data.Rationals.Base
open import Cubical.Data.Rationals.Order
open import Cubical.Data.Rationals.Properties

ℚ₊ : Type
ℚ₊ = Σ[ q ∈ ℚ ] q > 0

recip₊ : ℚ₊  ℚ₊
recip₊ (q , q+) = {!!}

When trying to case-split on q, it throws this error message:

An internal error has occurred. Please report this as a bug.
Location of the error: __IMPOSSIBLE__, called at src/full/Agda/TypeChecking/Substitute.hs:140:33 in Agda-2.7.0.1-3ZwbSnqgf4p8e0IQcAkutY:Agda.TypeChecking.Substitute
@andreasabel
Copy link
Member

Here is some initial shrinking, inlining the Order module and making all imports explicit.

{-# OPTIONS --cubical #-}

open import Agda.Builtin.Sigma using (Σ; _,_; fst; snd)

open import Cubical.Foundations.Prelude using (Type; ℓ-zero; _≡_; isProp→PathP; isPropIsProp)
open import Cubical.Foundations.HLevels using (hProp; isSet→SquareP; isSetHProp)

import Cubical.Data.Int.Base as ℤ using (_·_)
open import Cubical.Data.Int.Base using (ℤ)
import Cubical.Data.Int.Order as ℤ using (_<_; isProp<)
open import Cubical.Data.NatPlusOne using (ℕ₊₁)
open import Cubical.Data.Rationals.Base using (ℕ₊₁→ℤ; [_]; eq/; _∼_)
open import Cubical.Data.Rationals.Base using (ℚ; fromNat)
open import Cubical.Data.Sigma using (_×_)

open import Cubical.HITs.SetQuotients using (squash/)

postulate
  ANY : {ℓ} {A : Type ℓ}  A

infix 4 _<'_

postulate
  lemma< : ((a , b) (c , d) (e , f) : (ℤ × ℕ₊₁))
         (c ℤ.· ℕ₊₁→ℤ f ) ≡ (e ℤ.· ℕ₊₁→ℤ d)
         ((a ℤ.· ℕ₊₁→ℤ d) ℤ.< (c ℤ.· ℕ₊₁→ℤ b))
        ≡ ((a ℤ.· ℕ₊₁→ℤ f) ℤ.< (e ℤ.· ℕ₊₁→ℤ b))

-- Internal error disappears if I make fun₀ a postulate
fun₀ : ℤ × ℕ₊₁  hProp ℓ-zero
fun₀ (a , b) [ c , d ] .fst = a ℤ.· ℕ₊₁→ℤ d ℤ.< c ℤ.· ℕ₊₁→ℤ b
fun₀ _       [ _ ]     .snd = ℤ.isProp<
fun₀ a/b (eq/ c/d e/f cf≡ed i) = record
  { fst = lemma< a/b c/d e/f cf≡ed i
  ; snd = isProp→PathP (λ i  isPropIsProp {A = lemma< a/b c/d e/f cf≡ed i}) ℤ.isProp< ℤ.isProp< i
  }
fun₀ a/b (squash/ x y p q i j) =
  isSet→SquareP (λ _ _  isSetHProp)
    (λ _  fun₀ a/b x)
    (λ _  fun₀ a/b y)
    (λ i  fun₀ a/b (p i))
    (λ i  fun₀ a/b (q i)) j i

postulate
  toPath :  a/b c/d (x : a/b ∼ c/d) (y : ℚ)  fun₀ a/b y ≡ fun₀ c/d y

_<'_ : hProp ℓ-zero
_<'_ [ a/b ] y = fun₀ a/b y
_<'_ (eq/ a/b c/d ad≡cb i) y = toPath a/b c/d ad≡cb y i
_<'_ (squash/ x y p q i j) z =
  isSet→SquareP (λ _ _  isSetHProp)
    (λ _  x <' z) (λ _  y <' z) (λ i  p i <' z) (λ i  q i <' z) j i

test : Σ ℚ (λ q  fst (0 <' q))  Type
test (q , q+) = {!q!} -- C-c C-c case split on q

-- __IMPOSSIBLE__ at Agda/TypeChecking/Substitute.hs:139:33

@andreasabel andreasabel added cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp internal-error Concerning internal errors of Agda labels Dec 12, 2024
@andreasabel andreasabel added this to the 2.8.0 milestone Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp internal-error Concerning internal errors of Agda
Projects
None yet
Development

No branches or pull requests

2 participants