-
Notifications
You must be signed in to change notification settings - Fork 56
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
Partial Order over CRDT's #8
Comments
I really want to write a There is a typeclass / library for this in haskell: Any idea what the possible blockers could be for translating that library to rust? I haven't looked at the code yet, just curious if you have any input. |
Well, a few things, first, a Second, a trait by itself is not that interesting, you need someway of checking the laws (assoc, commute, idempotent, LUB, etc.) and writing down the trait(or typeclass) definition gets you nowhere closer to verifying an instance follows these laws. Most of the work is in testing that a CRDT's follow the CRDT laws. (Haskell doesn't help you here either) The point of this issue was to give us one more tools for writing some more sophisticated property tests for the CRDT laws, a partial order over CRDT's would allow us to write properties like:
|
Thank you, I knew I had to be missing something. Now this makes sense, so you want to show that CRDT implies partial order? It's obviously trivial to write the
I don't write much rust, so I may still be missing something? Edit: that match statement would obviously be inside the definition of |
match merge(A, B) {
A => Some(cmp::Greater)
B => Some(cmp::Lesser)
_ => None
} do you mean?: let ab = merge(a, b);
if ab == a {
Some(cmp::Greater)
} else if ab == b {
Some(cmp::Lesser)
} else {
None
} That would only work if one (a or b) is based on the other, but what if they diverged from one another (got different data applied to them). edit: hmm, yes ur right... at least for:
but not in a general way? |
Generally; a merge of two members in a CRDT is equivalent to a join in a semilattice, this is because a CRDT requires a unique result of the merge operation (or you wouldn't have eventual consistency) and this is exactly the property that refines a partial order into a semilattice. In mathematics when you want to show that semilattice is partially ordered you define the ordering as I did above, if https://ncatlab.org/nlab/show/semilattice However, in a computer you need to be more paranoid I guess, so the idea is to use the inter-relation of mathematical concepts to verify that the implementation is correct ( |
There are many partial orders that can be defined over a structure, the one we are looking for is the partial order that induces the merge function we are using for a particular CRDT. In math you would say that the merge of two CRDT states is defined as the least upper bound of A and B under a given partial order.
expanding just a bit, we can say:
C is an upper bound:
C is the least upper bound:
So the interesting thing to understand is really just that the merge function is uniquely defined by the partial order, ( The goal is to somehow get closer to this underlying partial order (and there is a very particular partial order we are looking for) to make sure that our merge function really does implement |
Partial orders are central to all CRDT's, we should have the PartialOrder trait implemented for all CRDT's and once done, we should be able to write some more interesting tests.
ie. the
merge(a, b)
should be the least-upper-bound of {a, b}.Leaving this here as a half finished thought to explore later.
The text was updated successfully, but these errors were encountered: