Distributed algorithms for solving the consensus problem #
In the consensus problem, each process of a distributed algorithm is given a boolean value at the beginning. Then by exchanging messages asynchronously, they are supposed to agree on one of the initial boolean values. This file contains a very general definition of such a distributed algorithm.
Borrowing an idea from Leslie Lamport, we allow the LTS defined by such an algorithm to
"stutter" at any time, in the sense of taking a dummy step without changing the
global state of the distributed algorithm. This idea enables us to focus on infinite
executions alone without loss of generality, because an algorithm that has run out of
useful steps to take can always take the stuttering step. Pathological executions in which
the stuttering step is taken forever when there is useful work to be done are outlawed by
the fairness assumptions defined in Consensus.lean.
The types P, M, and S below are the types of processes (more precisely, process identifiers),
messages contents, and process states. Eventually P will be assumed to be finite in the form of
[Fintype P], but that assumption will be added only where necessary. No assumption whatsoever
will be made about M and S. In particular, they could be infinite.
The type of messages that processes send to each other.
- dest : P
The destination of a message.
The content of the message, where the
Booloption is used to carry to the initial boolean value to each process.
Instances For
Equations
Instances For
The global state of the distributed algorithm.
A multiset containing all messages that are in-flight (namely, they have been sent but not yet received). Note that being a multiset implies that the messages are not ordered.
- proc : P → ProcState S
A map giving the local states of all processes.
Instances For
The specification of a distributed algorithm for solving the consensus problem.
Note that each field below can depend on a process's identifier (recall that each Message
contains its destination's identifier), so the algorithm is not required to be uniform
across processes.
- init : P → S
A map specifying the initial state of each process.
A map specifying how a process changes its internal state upon receiving a message.
A map specifying what messages a process sends out upon receiving a message.
A map specifying the boolean decision a process makes upon receiving a message, where
nonemeans that no decision is made.
Instances For
The type of labels of the LTS defined by an Algorithm, where some m denotes
the reception of message m and none denotes a stuttering step.
Equations
- Cslib.FLP.Action P M = Option (Cslib.FLP.Message P M)
Instances For
Given inp : P → Bool, the initial state of the algorithm a contains a single message
carrying the boolean value inp p to each process p, where the initial internal state is
a.init p and no decision has been made. The assumption [Fintype P] is made because
a multiset may contain only finitely many elements.
Equations
Instances For
The specification of how the global state of the algorithm changes when a process p
receives a message m. (This function will be used only when such a message m exists.)
Note that once p has made a boolean decision in its out field, it is not allowed to
"change its mind" anymore.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The transition relation of the LTS defined by the algorithm a.
Note that the stuttering step is always allowed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
a.Reachable inp s means that s is a reachable state of a given the initial inp.
Instances For
s.ProcDecided p b means that process p is decided on the boolean value b
in the state s.
Instances For
a.SafeConsensus says that in any reachable state of a, (1) all boolean values decided on
in that state must agree with each other and (2) that boolean value (if it exists) must be
one of the boolean values given by inp at the beginning. a.SafeConsensus is the minimal
correctness requirement on a and is a safety property (hence its name).
Equations
- a.SafeConsensus = ∀ (inp : P → Bool) (s : Cslib.FLP.State P M S), a.Reachable inp s → s.Agreed ∧ ∀ (b : Bool), s.Decided b → ∃ (p : P), inp p = b
Instances For
The stuttering step does not change the global state.
The initial state is reachable.
If s is reachable from the initial state and s' is reachable from s,
then s' is reachable from the initial state.
If p is decided on the boolean value b in s and s' is reachable from s,
then p is still decided on b in s'.
If at least one process is decided on the boolean value b in s and s' is reachable
from s, then at least one process is still decided on b in s'.
If m1 and m2 are both inflight and they have different destinations,
then receiving them in either order produces the same end state.
A diamond property for the transition relation a.lts.Tr.
A message that is in-flight stays in-flight as long as it is not received (finite execution version).
A message that is in-flight stays in-flight as long as it is not received (infinite execution version).