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

Adds unary disjoint relation

Open bsaul opened this issue 11 months ago • 26 comments

This PR adds the relation between two predicates expressing disjointness.

I am not at all wedded to the _#_ notation.

See the discussion on the Agda Zulip for more background.

bsaul avatar Feb 19 '25 16:02 bsaul

Before I fix the build errors (due to overloaded # symbol), I'll wait till we've settled on notation.

bsaul avatar Feb 19 '25 16:02 bsaul

(in lieu of my (now deleted) comment, I took the liberty of adding the link myself to your OP... hope that's OK)

jamesmckinna avatar Feb 19 '25 18:02 jamesmckinna

(I took the liberty of adding the link myself to your OP... hope that's OK)

Of course, thanks!

bsaul avatar Feb 19 '25 19:02 bsaul

cf. #2594 ... Can you also add some properties of these relations? Or other extensions, eg.:

  • prove Symmetric _⊥_, Symmetric _≬_
  • lift _⊥_ to Relation.Binary.Definitions (and even: Relation.Nullary?), and redefine Irreflexive using it?
  • redefine relational composition using _≬_? (there may be dependency issues in trying to do this; partly because of the Nullary/Unary/Binary distinction, and partly because neither of Unary nor Nullary split off distinct Definitions modules...)
  • ...

All of these strictly go outside the scope of what you have so far, but might also give life to the new definitions.

You also alluded to how they are part of your basic toolkit when developing in Agda, so what's a specimen client application/deployment context which might also be generally useful as an addition to the library?

jamesmckinna avatar Feb 20 '25 07:02 jamesmckinna

Can you also add some properties of these relations?

Yes, will do. Those are good suggestions.

bsaul avatar Feb 20 '25 19:02 bsaul

You also alluded to how they are part of your basic toolkit when developing in Agda, so what's a specimen client application/deployment context which might also be generally useful as an addition to the library?

I'm working on formalizing parts probability/statistics/causal inference wherein disjoint "events" or sets are sometimes a precondition in a theorem, e.g. Pearl's definition of d-separation.

bsaul avatar Feb 20 '25 19:02 bsaul

You also alluded to how they are part of your basic toolkit when developing in Agda, so what's a specimen client application/deployment context which might also be generally useful as an addition to the library?

I'm working on formalizing parts probability/statistics/causal inference wherein disjoint "events" or sets are sometimes a precondition in a theorem, e.g. Pearl's definition of d-separation.

Nice! But not sure quite how in scope (yet) that might be for stdlib. Still the two concepts introduced are familiar to me from constructive approaches to (the foundations of) probability, cf. eg. Jan van Plato's book from some years ago now...

jamesmckinna avatar Feb 21 '25 12:02 jamesmckinna

Nice! But not sure quite how in scope (yet) that might be for stdlib.

I wouldn't expect most of what I'm noodling on to be in scope for stdlib -- I'm just trying to upstream things that might be.

bsaul avatar Feb 21 '25 13:02 bsaul

cf. eg. Jan van Plato's book from some years ago now...

Thanks for the reference -- looks quite interesting.

bsaul avatar Feb 21 '25 17:02 bsaul

  • prove Symmetric _⊥_, Symmetric _≬_

Done in f77d38b

bsaul avatar Feb 21 '25 20:02 bsaul

  • lift _⊥_ to Relation.Binary.Definitions? and redefine Irreflexive using it?

Trying to import Relation.Unary into Relation.Binary.Defintions introduces a cyclic dependency, so I suspect there would be a bit of refactoring to make this happen.

bsaul avatar Feb 21 '25 20:02 bsaul

On Tue, Feb 25, 2025 at 05:20:24PM -0800, Jacques Carette wrote:

that would be nice (fat perp)

Fat perp is apparently not on offer by Unicode, but see:

https://www.fileformat.info/info/unicode/char/search.htm?q=perp&han=Y

https://www.fileformat.info/info/unicode/char/search.htm?q=tack&han=Y

WolframKahl avatar Feb 26 '25 02:02 WolframKahl

In favour of \perp:

  • easy to type
  • mildly distinct visually from \bot
  • definitely distinct visually/lexically from _#_

In favour of _#_

  • semantically it is an apartness
  • ... what else?

Regarding @WolframKahl 's links to Unicode, I wonder if perhaps we should make every module preamble comment include the new (infix/mixfix) symbols introduced with their character encodings (emacs and Unicode?), as 'self-documentation', rather than trying to build a big lookup table in style-guide?

jamesmckinna avatar Feb 26 '25 11:02 jamesmckinna

I wonder if perhaps we should make every module preamble comment include the new (infix/mixfix) symbols introduced with their character encodings (emacs and Unicode?), as 'self-documentation', rather than trying to build a big lookup table in style-guide?

That seems like a good idea.

JacquesCarette avatar Feb 26 '25 13:02 JacquesCarette

I wonder if perhaps we should make every module preamble comment include the new (infix/mixfix) symbols introduced with their character encodings (emacs and Unicode?), as 'self-documentation', rather than trying to build a big lookup table in style-guide?

That seems like a good idea.

Agreed.

bsaul avatar Feb 26 '25 16:02 bsaul

On Wed, Feb 26, 2025 at 03:58:22AM -0800, jamesmckinna wrote:

In favour of \perp:

  • [...]
  • mildly distinct visually from \bot

With my current fonts, I can see that when they are side-by-side, but I wouldn't be able to distinguish individual occurrences. I'd therefore argue against using both symbols in Agda.

WolframKahl avatar Feb 26 '25 16:02 WolframKahl

On Wed, Feb 26, 2025 at 03:58:22AM -0800, jamesmckinna wrote: In favour of \perp: * [...] * mildly distinct visually from \bot With my current fonts, I can see that when they are side-by-side, but I wouldn't be able to distinguish individual occurrences. I'd therefore argue against using both symbols in Agda.

Hmm... that's a shame, I think. I'd maybe try to influence things further by adding

  • \perp as a definition is lifting/proxying for the underlying appeal to \bot, so 'it makes sense' (?) to use cognate symbols
  • plus any additional cognitive reinforcement arising from documenting the symbology sur place

But I'd better stop beating this particular donkey now.

jamesmckinna avatar Feb 27 '25 11:02 jamesmckinna

I have no strong opinions on the choice of symbol. We use quite a lot of close cognates in the library already, but I can understand the urge not to add more.

MatthewDaggitt avatar Mar 03 '25 04:03 MatthewDaggitt

@bsaul I've made a couple of suggestions, and additions, happy to commit those if you don't have time, along with fixing up the merge conflicts.

jamesmckinna avatar Apr 07 '25 08:04 jamesmckinna

@bsaul I've made a couple of suggestions, and additions, happy to commit those if you don't have time, along with fixing up the merge conflicts.

@jamesmckinna looks good to me. I can make the changes later today. But if you have time sooner, please feel free to make the commits and fix up.

bsaul avatar Apr 07 '25 11:04 bsaul

Merge conflicts resolved; additions improve level polymorphism, but also (hopefully) avoid potential unsolved metas when applying the *-sym proofs, but given my involvement, a second review/fresh pair of eyes would be helpful before merging.

jamesmckinna avatar Apr 08 '25 02:04 jamesmckinna

I've opened https://github.com/agda/agda/pull/7791/files to add the relevant unicode symbols

gallais avatar Apr 08 '25 13:04 gallais

So maybe we should hold off on this, so that the new symbol(s) can be used?

JacquesCarette avatar Apr 08 '25 13:04 JacquesCarette

Very happy/happier still with fat perp over perp... however we end up supporting it?

jamesmckinna avatar Apr 08 '25 16:04 jamesmckinna

I've opened https://github.com/agda/agda/pull/7791/files to add the relevant unicode symbols

Oh I see, \bbot is 'short' like \bot, rather than 'tall' like \perp. Hmmm...

jamesmckinna avatar Apr 08 '25 20:04 jamesmckinna

Once we can and do agree on the symbol, suggest updating the declaration of the symbol in the spirit of #2690 ...

jamesmckinna avatar Apr 09 '25 06:04 jamesmckinna

Can we (@JacquesCarette @gallais) agree this for v2.3?

jamesmckinna avatar Jun 25 '25 14:06 jamesmckinna