agda / agda-stdlib

The Agda standard library
https://wiki.portal.chalmers.se/agda/Libraries/StandardLibrary
Other
561 stars 234 forks source link

List of wrinkles in `Data.List.Properties` #2358

Open MatthewDaggitt opened 2 months ago

MatthewDaggitt commented 2 months ago

Various things spotted during https://github.com/agda/agda-stdlib/pull/2355/ that require breaking changes:

mildsunrise commented 2 months ago

thanks! noting some other inconsistencies i spotted while writing it:

jamesmckinna commented 2 months ago

Not sure about the third point regarding fold*-cong: currently Data.List.Properties is strongly biased towards PropositionalEquality, and as with #2360 , we maybe need a more systematic approach to making (all of) those Properties more Setoidal...

mildsunrise commented 2 months ago

currently Data.List.Properties is strongly biased towards PropositionalEquality

hmm, that looks like a separate problem to me? my point is that all other current congruence proofs in Data.List.Properties (map-cong, alignWith-cong, unalignWith-cong, concatMap-cong) only take equality on the function, not on the input list. only foldr-cong takes equality on the input list.

then yes, it would be nice to port more of these properties to setoids, but in our current module structure those belong in Data.List.Relation.Binary.Equality.Setoid, is that correct? are you suggesting to move them?

jamesmckinna commented 2 months ago

Re: moving properties to ...Setoid: not as part of this PR ;-)

Re: cong properties (I think I may be responsible for some of the ones that you and @MatthewDaggitt identify) I have always tended to regard fold* in this sense as a 3-ary function, so I expect cong properties to involve equality on each of its 3 arguments. That said, and given the bias towards Propositional equality, it makes sense to refactor them only to concentrate on the function arguments as being extensionally equal, given that refl looks after the other ones. So my mistake, both historically, and now in commenting... :-(

TL;DR: you and @MatthewDaggitt are right!

As for Setoidal refactoring (for which an 'n-ary' statement of cong would make more sense...?), that's enough work for a bunch of downstream PRs... and some discussion ahead of time about how best to tackle it (rather than following my own first thoughts on the matter ;-))

JacquesCarette commented 2 months ago

Amusingly in code that Conor and I are currently writing, we've gone in the opposite direction: we've generalized some cong-like functions to take that explicit proofs on the 'obvious input' so that we had somewhere more obvious to hand certain proofs, instead of being more-or-less forced to do it in 2 steps.

My current thinking on that: this feels like a false choice. Why not have both kinds? Now, the default ones could certainly have a different design than the ones provided in an 'extended' module.

jamesmckinna commented 2 months ago

Thanks again to @mildsunrise for the prompt to reconsider some of the fundamentals. But we should focus on merging your #2355 before either getting too caught in the weeds... or any of the other PRs which yours has prompted!

mildsunrise commented 2 months ago

@JacquesCarette that's right, we can have two proofs for every higher order function, one accepting only functional equality and the other accepting also equality on the inputs. i'd only ask for things to be consistent among all functions.

@jamesmckinna yes, that would be nice :) let me see if there's anything missing there on my part