PADEC - Coq Library
Library Padec.KClustering.KClustering_specification
From Coq Require Import SetoidList.
From Coq Require Import SetoidClass.
From Coq Require Import ZArith.
From Coq Require Import SetoidClass.
From Coq Require Import ZArith.
From Padec Require Import SetoidUtil.
From Padec Require Import RelationA.
From Padec Require Import Algorithm.
From Padec Require Import RelModel.
From Padec Require Import Count.
Open Scope Z_scope.
Open Scope signature_scope.
Set Implicit Arguments.
From Padec Require Import RelationA.
From Padec Require Import Algorithm.
From Padec Require Import RelModel.
From Padec Require Import Count.
Open Scope Z_scope.
Open Scope signature_scope.
Set Implicit Arguments.
Every terminal configuration of the system should contain a
k-clustering defined as follows:Predicate that defines a k-cluster and a cluster head
Definition is_neighbor_of (y x: Node): Prop :=
exists (c: Channel), peer x c == Some y.
Definition is_path := chain is_neighbor_of.
exists (c: Channel), peer x c == Some y.
Definition is_path := chain is_neighbor_of.
First part of the specification:
- for any cluster head h, ie, such that (clusterHead h), the set
of nodes n such that (kcluster h n) represents a k-cluster,
namely,
- the set of sets { kCluster h | h, clusterHead h } is a partition
of the set of nodes, namely,
- > kCluster h' n -> eqN h h' (see partition_OK)
- > kCluster h' n -> eqN h h' (see partition_OK)
Definition kCluster_OK (g: Env): Prop :=
forall (h: Node),
clusterHead g h ->
forall (n: Node), kCluster g h n ->
exists (p: list Node),
is_path h p n /\
(forall q, InA equiv q p -> kCluster g h q) /\
(Z_of_nat (length p) <= k)%Z.
forall (h: Node),
clusterHead g h ->
forall (n: Node), kCluster g h n ->
exists (p: list Node),
is_path h p n /\
(forall q, InA equiv q p -> kCluster g h q) /\
(Z_of_nat (length p) <= k)%Z.
The set of k-clusters is a partition on the set of nodes:
Definition partition_OK (g: Env): Prop :=
forall (n: Node), (exists (h: Node), kCluster g h n) /\
forall (h h': Node), kCluster g h n -> kCluster g h' n -> h == h'.
Definition kClustering_SPEC (g: Env): Prop :=
kCluster_OK g /\ partition_OK g.
forall (n: Node), (exists (h: Node), kCluster g h n) /\
forall (h h': Node), kCluster g h n -> kCluster g h' n -> h == h'.
Definition kClustering_SPEC (g: Env): Prop :=
kCluster_OK g /\ partition_OK g.
Second part of the specification:
the k-clustering contains no more than floor((n-1)/(k+1))+1
k-clusters
The set of clusterheads
Definition ClusterHeads (g: Env) := { n: Node | clusterHead g n }.
Definition counting_OK (g: Env): Prop :=
exists (N C: nat),
Num_Card Same Node N /\ Num_Card Same (ClusterHeads g) C /\
(N - 1 >= S (Z.to_nat k) * (C - 1))%nat.
Definition counting_OK (g: Env): Prop :=
exists (N C: nat),
Num_Card Same Node N /\ Num_Card Same (ClusterHeads g) C /\
(N - 1 >= S (Z.to_nat k) * (C - 1))%nat.
n.b.: N stands for the number of nodes in the network, C
stands for the number of clusterheads, hence for the number of
k-clusters.
Third part of the specification:
- there exists a local function (on state of a node)
clusterHeadID: State -> ID which represents the clusterhead
of the node (n.b.: it requires a fully identified network)
- there exists a local function (on a state of a node)
clusterParent: State -> Channel which allows to build path
in the cluster from the node to its clusterhead (with length
smaller or equal to k)
Context {IDType: Type} `{ID_setoid: Setoid IDType}.
Variable (ID: State -> IDType)
(uniqueID:
forall (g: Env),
Proper pequiv g ->
forall n1 n2, ID (g n1) == ID (g n2) -> n1 == n2).
Variable (ID: State -> IDType)
(uniqueID:
forall (g: Env),
Proper pequiv g ->
forall n1 n2, ID (g n1) == ID (g n2) -> n1 == n2).
Variable (clusterHeadID: State -> IDType).
Definition clusterHeadID_OK (g: Env): Prop :=
forall (h n: Node), kCluster g h n <-> ID (g h) == clusterHeadID (g n).
Definition clusterHeadID_OK (g: Env): Prop :=
forall (h n: Node), kCluster g h n <-> ID (g h) == clusterHeadID (g n).
Definition of a route using cluster parent:
Definition is_cluster_parent (g: Env) (y x: Node): Prop :=
match (clusterParent (g x))
with None => False
| Some c => peer x c == Some y end.
match (clusterParent (g x))
with None => False
| Some c => peer x c == Some y end.
A route from a node to its clusterhead is a path made of
clusterParent pointers (cluster_path') such that any
intermediate node remains in the same k-cluster
(agreed_cluster_path).
Definition cluster_path (g: Env) := (chain (is_cluster_parent g)).
Definition agreed_cluster_path
(g: Env) (n': Node) (p: list Node) (n: Node): Prop :=
cluster_path g n' p n /\
forall (q: Node), InA equiv q p ->
clusterHeadID (g n') == clusterHeadID (g q).
Lemma cluster_path_is_path:
forall (g: Env) (x y: Node) (p: list Node),
agreed_cluster_path g x p y -> is_path x p y.
Definition agreed_cluster_path
(g: Env) (n': Node) (p: list Node) (n: Node): Prop :=
cluster_path g n' p n /\
forall (q: Node), InA equiv q p ->
clusterHeadID (g n') == clusterHeadID (g q).
Lemma cluster_path_is_path:
forall (g: Env) (x y: Node) (p: list Node),
agreed_cluster_path g x p y -> is_path x p y.
Any node has a route that reaches its clusterhead in at most k
hops, staying in the cluster all along the route.
Definition cluster_path_OK (g: Env): Prop :=
forall (h: Node), clusterHead g h ->
forall (n: Node),
kCluster g h n ->
exists (p: list Node), agreed_cluster_path g h p n /\
(Z_of_nat (length p) <= k)%Z.
forall (h: Node), clusterHead g h ->
forall (n: Node),
kCluster g h n ->
exists (p: list Node), agreed_cluster_path g h p n /\
(Z_of_nat (length p) <= k)%Z.
Third part of the specification
Definition kClustering_SPEC_strong (g: Env): Prop :=
kClustering_SPEC g /\ counting_OK g /\ kClustering_ID_SPEC g.
Lemma kClustering_ID_SPEC_stronger:
forall (g: Env), kClustering_ID_SPEC g -> kCluster_OK g.
kClustering_SPEC g /\ counting_OK g /\ kClustering_ID_SPEC g.
Lemma kClustering_ID_SPEC_stronger:
forall (g: Env), kClustering_ID_SPEC g -> kCluster_OK g.
Lemma kClustering_SPEC_strong_alt:
forall (g: Env), kClustering_SPEC_strong g <->
kClustering_ID_SPEC g /\
partition_OK g /\ counting_OK g.
End With_ID.
End KClustering_Specification.
Close Scope Z_scope.
Close Scope signature_scope.
Unset Implicit Arguments.
forall (g: Env), kClustering_SPEC_strong g <->
kClustering_ID_SPEC g /\
partition_OK g /\ counting_OK g.
End With_ID.
End KClustering_Specification.
Close Scope Z_scope.
Close Scope signature_scope.
Unset Implicit Arguments.