PriorityQueue interface - #1552
Conversation
|
Since I used permutation relation of lists defined over propositional equality, one should think equivalence between |
|
Thanks for putting together a draft @damhiya! It's a fascinating design problem. From an implementor's perspective, I can definitely see the attraction of having a thin interface with the other operations derivable. However, from a user's perspective I think a fat interface might be more desirable. For example with your definitions, any notion of equality (i.e permutations of With a fat interface, yes you're going to get some blowup in the number of proofs required for the implementation but at least that burden is during the implementation (which only happens once) rather than on the user (of which there will be many). If we do go for a fat interface then I'd probably have at least the following additional fields:
What are your thoughts? |
|
Hmm from a performance perspective, maybe we should have a separate |
|
In my opinion, ideal solution is providing minimal, but enough operations so that one can derive all general properties of priority queue without having specific instance of priority queue implementation. What I mean by general properties are properties which should be true for any implementation of priority queue. Then, we should prove such properties parametrically, not to prove such things for multiple times. So I'm looking forward that users may use such proofs constructed on top of minimal interface. However, as you said, it might not very convenient due to complex permutation related things. I think this decision should be made after examining some application of priority queues. Current implementation of |
I thought one may implement |
|
Apologies for taking so long to reply, I've been mulling this over in my head.
So what are the advantages of this solution for the users of the standard library? I understand that from the implementor's perspective it's desirable to have a minimal interface so as to only have to prove the properties once. I ask, because the point of the standard library is to make the life of the users as easy possible, not the life of the implementors.
Hmm having tried it out, the type messages are still pretty bad even when we're considering an abstract definition. I'm getting things like: Having The situation is going to get much worse once you're using a concrete backing implementation.
I'm not suggesting removing the current definition of |
|
Closing this as I don't think we're going to make progress on it. |
Hi I wrote an interface of priority queue as discussed in #1542.
What I focused was describing soundness of priority queue with small number of fields as possible,
so that not to blowing up record size with declarations of consistency between fields.
For example, I defined
toListusingpopMin, and used permutation relation over result oftoListtoguarantee correctness of queue implementation.
If someone has better design idea, please notice me.
I'll also implement instance for
PriorityQueuesoon, in order to convince interface definition.