Std.CRDT.Proof

View source →

Kernel-checked join-semilattice proofs for Cure's CRDT merge semantics.

A state-based CRDT converges under arbitrary message reordering, duplication, and network partitions if and only if its merge operation forms a join-semilattice:

  1. Idempotent: merge(a, a) == a
  2. Commutative: merge(a, b) == merge(b, a)
  3. Associative: merge(merge(a, b), c) == merge(a, merge(b, c))

Every law below is an ordinary Std.Equivalent proof checked by the dependent kernel and certified total with zero TCB changes.

Types

  • type GCounter2 = GCounter2

    Two-replica grow-only counter state, merged component-wise via nat_max.

Functions

  • # fn bool_or(left: Bool, right: Bool) -> Bool

    Boolean join (bool_or) underlying grow-only flags and set membership.

  • # fn bool_or_assoc(a: Bool, b: Bool, c: Bool) -> Equivalent(Bool, bool_or(bool_or(a, b), c), bool_or(a, bool_or(b, c)))

    Associativity: bool_or(bool_or(a, b), c) == bool_or(a, bool_or(b, c)).

  • # fn bool_or_comm(a: Bool, b: Bool) -> Equivalent(Bool, bool_or(a, b), bool_or(b, a))

    Commutativity: bool_or(a, b) == bool_or(b, a).

  • # fn bool_or_idempotent(b: Bool) -> Equivalent(Bool, bool_or(b, b), b)

    Idempotence: bool_or(b, b) == b.

  • # fn gcounter2_cong(a1: Nat, a2: Nat, b1: Nat, b2: Nat, p: Equivalent(Nat, a1, a2), q: Equivalent(Nat, b1, b2)) -> Equivalent(GCounter2, GCounter2(a1, b1), GCounter2(a2, b2))

    Binary congruence for GCounter2.

  • # fn gcounter2_merge(left: GCounter2, right: GCounter2) -> GCounter2

    Component-wise join for two-replica grow-only counters.

  • # fn gcounter2_merge_assoc(a: GCounter2, b: GCounter2, c: GCounter2) -> Equivalent(GCounter2, gcounter2_merge(gcounter2_merge(a, b), c), gcounter2_merge(a, gcounter2_merge(b, c)))

    GCounter2 merge is associative: merge(merge(a, b), c) == merge(a, merge(b, c)).

  • # fn gcounter2_merge_comm(a: GCounter2, b: GCounter2) -> Equivalent(GCounter2, gcounter2_merge(a, b), gcounter2_merge(b, a))

    GCounter2 merge is commutative: merge(a, b) == merge(b, a).

  • # fn gcounter2_merge_idempotent(c: GCounter2) -> Equivalent(GCounter2, gcounter2_merge(c, c), c)

    GCounter2 merge is idempotent: merge(c, c) == c.

  • # fn nat_max(left: Nat, right: Nat) -> Nat

    Structural maximum on Nat, the per-replica join behind GCounter.

  • # fn nat_max_assoc(a: Nat, b: Nat, c: Nat) -> Equivalent(Nat, nat_max(nat_max(a, b), c), nat_max(a, nat_max(b, c)))

    Associativity: nat_max(nat_max(a, b), c) == nat_max(a, nat_max(b, c)).

  • # fn nat_max_comm(a: Nat, b: Nat) -> Equivalent(Nat, nat_max(a, b), nat_max(b, a))

    Commutativity: nat_max(a, b) == nat_max(b, a).

  • # fn nat_max_idempotent(a: Nat) -> Equivalent(Nat, nat_max(a, a), a)

    Idempotence: nat_max(a, a) == a.

  • # fn succ_cong(a: Nat, b: Nat, p: Equivalent(Nat, a, b)) -> Equivalent(Nat, S(a), S(b))

    Congruence for S over Equivalent(Nat, ...).