agda-stdlib icon indicating copy to clipboard operation
agda-stdlib copied to clipboard

Problem with `DISPLAY` pragma for `⊥` in `Data.Empty`

Open jamesmckinna opened this issue 1 year ago • 6 comments

Agda issue#7533 and its 'resolution'/explanation via Agda issue#2004 suggests that perhaps we should rethink our approach to how to deal lexically with the token (for output as well as input)? Or else (at least!) document that Data.Irrelevant should be approached with caution...

Sadly, syntax declarations are subject to the same, or similar, effects, so attempting to write

syntax Irrelevant Empty = ⊥

is both ill-formed (the 'hole' Empty is never used), and useless (Empty is not correctly interpreted as a already-defined term).

Perhaps a solution is simply to remove the DISPLAY pragma altogether? UPDATED: NB. this is the only use of the pragma in stdlib!

jamesmckinna avatar Oct 04 '24 13:10 jamesmckinna

Hmm, this is very irritating. It's a big usability loss to remove the DISPLAY pragma... I really don't want Irrelevant Empty popping up in people's buffers...

Introduced by @gallais in https://github.com/agda/agda-stdlib/commit/367e3d620a8512a36e2916dc081cdf300593f749. Can't exactly revert this either, as it'll break a lot of code.

@gallais any ideas?

Could we use the new abstract feature somehow to prevent reduction?

MatthewDaggitt avatar Oct 07 '24 02:10 MatthewDaggitt

Could we use the new abstract feature somehow to prevent reduction?

This is what I was going to suggest we should experiment with.

However the following does not typecheck and so it does seem that Agda's emptyness check refuses to go under abstract types which would make it a dramatically breaking change.

data Empty : Set where

abstract

  ⊥ : Set
  ⊥ = Empty


⊥-elim : ⊥ → ∀ {a} {A : Set a} → A
⊥-elim ()

I've commented on an upstream issue bringing up a similar issue for positivity annotations: https://github.com/agda/agda/issues/6970#issuecomment-2396159611

gallais avatar Oct 07 '24 07:10 gallais

Andreas has reopened my originating issue, so there may be upstream progress at some point https://github.com/agda/agda/pull/7536 ... in the meanwhile, display pragma is a new label on the main Agda issue tracker...

Separately, he hinted that perhaps REWRITE could be used here, but I'm not clear whether or not any such attempt would be subject to the same interpretation of Empty as a (pattern) variable...

jamesmckinna avatar Oct 07 '24 08:10 jamesmckinna

As for pragmatics of the problem, I only encountered it when trying to have Data.Empty and Data.Irrelevant in scope at the same time... a (perhaps) rare scenario? (And leaning in to my customary observation about explicit use of and ⊥-elim when these are largely avoidable via other mechanisms...)

jamesmckinna avatar Oct 07 '24 08:10 jamesmckinna

Prompted by this issue, Agda 2.8 might have more usable DISPLAY pragmas:

  • https://github.com/agda/agda/pull/7543

This should fix your problem (albeit not right now).

andreasabel avatar Oct 08 '24 15:10 andreasabel

That's great, thank you! So I guess we mark this issue as blocked upstream and wait for the fix.

MatthewDaggitt avatar Oct 09 '24 05:10 MatthewDaggitt

@jamesmckinna can you confirm that this problem is resolved in v2.8.0-rc3 and if so close this issue?

MatthewDaggitt avatar Jun 30 '25 06:06 MatthewDaggitt

Ugh... @MatthewDaggitt it turns out in my setup that I can't seem to install RC3 (both cabal- and stack- based install fall over, the first with dependencies, the second with invalid HTTP requests), so I can't seem to achieve this right now... sigh.

jamesmckinna avatar Jun 30 '25 07:06 jamesmckinna

@Taneb are you able to check that the issue goes away under v2.8.0-rc3?

jamesmckinna avatar Jun 30 '25 07:06 jamesmckinna

I'll take a look this afternoon

Taneb avatar Jun 30 '25 07:06 Taneb

Sorry I won't have time now to look at this, any update @Taneb ?

jamesmckinna avatar Jul 02 '25 07:07 jamesmckinna

Okay removing this from v2.3 milestone regardless as I think the consensus is that this is an upstream problem rather than something to be fixed by us now.

MatthewDaggitt avatar Jul 03 '25 03:07 MatthewDaggitt

Isn't this fixed by switching to Agda 2.8.0?

andreasabel avatar Jul 05 '25 10:07 andreasabel

After some install woes, I can now confirm that this is fixed by v2.8.0! :tada:

jamesmckinna avatar Jul 07 '25 09:07 jamesmckinna