YATA algorithm:修订间差异

来自WHY42
Riguz留言 | 贡献
Riguz留言 | 贡献
 
(未显示同一用户的16个中间版本)
第3行: 第3行:


== Rules ==
== Rules ==
<q>
We compose the following three rules in order to find a
strict total order <math><_{c}</math> on conflicting operations.
</q>


We get retrieve the total order function <math><_{c}</math> by enforcing all
strict total order(严格全序): A '''strict total order''' on a set <math>X</math> is a strict partial order on <math>X</math> in which any two distinct elements are comparable. That is, a strict total order is a binary relation <math><</math> on some Set <math>X</math>, which satisfies the following for all <math>a, b</math> and <math>c</math> in <math>X</math>
three rules:
<ref>https://en.wikipedia.org/wiki/Total_order</ref>:
 
# Not <math>a < a</math> (irreflexive).
<math>
# If <math>a < b</math> then not <math> b < a </math> (asymmetric).
o_{1} <_{c} \iff (o_{1} <_{rule1} o_{2}) \land (o_{1} <_{rule2} o_{2}) \land (o_{1} <_{rule3} o_{2})
# If <math>a < b</math> and <math>b < c</math> then <math>a < c</math> (transitive).
 
# If <math>a \neq b</math>, then <math>a < b</math> or <math>b < a</math> (connected).
\Leftrightarrow 
</math>


o1 <c o2 ⇐⇒ o1 <rule1 o2 ∧ o1 <rule2 o2 ∧ o1 <rule3 o2
⇔ o1 < origin2 ∨ origin2 ≤ origin1
∧ @o : o2 <c o < o1
∧ origin1 ≡ origin2 → creator1 < creator2
o1 ≤c o2 ⇔ o1 <c o2 ∨ o1 ≡ o2
=== Rule1: No line crossing ===
=== Rule1: No line crossing ===
<q>
<q>
第26行: 第23行:
</q>
</q>


<math>o1 <_{rule1} o2 o1 < origin2 origin2 origin1</math>
<math>o1 <_{rule1} o2 \Leftrightarrow o1 < origin2 \lor origin2 \leq origin1</math>


* Red line refers to the connection from the operation to it's origin
* Red line refers to the connection from the operation to it's origin
第35行: 第32行:
=== Rule2: transitivity on <c ===
=== Rule2: transitivity on <c ===


transitivity: if 𝑎≤𝑏 and 𝑏≤𝑐, then 𝑎≤𝑐, for every 𝑎, 𝑏, and 𝑐 in 𝐴.<ref>https://leanprover.github.io/logic_and_proof/relations.html#:~:text=To%20show%20transitivity%2C%20suppose%20a,to%20show%20a%E2%89%A0c.</ref>
transitivity: if 𝑎≤𝑏 and 𝑏≤𝑐, then 𝑎≤𝑐, for every 𝑎, 𝑏, and 𝑐 in 𝐴.<ref>https://leanprover.github.io/logic_and_proof/relations.html</ref>


<q>
<q>
第43行: 第40行:
</q>
</q>


<math>o_{1} <_{rule2} o_{2} \iff \exists o : o_{2} <_{c} o \to o_{1} \leq o \iff \nexists o : o_{2} <_{c} o < o_{1}</math>
<math>o_{1} <_{rule2} o_{2} \Leftrightarrow \exists o : o_{2} <_{c} o \to o_{1} \leq o \Leftrightarrow \nexists o : o_{2} <_{c} o < o_{1}</math>


=== Rule3: Smaller ID placed left ===
=== Rule3: Smaller ID placed left ===
第54行: 第51行:


<math>
<math>
o_{1} <_{rule3} o_{2} origin_{1} \equiv origin_{2} \to creator_{1} < creator_{2}
o_{1} <_{rule3} o_{2} \Leftrightarrow origin_{1} \equiv origin_{2} \to creator_{1} < creator_{2}
</math>
</math>


We get retrieve the total order function <math><_{c}</math> by enforcing all
three rules:
<math>
\begin{align}
o_{1} <_{c} o_{2} &\iff (o_{1} <_{rule1} o_{2}) \land (o_{1} <_{rule2} o_{2}) \land (o_{1} <_{rule3} o_{2}) \\
&\Leftrightarrow \quad o1 < origin2 \lor origin2 \leq origin1 \\
&\land \quad \nexists o : o_{2} <_{c} o < o_{1} \\
&\land \quad origin_{1} \equiv origin_{2} \to creator_{1} < creator_{2}
\end{align}
</math>
and:
<math>
o_{1} \leq_{c} o_{2} \iff o_{1} <_{c} o_{2} \quad \lor \quad o_{1} \equiv o_{2}
</math>
== Correctness ==
<q>
Therefore, we have to
show that for all conflicting insertions o1, o2, and o3 the
ordering function <math>c=<_{c}</math> is antisymmetric, transitive, and total.
</q>
antisymmetric(反对称关系)<ref>https://zh.wikipedia.org/wiki/%E5%8F%8D%E5%AF%B9%E7%A7%B0%E5%85%B3%E7%B3%BB</ref>:
<math>\displaystyle \forall a,b\in X,\ aRb\land bRa\;\Rightarrow \;a=b</math>
<math>
\begin{align}
o_{1} \leq_{c} o_{2} \land o_{2} \leq_{c} o_{1} \quad &\implies \quad o_{1} \equiv o_{2} \quad (antisymmetry) \\
o_{1} \leq_{c} o_{2} \land o_{2} \leq_{c} o_{3} \quad &\implies \quad o_{1} \leq_{c} o_{3} \quad (transitivity) \\
o_{1} \leq_{c} o_{2} \quad &\lor \quad o_{2} \leq_{c} o_{1} \quad (totality)
\end{align}
</math>


[[Category:Distributed]]
[[Category:Distributed]]
[[Category:CRDT]]
[[Category:CRDT]]

2024年8月15日 (四) 06:19的最新版本

Notes on YATA paper

This is notes on Near Real-Time Peer-to-Peer Shared Editing on Extensible Data Types[1].

Rules

We compose the following three rules in order to find a strict total order [math]\displaystyle{ \lt _{c} }[/math] on conflicting operations.

strict total order(严格全序): A strict total order on a set [math]\displaystyle{ X }[/math] is a strict partial order on [math]\displaystyle{ X }[/math] in which any two distinct elements are comparable. That is, a strict total order is a binary relation [math]\displaystyle{ \lt }[/math] on some Set [math]\displaystyle{ X }[/math], which satisfies the following for all [math]\displaystyle{ a, b }[/math] and [math]\displaystyle{ c }[/math] in [math]\displaystyle{ X }[/math] [2]:

  1. Not [math]\displaystyle{ a \lt a }[/math] (irreflexive).
  2. If [math]\displaystyle{ a \lt b }[/math] then not [math]\displaystyle{ b \lt a }[/math] (asymmetric).
  3. If [math]\displaystyle{ a \lt b }[/math] and [math]\displaystyle{ b \lt c }[/math] then [math]\displaystyle{ a \lt c }[/math] (transitive).
  4. If [math]\displaystyle{ a \neq b }[/math], then [math]\displaystyle{ a \lt b }[/math] or [math]\displaystyle{ b \lt a }[/math] (connected).

Rule1: No line crossing

Rule1: We forbid crossing of origin connections (red lines in the graphical representation) between conflicting insertions. This rule is easily explained using the graphical representation of insertions in the linked list. As we stated before, every insertion has an origin connection to an insertion to the left (to a predecessor). Only when two operations are concurrently inserted after the same insertion, they will have the same origin.

[math]\displaystyle{ o1 \lt _{rule1} o2 \Leftrightarrow o1 \lt origin2 \lor origin2 \leq origin1 }[/math]

  • Red line refers to the connection from the operation to it's origin
  • The assumation is that o1 and o2 conflicts, which means that there's overlap between intentions of them.

Rule2: transitivity on <c

transitivity: if 𝑎≤𝑏 and 𝑏≤𝑐, then 𝑎≤𝑐, for every 𝑎, 𝑏, and 𝑐 in 𝐴.[3]

Specifies transitivity on [math]\displaystyle{ \lt _{c} }[/math]. Let [math]\displaystyle{ o_{1} \lt _{c} o_{2} }[/math]. Then following rule ensures, that there is no [math]\displaystyle{ o }[/math] that is greater than [math]\displaystyle{ o_{2} }[/math], but smaller than [math]\displaystyle{ o_{1} }[/math], with respect to [math]\displaystyle{ \lt _{c} }[/math]

[math]\displaystyle{ o_{1} \lt _{rule2} o_{2} \Leftrightarrow \exists o : o_{2} \lt _{c} o \to o_{1} \leq o \Leftrightarrow \nexists o : o_{2} \lt _{c} o \lt o_{1} }[/math]

Rule3: Smaller ID placed left

When two conflicting insertions have the same origin, the insertion with the smaller creator id is to the left. We borrow this rule from the OT approach. But in OT this rule is applied when the position parameters are equal.

[math]\displaystyle{ o_{1} \lt _{rule3} o_{2} \Leftrightarrow origin_{1} \equiv origin_{2} \to creator_{1} \lt creator_{2} }[/math]


We get retrieve the total order function [math]\displaystyle{ \lt _{c} }[/math] by enforcing all three rules:

[math]\displaystyle{ \begin{align} o_{1} \lt _{c} o_{2} &\iff (o_{1} \lt _{rule1} o_{2}) \land (o_{1} \lt _{rule2} o_{2}) \land (o_{1} \lt _{rule3} o_{2}) \\ &\Leftrightarrow \quad o1 \lt origin2 \lor origin2 \leq origin1 \\ &\land \quad \nexists o : o_{2} \lt _{c} o \lt o_{1} \\ &\land \quad origin_{1} \equiv origin_{2} \to creator_{1} \lt creator_{2} \end{align} }[/math]

and:

[math]\displaystyle{ o_{1} \leq_{c} o_{2} \iff o_{1} \lt _{c} o_{2} \quad \lor \quad o_{1} \equiv o_{2} }[/math]

Correctness

Therefore, we have to show that for all conflicting insertions o1, o2, and o3 the ordering function [math]\displaystyle{ c=\lt _{c} }[/math] is antisymmetric, transitive, and total.

antisymmetric(反对称关系)[4]: [math]\displaystyle{ \displaystyle \forall a,b\in X,\ aRb\land bRa\;\Rightarrow \;a=b }[/math]

[math]\displaystyle{ \begin{align} o_{1} \leq_{c} o_{2} \land o_{2} \leq_{c} o_{1} \quad &\implies \quad o_{1} \equiv o_{2} \quad (antisymmetry) \\ o_{1} \leq_{c} o_{2} \land o_{2} \leq_{c} o_{3} \quad &\implies \quad o_{1} \leq_{c} o_{3} \quad (transitivity) \\ o_{1} \leq_{c} o_{2} \quad &\lor \quad o_{2} \leq_{c} o_{1} \quad (totality) \end{align} }[/math]