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

Irrelevance bug to prove false #610

Closed
GoogleCodeExporter opened this issue Aug 8, 2015 · 10 comments
Closed

Irrelevance bug to prove false #610

GoogleCodeExporter opened this issue Aug 8, 2015 · 10 comments
Assignees
Labels
irrelevance Issues to do with irrelevance annotations regression on master Unreleased regression in development version (Change to "regression in ..." should it be released!) type: bug Issues and pull requests about actual bugs with Problems with the "with" abstraction
Milestone

Comments

@GoogleCodeExporter
Copy link

When we were fooling around with irrelevance in #agda today, James Deikun found
that if you name your where modules in irrelevant contexts, you can make that
which is irrelevant relevant again, with some other trickery:

module RelevanceBug where

open import Level
open import Relation.Binary.PropositionalEquality

open import Data.Empty
open import Data.Unit

record A : Set₁ where
  constructor set
  field
    .a : Set

.get : A  Set
get x = helper x
  module R where
  helper : .A -> Set
  helper x = A.a x

ack : A  Set
ack x = R.helper x x

hah : set ⊤ ≡ set ⊥
hah = refl

.moo : ⊥
moo with cong ack hah
moo | q = subst (λ x  x) q _

baa : .⊥  ⊥
baa ()

yoink : ⊥
yoink = baa moo

An odd aspect to this hack is that cong ack hah does not have type ⊤ ≡ ⊥,
but rather has type .(⊤) ≡ .(⊥) which is actually considered distinct and
won't unify. Luckily, in the irrelevant moo function above, .(⊤) ≡ .(⊥)
magically turns into ⊤ ≡ ⊥ again, and we can do great evil again.

Original issue reported on code.google.com by pumpkingod@gmail.com on 16 Apr 2012 at 9:17

@GoogleCodeExporter GoogleCodeExporter added type: bug Issues and pull requests about actual bugs auto-migrated with Problems with the "with" abstraction priority: critical irrelevance Issues to do with irrelevance annotations labels Aug 8, 2015
@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 8, 2015

Oh, and I built Agda a couple of weeks ago. I was also surprised that it didn't ask me to postulate an irrAxiom.

Original comment by pumpkingod@gmail.com on 16 Apr 2012 at 9:34

@GoogleCodeExporter
Copy link
Author

Original comment by nils.anders.danielsson on 17 Apr 2012 at 9:13

  • Changed state: Accepted
  • Added labels: Priority-Critical, Type-Defect

@GoogleCodeExporter
Copy link
Author

There's a simpler to define ack which still makes the rest work:

.ack : A  Set
ack x = A.a x

Original comment by sanzhi...@gmail.com on 17 Apr 2012 at 9:20

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 8, 2015

Thanks for reporting these bugs. I am currently fixing the first one (modules and irrelevance), but the second one is independent (with and irrelevance).

Original comment by andreas....@gmail.com on 18 Apr 2012 at 12:15

@GoogleCodeExporter
Copy link
Author

Fixed.

The irrAxiom is now in the Kernel and printed as .(_)
In with functions it got lost, this is fixed now, so the great evil is cured.
Cheers, Andreas

Original comment by andreas....@gmail.com on 18 Apr 2012 at 1:08

  • Changed state: Fixed
  • Added labels: Irrelevance, With

@Saizan
Copy link
Contributor

Saizan commented Feb 11, 2016

Sometimes they come back:

open import Data.Unit
open import Data.Empty
open import Relation.Binary.PropositionalEquality

data A : Set₁ where
  set : .Set -> A

module M .(x : Set) where

  .out : Set
  out = x

.ack : A  Set
ack (set x) = M.out x

hah : set ⊤ ≡ set ⊥
hah = refl

.moo : ⊥
moo with cong ack hah
moo | q = subst (λ x  x) q _

baa : .⊥  ⊥
baa ()

yoink : ⊥
yoink = baa moo

@Saizan Saizan reopened this Feb 11, 2016
@asr asr added the regression on master Unreleased regression in development version (Change to "regression in ..." should it be released!) label Feb 11, 2016
@asr asr added this to the 2.5.1 milestone Feb 11, 2016
@jespercockx
Copy link
Member

jespercockx commented Feb 11, 2016

I guess we'll have to reset the counter again. Note that this time, it isn't necessary to use with:

.moo : ⊥
moo = subst (λ x  x) (cong ack hah) tt

Is the application cong ack supposed to typecheck?

@UlfNorell
Copy link
Member

I suspect that the problem is out. Note that if you try

.out : .(x : Set)  Set
out x = x

you get an error. Although I have to admit I'm not exactly sure what the rules are for irrelevant definitions.

@andreasabel
Copy link
Member

I'm not either. But it feels like the bodies of irrelevant definitions have to be protected by a DontCare just as for irrelevant projections. It fixes this issue. The rationale is that adding a DontCare does no harm, as irrelevant terms are all equal in irrelevant context. But the DontCare prevents us from tracelessly reducing away the constructor set whose argument is irrelevant.

@andreasabel
Copy link
Member

Associated commits (2012):

Date:   Wed Apr 18 12:37:48 2012 +0000

    Declaration in irrelevant context (e.g. where modules) must be irrelevant as well.
    Fixes part of issue 610.
Date:   Wed Apr 18 12:58:52 2012 +0000

    When checking a DontCare term, keep DontCare. (Fixes Issue 610-4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
irrelevance Issues to do with irrelevance annotations regression on master Unreleased regression in development version (Change to "regression in ..." should it be released!) type: bug Issues and pull requests about actual bugs with Problems with the "with" abstraction
Projects
None yet
Development

No branches or pull requests

6 participants