22 Operational Transform Convergence
(May 2005)
Syntactic conventions
O, O1, O2 etc are primitive (i.e. indivisible) operations.
L, L1, L2 etc are lists of operations.
L = [O1 , O2 , O3 , ... , On] is the list of operations O1 then O2 ... then On.
L = [L1, L2, ..., Ln] is the concatenation of lists L1, ..., Ln
L = [H | T] is the list with head operation H and tail T
Xi is either an Oi or Li.
L = [X1 X2 ... Xn] is the concatenation of lists or primitive operations X1, ..., Xn
Definitions
Definition: We write X1 ~ X2 if X1 and X2 are executed on the same initial document state and produce the same final document state. This is called convergence.
Some people call this eventual consistency, but the term "consistent" means different things to different people (e.g. convergent, satisfies integrity constraints, linearisable or serialisable), and therefore probably should be avoided.
Clearly: ∀i, Xi ~ Yi ⇒ [X1 ... Xn] ~ [Y1 ... Yn]
Definition: IT(O2, O1) is the inclusion transform of O2 against O1. O1,O2 are assumed to be concurrent operations on the same initial document state. IT(O2, O1) is a transformed version of O2 that can be executed after O1.
Definition: Let O1,2 = [O1 , IT(O2, O1) ]
Definition: Convergence condition C1 : ∀ O1,O2, O1,2 ~ O2,1
The following diagram depicts the two operations O1, O2 that apply to initial document state S. Condition C1 states that the path along the left and top edges yields the same final document state F as the path along the bottom and right edges.
Definition: IT(L1, L2) is defined recursively as follows
- IT([], []) = []
- IT([L1, L2], L3) = [ IT(L1 ,L3) , IT(L2, IT(L3, L1)) ]
- IT(L1, [L2 , L3]) = IT(IT(L1, L2), L3)
[Note that this definition appears to be ambiguous in the way in which a list is decomposed into smaller sub-lists. However, it turns out that the final result is independent of the order in which the lists are decomposed. A more formal approach could begin with an unambiguous definition then prove decomposition rules 2,3 above]
We can depict IT(L1,L2) pictorially as follows. L2 has three primitive operations and L1 has four primitive operations. The initial document state S is associated with the bottom left corner of the 3 x 4 grid of "cells".
Starting from the bottom left corner we can apply IT on the primitive operations. This can proceed to adjacent cells until we transform the operations to the top and right boundaries.
Note that IT is quadratic in the size of the lists.
Definition : L1,2 = L1 IT(L2, L1)
Lemma 1: C1 ⇒ ∀ L1,L2, L1,2 ~ L2,1
Proof :
A formal proof can be achieved using induction on the length of L1,L2. Informally, we can prove the result more easily as follows
We begin with L1,2, which is associated with the path along the bottom and right edges. Starting from the bottom right corner we can shift the path using the known convergence property on the cell. This is repeated for adjacent cells until the path is transformed to the left and top edges, corresponding to L2,1.
Definition: O1,2,3 = O(1,2), 3 = [O1,2 IT(O3, O1,2) ]
This represents one of the six possible paths from "Start" to "Finish" on the following cube.
Definition: Condition C2: ∀ O1,O2,O3, O1,2,3 ~ O2,1,3
Note that it is not the case that C1⇒C2. On the contrary, C2 must be independently assumed in order to achieve convergence when there are more than two sites.
There are 6 possible paths on the cube...
Convergence C1 implies that the 6 paths can be put into 3 groups, illustrated with the dotted ovals on the left side.
Adding condition C2 implies that all 6 paths are equivalent.
Lemma : C1 ⇒ L1,2,3 ~ L1,3,2
Note that it is not the case that C1 ⇒ L1,2,3 ~ L2,1,3
Lemma 2: C1, C2 ⇒ ∀ L1,L2,L3, L1,2,3 ~ L2,1,3
Proof: (Informally)
The following cube depicts two operations in L1, two in L2 and three operations in L3.
L1,2,3 corresponds to the transformation of L3 along the front face then the right face of the cube. On each of these faces we can depict a regular grid of cells, associated with the simple, two dimensional case. Condition C1 ensures that convergence is achieved on each face of the cube.
The individual operations allow us to partition the cube into small "cells". In particular the "cell" at the nearest, bottom right corner of the cube (ie labeled B in the diagram) is of interest. Consider that we adjust the path on the right face as follows
We can now apply condition C2 to the cell at B to yield an equivalent path as follows
We now adjust the path on the back face of the cell at B
This allows us to proceed to the cell to the left of B. In this manner we can proceed through the cells until we get the following path
which corresponds to L2,1,3
This shows informally that L1,2,3 ~ L2,1,3
RTP. C1, C2 ⇒ L(1,2), 3 ~ L1, (2,3) (associativity)
Proof :
L(1,2), 3 ~ L(2,1),3 (Lemma 2)
= L2,1 IT(L3, L2,1)
~ L1,2 IT(L3, L2,1) (Lemma 1)
= L1,2 IT(L3, [L2 IT(L1, L2)] )
= L1,2 IT(IT(L3,L2), IT(L1, L2))
= L1 IT(L2,L1) IT(IT(L3,L2), IT(L1, L2))
= L1 IT([L2 IT(L3,L2) ], L1)
= L1 IT(L2,3, L1)
= L1, (2,3)
Four sites
There are 4! = 24 paths through the "hypercube". Interestingly it turns out that C1,C2 are sufficient for convergence.
The paths can be listed in four groups of 6 as follows
| G1 | G2 | G3 | G4 |
|---|---|---|---|
| 1 2 3 4 | 2 1 3 4 | 3 1 2 4 | 4 1 2 3 |
| 1 2 4 3 | 2 1 4 3 | 3 1 4 2 | 4 1 3 2 |
| 1 3 2 4 | 2 3 1 4 | 3 2 1 4 | 4 2 1 3 |
| 1 3 4 2 | 2 3 4 1 | 3 2 4 1 | 4 2 3 1 |
| 1 4 2 3 | 2 4 1 3 | 3 4 1 2 | 4 3 1 2 |
| 1 4 3 2 | 2 4 3 1 | 3 4 2 1 | 4 3 2 1 |
Claim
- Each group contains equivalent paths because they all begin with the same operation which can therefore be disregarded, reducing the problem to the 3-site case which has already been proven
- As an example G1 ~ G2 because L1,2,3,4 ~ L2,1,3,4. This follows by letting M = L3,4. By associativity L1,2,3,4 ~ L1,2,M ~ L2,1,M ~ L2,1,3,4.
This pattern extends into n sites.