-
Notifications
You must be signed in to change notification settings - Fork 239
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
Refactor to support multiple definitions of Data.List.Relation.Binary.Permutation
#2311
Comments
Can't we have them all (and prove them equivalent if they are) rather than replacing? |
Indeed... I suppose for me there is always a question of what gets 'blessed' as a definition, especially given that, on the one hand, the existing definitions have been the topic of (relatively speaking, so much) shade from other authors (including me ;) it feels like a definition tuned to correlate with But if it does 'simply' get added as a new definition, then where should it live? |
I would be in favour of having separate submodules. |
OK, I think that makes sense. One possibility, looking at the current organisation, is that each of |
From
Well, I've been wondering if this is the better solution? cf. the discussion of #1113 , where now, we could avoid |
I'm also in favour of separate sub-modules. And I, of course, have my own implementation, which is again different. See I've been meaning to submit both codes on partitions on |
@JacquesCarette writes:
Of course! (but without the hint/link, how would we know? etc. ;-)) Interesting that you don't need the 'merge' rule as such, or at least not in its 'symmetric' form, but I guess that is all wrapped up in the partition definitions, which I haven't looked at. Yours and Conor's version seems closest to the one I dub 'algorithmic' above... And you develop all of the free commutative monoid machinery, too, which should please @Taneb and hopefully resolve #1281 to his satisfaction... Chapeau! |
I develop it all twice, once the CS way, and once the Math way. The Math way, when spelled out in full, is quite silly - and thus its name in the repo. |
So as BREAKING change: |
NB. See also #1354 and #1761 for comparison and prior thinking on the topic (including my own, which I had forgotten about 🤦 ) UPDATED: and a concrete proposal for how to take #1354 forward, as well as making space to support multiple (re-)implementations of the basic relation. Suggest maybe renaming this issue to
both to avoid overlap with the originating #1354, and in the constructive spirit of the above responses arguing persuasively for such pluralism...? |
Data.List.Relation.Binary.Permutation
Data.List.Relation.Binary.Permutation
Recent work by
has looked at lists-modulo-permutation, with a view to establishing that (
Setoid
) structure as (a representation of) (the carrier of) the free commutative monoid, with the former alluding to difficulties in establishing such results for thestdlib
definition of permutation, and the latter, IIUC, by observing that fresh/sorted lists, by providing a constructive representative of the equivalence-classes-modulo makes such difficulties more tractable, at the cost of a(nother) new representation (but one already in the library, and interesting in its own right).Each (incl.
stdlib
;-) by taking a prefix-closed, transitive relation which can swap only the top two elements of a list; it's very fiddly, and requires transitivity to be built in), IMHO, fails to tackle the elephant in the room, namely that there are two 'natural' definitions of the relation, for which it is interesting (and useful/computationally relevant!) to prove the equivalence between them (something already done, but lost in the archaeology of my PhD thesis back in 1992), namely as:[]
,_∷_
(and hence for_++_
) which 'makes_++_
commutative', ie relatesas ++ bs
andbs ++ as
[]
is related to itself, and that ifcs
is related toas ++ bs
, thenc ∷ cs
is related toas ++ c ∷ bs
(whence the correctness of insertion sort)I've recently come across the following definition, due, I think to Ralf Hinze, which may easily be shown equivalent to each of these definitions (NB in the
Propositional
case, I'm still looking at theSetoid
generalisation), as the least relation such that:[]
is related to itselfas
is related tobs
, thena ∷ as
is related toa ∷ bs
(so that we have left-prefix-closure for
_++_
, if not full congruence, straightaway)as
is related tob ∷ cs
, andbs
is related toa ∷ cs
, thena ∷ as
is related tob ∷ bs
(whence the correctness of mergesort, as well, again IIUC)This may easily be shown to be reflexive, symmetric, makes
_++_
commutative, and by a slightly fiddly length induction, may be shown to be transitive. Cancellation properties, as well as full congruence, follow easily from this.PROPOSAL: subject to the
Setoid
generalisation working out, that we replace the library definition with Ralf's, together with theProperties
showing it equivalent to the declarative and algorithmic ones above.ISSUES:
steps
counting the number of rule applications of the existing constructors, but AFAICT, it is used nowhere else in the library, but would need to be retained for backwards-compatibility (I don't see the point myself, but hey)The text was updated successfully, but these errors were encountered: