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

Yet another irrelevant instance bug #428

Open
ncfavier opened this issue Aug 27, 2024 · 0 comments
Open

Yet another irrelevant instance bug #428

ncfavier opened this issue Aug 27, 2024 · 0 comments

Comments

@ncfavier
Copy link
Member

Minimised from #427 (comment)

open import Agda.Builtin.Nat
open import Agda.Builtin.Equality

data _≤_ : Nat  Nat  Set where
  0≤x :  {x}  0 ≤ x
  s≤s :  {x y}  x ≤ y  suc x ≤ suc y

instance
  s≤s' :  {x y}  ⦃ x ≤ y ⦄  suc x ≤ suc y
  s≤s' ⦃ x ⦄ = s≤s x

  x≤sucy :  {x y} ⦃ p : x ≤ y ⦄  x ≤ suc y
  x≤sucy {.0} {y} ⦃ 0≤x ⦄ = 0≤x
  x≤sucy {.(suc _)} {.(suc _)} ⦃ s≤s p ⦄ = s≤s (x≤sucy ⦃ p ⦄)

  {-# INCOHERENT x≤sucy #-}

Positive : Nat  Set
Positive n = 1 ≤ n

postulate
  z : (b : Nat)  .⦃ _ : Positive b ⦄  Nat
  foo : ∀ n → .⦃ _ : Positive n ⦄  z n ≡ 0

bar : ∀ n → ⦃ _ : Positive n ⦄  z n ≡ 0
bar n@(suc _) ⦃ p ⦄ = foo n

{-
p != s≤s _54 of type 1 ≤ suc n₁
when checking that n is a valid argument to a function of type
(n₂ : Nat) .⦃ _ = z₁ : Positive n₂ ⦄ → z n₂ ≡ 0
-}

If the instance argument to foo is not marked irrelevant, then the error is

Failed to solve the following constraints:
  Resolve instance argument _58 : Positive (suc n₁)
  Candidates
    s≤s' : {x y : Nat} ⦃ _ : x ≤ y ⦄ → suc x ≤ suc y
    p : 1 ≤ suc n₁
    (stuck)

I think it's trying to compare z n ⦃ p ⦄ with z n ⦃ s≤s' ⦄, which should succeed but fails (why?)

@ncfavier ncfavier mentioned this issue Aug 27, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant