PADEC - Coq Library
Library Padec.MessagePassing.AlgorithmMPold
A Framework for Certified Self-Stabilization
PADEC Coq Library
- Feb 2016 - updated April 2018
- Jan 2019 (Fork by David Ilcinkas for message-passing systems)
From Padec Require Import SetoidUtil.
From Padec Require Import OptionUtil.
From Padec Require Import ListUtils.
Open Scope signature_scope.
Set Implicit Arguments.
From Padec Require Import OptionUtil.
From Padec Require Import ListUtils.
Open Scope signature_scope.
Set Implicit Arguments.
Distributed Algorithm:
- Channels (In and Out)
- Network
- Algorithm
exists an Algorithm (the one to be proven) (uses *Channels)
forall Network using *Channels,
the Algorithm meets its specification
defined on Network and *Channels
(provided some assumption on Network and *Channels).
Class Channels:
Channels are used to model the access of a node to its neighbors. An incoming channel (Type InChannel) cin connects a node n to its neighbor n': n <-cin---- n' An outgoing channel (Type OutChannel) cout connects a node n to its neighbor n': n -cout----> n'
Class InChannels :=
mkInChannels {
InChannel: Type;
InChannel_setoid :> Setoid InChannel;
InChannel_dec: Decider (equiv (A:=InChannel))
}.
Class OutChannels :=
mkOutChannels {
OutChannel: Type;
OutChannel_setoid :> Setoid OutChannel;
OutChannel_dec: Decider (equiv (A:=OutChannel))
}.
mkInChannels {
InChannel: Type;
InChannel_setoid :> Setoid InChannel;
InChannel_dec: Decider (equiv (A:=InChannel))
}.
Class OutChannels :=
mkOutChannels {
OutChannel: Type;
OutChannel_setoid :> Setoid OutChannel;
OutChannel_dec: Decider (equiv (A:=OutChannel))
}.
Class Network:
A network is described by its nodes (Type Node) and links (arcs) between nodes. A directed connection is defined through two channels (one InChannel and one OutChannel) linking two nodes.
Class DirNetwork {InChans: InChannels} {OutChans: OutChannels} :=
mkNet {
Node: Type;
Node_setoid :> Setoid Node;
Node_dec: Decider (equiv (A := Node));
mkNet {
Node: Type;
Node_setoid :> Setoid Node;
Node_dec: Decider (equiv (A := Node));
XLink: (XLink n n') is
- either None when n' is not an X-neighbor of n;
- either Some c when n ?-c----? n', i.e. n' is the X-neighbor of n through XChannel c, with X being either In or Out.
inLink: Node * OutChannel -> option (Node * InChannel);
outLink: Node * InChannel -> option (Node * OutChannel);
outLink: Node * InChannel -> option (Node * OutChannel);
peer and link cover the same arcs of the network
Link_spec: forall n1 n2 c1 c2,
inLink (n1,c1) == Some (n2,c2) <-> outLink (n2,c2) == Some (n1,c1);
inLink_compat: Proper fequiv inLink;
outLink_compat: Proper fequiv outLink;
inLink (n1,c1) == Some (n2,c2) <-> outLink (n2,c2) == Some (n1,c1);
inLink_compat: Proper fequiv inLink;
outLink_compat: Proper fequiv outLink;
The number of nodes is finite: this is modeled using
a (finite) list of nodes and with the predicate:
every node is in this list.
The number of arcs is also finite: this is modeled using
a (finite) list of incomming channels and with the predicate:
every incoming channel is in this list.
all_inChannels: list InChannel;
all_inChannels_prop: forall n1 cin n2 cout, is_InChannel n1 cin n2 -> InA equiv cin all_inChannels;
}.
fromIntoOutChannel and fromOuttoInChannel are inverse of each other (first version)
For a given network and a given node n, (XPeers n) is the list
of XChannels from n
peers characterization using the function peer:
every channel in (peers n) is actually a channel from n
in the network
Class Algorithm:
run s sn
run s sn
returns a new state for node n.
If this new state is actually different from s, then the node
was enabled and did compute. Otherwise the run function has no
effect and this means that either the node was disabled or that the
statement of the algorithm has no effect.
Type State: state of a node
Type Msg: state of a message
run: see above
run: State -> option (InChannel * Msg) -> (State * (list (OutChannel*Msg)));
run_compat :> Proper fequiv run;
}.
Stable Variable
Class Stable_Variable {InChans: InChannels} {OutChans: OutChannels}
(Algo: MPAlgorithm) (VarType: Type) (GetVar: State -> VarType) :=
{
(Algo: MPAlgorithm) (VarType: Type) (GetVar: State -> VarType) :=
{
VarType: type of the projection
projection is compatible
GetVar projection is preserved by run