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

Adding an (existentially quantified) sublist

Open ajrouvoet opened this issue 7 years ago • 13 comments

We have Sublist.Inductive to relationally define what xs are sublists/OPEs of a given ys. It seems useful to me to actually define a notion Sublist ys to existentially quantify over the xs, with definitions:

  ⊤ : ∀ {l} → Sublist l
  ⊥ : ∀ {l} → Sublist l
  Empty : ∀ {l} → Sublist l → Set a
  _∪_ : ∀ {l} → (xs ys : Sublist l) → Sublist l
  _∩_ : ∀ {l} → (xs ys : Sublist l) → Sublist l

This is completely analogue to the notion Fin.Subset n for natural numbers.

I have these definitions sitting in a branch here. I would like some input on:

  • [ ] Where should this be defined?
  • [ ] Equality of a sublist to ⊤ appears hard to prove in practice. Proving that the reification of a sublist of xs is equal to xs seems more practical. This begs for the definition of Every as a counterpart to Empty.

ajrouvoet avatar Dec 04 '18 16:12 ajrouvoet

_∪_ : ∀ {l} → (xs ys : Sublist l) → Sublist l
_∩_ : ∀ {l} → (xs ys : Sublist l) → Sublist l

Ooooh fancy. I don't think we have meet & joins for the current inductive sublists?

I don't know where this would go. As for the last point: can't we add a proof that if reify equals xs then the sublist equals whenever the setoid equalities are irrelevant?

gallais avatar Dec 04 '18 16:12 gallais

We do not have those now indeed, probably exactly because the left operand of the output is then existentially quantified.

The latter proof I have indeed. So maybe naming the intermediate representation is unnecessary?

After your note on the other issue about closure I realized that this is another example of the closure of a relation, but using the 'somewhere' modality, rather than the everywhere. Might be useful to define that modality and define Sublist as such.

ajrouvoet avatar Dec 04 '18 18:12 ajrouvoet

As for location I've been thinking about adding a Predicate subfolder to match the Relation folder for compositional data. This should really live in Data.List.Predicate.Sublist right? The only problem is that Any and All are so widely used that it's going to be backwards compatible nightmare.... I guess we could deprecate the module.

MatthewDaggitt avatar Dec 06 '18 13:12 MatthewDaggitt

I was thinking about that but we have Relation.Unary rather than Predicate. So for consistency we should maybe reorganise the whole Data.List.Relation into Data.List.Relation.Unary and Data.List.Relation.Binary?

We could maintain backwards compatibility by having placeholder modules for a while with the old name and re-exporting the new one. Then we would really need WARNING_ON_IMPORT to be sure we can get rid of them at some point in the future.

gallais avatar Dec 06 '18 13:12 gallais

Good point! Do you think there's any prospect of such a magic WARNING_ON_IMPORT sneaking into the next release of Agda? :smile:

MatthewDaggitt avatar Dec 06 '18 13:12 MatthewDaggitt

There's a feature freeze at the moment so the answer is no. Plus I'm currently making sure I finally ship my thesis. :D

But I may find the time to write something like over the Xmas holidays.

gallais avatar Dec 06 '18 13:12 gallais

Plus I'm currently making sure I finally ship my thesis. :D

Congrats!

Okay no problem. The warnings can always come later. @ajrouvoet mind if you hold off on your PR until we complete this rearrangement?

MatthewDaggitt avatar Dec 06 '18 14:12 MatthewDaggitt

@MatthewDaggitt SGTM. Currently there really is no natural place for this code anyway. I'm using the Sublist elsewhere and still adding properties to it, so holding off sounds fine :)

ajrouvoet avatar Dec 13 '18 10:12 ajrouvoet

Unblocked.

MatthewDaggitt avatar Jun 18 '19 13:06 MatthewDaggitt

Does the refactoring of Data.List.Relation.Unary.{Prefix|Suffix} as instances of abstract divisibility #2604 close this, or rather, can we refactor the proposed constructions as suitable lubs/glbs for the corresponding orderings?

jamesmckinna avatar Oct 28 '25 09:10 jamesmckinna

Sublist is more general surely?

gallais avatar Oct 28 '25 09:10 gallais

Sublist is more general surely?

Yes, I'm an idiot!

jamesmckinna avatar Oct 28 '25 10:10 jamesmckinna

We do not have those now indeed, probably exactly because the left operand of the output is then existentially quantified.

As befits the abstract name of a universal construction: we shouldn't care! only the universal property matters!?

jamesmckinna avatar Nov 05 '25 09:11 jamesmckinna