Documentation

CslibFrontier.Computability.Distributed.OrientedCycle.Basic

The LOCAL model on oriented cycles #

Deterministic synchronous distributed algorithms in the LOCAL model of Linial on consistently oriented cycles. The nodes of the oriented n-cycle are ZMod n; node v has predecessor v - 1 and successor v + 1. For n = 0 the graph ZMod 0 = ℤ is the infinite oriented path. Each node receives an input, for instance a unique identifier or an initial colour.

In every round each node exchanges messages with its two neighbours and updates its state. Messages are unbounded, so an Algorithm simply sends its whole state. A MessageAlgorithm with explicit messages reduces to this form (MessageAlgorithm.toAlgorithm_state). The round number is common knowledge. Algorithms are non-uniform: one may be chosen for each cycle length n, so every node knows n.

The equivalent view formulation: after r rounds the state of a node is a function of the inputs at distance at most r (Algorithm.state_eq_viewState), so an r-round algorithm computes a LocalRule of radius r (Algorithm.run_eq_apply). Conversely every rule of radius r is computed in r rounds by flooding (LocalRule.toAlgorithm_run). Lower bounds can thus be proved for rules and transferred to algorithms. LocalRule.andThen runs a rule and then an algorithm on its outputs, and Algorithm.seq runs one algorithm for a fixed number of rounds and then another on its outputs.

Identifiers are natural numbers. Algorithm.ColorsCycle uses identifiers {0, …, n - 1}; the standard convention {1, …, n} is the same up to a shift by one, made precise by Algorithm.colorsCycle_comapInput_succ_iff. For n = 0 no identifier assignment qualifies, so ColorsCycle 0 t c holds vacuously; results on the infinite oriented path are stated directly for Algorithm.run (for instance threeColoring_run).

Main definitions #

Main results #

References #

structure Cslib.Distributed.OrientedCycle.Algorithm (I : Type u_1) (State : Type u_2) (O : Type u_3) :
Type (max (max u_1 u_2) u_3)

A deterministic synchronous algorithm in the LOCAL model on consistently oriented cycles.

Every node starts in state init x from its input x (an identifier or an initial colour). In round r + 1 every node exchanges its whole state with its two neighbours and moves to step r p s q, where s is its own state, p that of its predecessor and q that of its successor. After the last round a node outputs output s. Messages and local computation are unbounded, the round number is common knowledge, and every node knows the cycle length, since an algorithm may be chosen separately for each n.

  • init : I → State

    The state of a node with input x before the first round.

  • step : ℕ → State → State → State → State

    The new state in round r + 1 from the predecessor's, own and successor's states.

  • output : State → O

    The output of a node in a given state.

def Cslib.Distributed.OrientedCycle.Algorithm.state {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} (x : ZMod n → I) :
ℕ → ZMod n → S

The state of node v of the oriented n-cycle ZMod n after r rounds on input x. For n = 0 the graph ZMod 0 = ℤ is the infinite oriented path.

def Cslib.Distributed.OrientedCycle.Algorithm.run {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
O

The output of node v after r rounds.

@[simp]
theorem Cslib.Distributed.OrientedCycle.Algorithm.state_zero {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} (x : ZMod n → I) (v : ZMod n) :
A.state x 0 v = A.init (x v)
theorem Cslib.Distributed.OrientedCycle.Algorithm.state_succ {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
A.state x (r + 1) v = A.step r (A.state x r (v - 1)) (A.state x r v) (A.state x r (v + 1))
def Cslib.Distributed.OrientedCycle.Algorithm.mapOutput {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {O' : Type u_4} (g : O → O') :
Algorithm I S O'

Post-processing the output of an algorithm by g.

@[simp]
theorem Cslib.Distributed.OrientedCycle.Algorithm.mapOutput_state {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} {O' : Type u_4} (g : O → O') (x : ZMod n → I) (r : ℕ) :
(A.mapOutput g).state x r = A.state x r
@[simp]
theorem Cslib.Distributed.OrientedCycle.Algorithm.mapOutput_run {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} {O' : Type u_4} (g : O → O') (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
(A.mapOutput g).run x r v = g (A.run x r v)
def Cslib.Distributed.OrientedCycle.Algorithm.comapInput {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {I' : Type u_4} (f : I' → I) :
Algorithm I' S O

Pre-processing the input of an algorithm by f: every node starts from f of its input.

@[simp]
theorem Cslib.Distributed.OrientedCycle.Algorithm.comapInput_state {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} {I' : Type u_4} (f : I' → I) (x : ZMod n → I') (r : ℕ) :
(A.comapInput f).state x r = A.state (f ∘ x) r
@[simp]
theorem Cslib.Distributed.OrientedCycle.Algorithm.comapInput_run {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} {I' : Type u_4} (f : I' → I) (x : ZMod n → I') (r : ℕ) (v : ZMod n) :
(A.comapInput f).run x r v = A.run (f ∘ x) r v

The algorithm that outputs a at every node, whatever its input.

@[simp]
theorem Cslib.Distributed.OrientedCycle.Algorithm.const_run {I : Type u_1} {O : Type u_3} {n : ℕ} (a : O) (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
(const a).run x r v = a
structure Cslib.Distributed.OrientedCycle.MessageAlgorithm (I : Type u_1) (State : Type u_2) (M : Type u_3) (O : Type u_4) :
Type (max (max (max u_1 u_2) u_3) u_4)

A message-passing algorithm on oriented cycles: in round r + 1 every node sends toPred r s to its predecessor and toSucc r s to its successor, and then updates its state from the message m₁ of its predecessor and the message m₂ of its successor.

  • init : I → State

    The initial state.

  • toPred : ℕ → State → M

    The message sent to the predecessor.

  • toSucc : ℕ → State → M

    The message sent to the successor.

  • receive : ℕ → State → M → M → State

    The new state from the old state, the predecessor's message and the successor's message.

  • output : State → O

    The output.

def Cslib.Distributed.OrientedCycle.MessageAlgorithm.state {I : Type u_1} {S : Type u_2} {M : Type u_3} {O : Type u_4} (A : MessageAlgorithm I S M O) {n : ℕ} (x : ZMod n → I) :
ℕ → ZMod n → S

The state of node v after r rounds of message passing.

def Cslib.Distributed.OrientedCycle.MessageAlgorithm.toAlgorithm {I : Type u_1} {S : Type u_2} {M : Type u_3} {O : Type u_4} (A : MessageAlgorithm I S M O) :
Algorithm I S O

A message-passing algorithm as a state-exchange Algorithm: a node can compute the messages its neighbours would send from their states.

theorem Cslib.Distributed.OrientedCycle.MessageAlgorithm.toAlgorithm_state {I : Type u_1} {S : Type u_2} {M : Type u_3} {O : Type u_4} (A : MessageAlgorithm I S M O) {n : ℕ} (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
A.toAlgorithm.state x r v = A.state x r v

The state-exchange simulation of a message-passing algorithm goes through the same states.

def Cslib.Distributed.OrientedCycle.Algorithm.seq {I : Type u_1} {S : Type u_2} {O : Type u_3} {S' : Type u_4} {O' : Type u_5} (A : Algorithm I S O) (t : ℕ) (B : Algorithm O S' O') :
Algorithm I (S × S') O'

Sequential composition: run A for t rounds, then run B on the outputs of A. During the first t rounds every node keeps B in its initial state for the current output of A.

theorem Cslib.Distributed.OrientedCycle.Algorithm.seq_run {I : Type u_1} {S : Type u_2} {O : Type u_3} {S' : Type u_4} {O' : Type u_5} (A : Algorithm I S O) (t : ℕ) (B : Algorithm O S' O') {n : ℕ} (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
(A.seq t B).run x (t + r) v = B.run (A.run x t) r v

Sequential composition. Running A.seq t B for t + r rounds is running B for r rounds on the outputs of A after t rounds.

def Cslib.Distributed.OrientedCycle.window {I : Type u_1} {n : ℕ} (x : ZMod n → I) (v : ZMod n) :
ℤ → I

The inputs seen from node v at offsets j : ℤ: the window j ↦ x (v + j). On the cycle this is the input along the universal cover, the oriented path ℤ, viewed from v.

structure Cslib.Distributed.OrientedCycle.LocalRule (I : Type u_1) (O : Type u_2) (r : ℕ) :
Type (max u_1 u_2)

A rule of radius r: a function of input windows ℤ → I that only depends on the offsets -r, …, r. Applied to every node of a cycle (LocalRule.apply) it computes the output of an r-round LOCAL algorithm, and conversely (Algorithm.toLocalRule, LocalRule.toAlgorithm).

  • toFun : (ℤ → I) → O

    The output from a window of inputs.

  • dependsOn : DependsOn self.toFun (Set.Icc (-↑r) ↑r)

    Only the offsets -r, …, r matter.

def Cslib.Distributed.OrientedCycle.LocalRule.apply {I : Type u_1} {O : Type u_2} {r : ℕ} (F : LocalRule I O r) {n : ℕ} (x : ZMod n → I) (v : ZMod n) :
O

The output of a local rule at node v of the oriented n-cycle.

theorem Cslib.Distributed.OrientedCycle.LocalRule.toFun_congr {I : Type u_1} {O : Type u_2} {r : ℕ} (F : LocalRule I O r) {w w' : ℤ → I} (h : ∀ (j : ℤ), -↑r ≤ j → j ≤ ↑r → w j = w' j) :
F.toFun w = F.toFun w'
def Cslib.Distributed.OrientedCycle.Algorithm.viewState {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) :
ℕ → (ℤ → I) → S

The state after r rounds at node 0 of the infinite oriented path, as a function of the input window.

theorem Cslib.Distributed.OrientedCycle.Algorithm.state_eq_viewState {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
A.state x r v = A.viewState r (window x v)

Locality. The state of a node after r rounds is determined by its radius-r window.

theorem Cslib.Distributed.OrientedCycle.Algorithm.viewState_dependsOn {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) (r : ℕ) :
DependsOn (A.viewState r) (Set.Icc (-↑r) ↑r)

After r rounds, the state only depends on the inputs at offsets -r, …, r.

def Cslib.Distributed.OrientedCycle.Algorithm.toLocalRule {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) (r : ℕ) :
LocalRule I O r

The radius-r rule computed by r rounds of an algorithm.

theorem Cslib.Distributed.OrientedCycle.Algorithm.run_eq_apply {I : Type u_1} {S : Type u_2} {O : Type u_3} (A : Algorithm I S O) {n : ℕ} (x : ZMod n → I) (r : ℕ) (v : ZMod n) :
A.run x r v = (A.toLocalRule r).apply x v

The output after r rounds is the radius-r rule A.toLocalRule r applied at every node.

def Cslib.Distributed.OrientedCycle.LocalRule.toAlgorithm {I : Type u_1} {O : Type u_2} {r : ℕ} (F : LocalRule I O r) :
Algorithm I (ℤ → I) O

The full-information algorithm for a local rule: every node floods the window it has learnt (its state is a window, correct on offsets -s, …, s after s rounds) and finally applies the rule.

theorem Cslib.Distributed.OrientedCycle.LocalRule.toAlgorithm_run {I : Type u_1} {O : Type u_2} {r : ℕ} (F : LocalRule I O r) {n : ℕ} (x : ZMod n → I) (v : ZMod n) :
F.toAlgorithm.run x r v = F.apply x v

Full-information simulation. Every rule of radius r is computed by an r-round algorithm.

def Cslib.Distributed.OrientedCycle.LocalRule.andThen {I : Type u_1} {O : Type u_2} {r : ℕ} {S' : Type u_3} {O' : Type u_4} (F : LocalRule I O r) (B : Algorithm O S' O') :
Algorithm I ((ℤ → I) × S') O'

Running a rule F of radius r and then an algorithm B on its outputs: the flooding algorithm F.toAlgorithm for r rounds, followed by B (Algorithm.seq).

theorem Cslib.Distributed.OrientedCycle.LocalRule.andThen_run {I : Type u_1} {O : Type u_2} {r : ℕ} {S' : Type u_3} {O' : Type u_4} (F : LocalRule I O r) (B : Algorithm O S' O') {n : ℕ} (x : ZMod n → I) (t : ℕ) (v : ZMod n) :
(F.andThen B).run x (r + t) v = B.run (F.apply x) t v

Composition. Running F.andThen B for r + t rounds is running B for t rounds on the outputs of F.

def Cslib.Distributed.OrientedCycle.LocalRule.comp {I : Type u_1} {O : Type u_2} {r : ℕ} {P : Type u_3} {r' : ℕ} (G : LocalRule O P r') (F : LocalRule I O r) :
LocalRule I P (r + r')

The composite of a rule F of radius r and a rule G of radius r' on the outputs of F: a rule of radius r + r'.

theorem Cslib.Distributed.OrientedCycle.LocalRule.apply_comp {I : Type u_1} {O : Type u_2} {r : ℕ} {P : Type u_3} {r' : ℕ} (G : LocalRule O P r') (F : LocalRule I O r) {n : ℕ} (x : ZMod n → I) :
(G.comp F).apply x = G.apply (F.apply x)

Composition of rules. Applying G.comp F is applying G to the outputs of F.

A colouring c of the oriented n-cycle is proper if every node and its successor receive different colours.

Instances For

    Distinct identifiers form a proper colouring, except on the one-node cycle, whose only node is its own successor.

    After t rounds, A properly colours every oriented n-cycle whose nodes carry distinct identifiers from {0, …, n - 1}, with colours 0, …, c - 1.

    For n = 0 this is vacuous, since no x : ℤ → ℕ has all values below 0; colourings of the infinite oriented path are stated directly for Algorithm.run, as in threeColoring_run and fastThreeColoring_run.

    theorem Cslib.Distributed.OrientedCycle.Algorithm.colorsCycle_comapInput_succ_iff {S : Type u_1} (A : Algorithm ℕ S ℕ) (n t c : ℕ) :
    (A.comapInput fun (x : ℕ) => x + 1).ColorsCycle n t c ↔ ∀ (x : ZMod n → ℕ), Function.Injective x → (∀ (v : ZMod n), 1 ≤ x v ∧ x v ≤ n) → IsProperColoring (A.run x t) ∧ ∀ (v : ZMod n), A.run x t v < c

    Identifiers from {1, …, n}. An algorithm A properly c-colours every oriented n-cycle with distinct identifiers from {1, …, n} in t rounds iff A.comapInput (· + 1), which first adds one to every identifier, satisfies ColorsCycle n t c. Upper and lower bounds for the {0, …, n - 1} convention therefore transfer to the {1, …, n} convention.