FLP Impossibility Proof Made after original paper http cs-www cs yale

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
(** FLP Impossibility Proof **)
(** Made after original paper http://cs-www.cs.yale.edu/homes/arvind/cs425/doc/fischer.pdf **)
Require Export BinPos.
Require Export List.
Require Export Coq.Arith.Compare_dec.
Require Export Coq.Lists.List.
Require Export Coq.PArith.Pnat.
Require Export Coq.Lists.ListSet.
Require Export Coq.Classes.EquivDec.
Require Export Coq.Vectors.VectorDef.
Require Export Coq.Vectors.Fin.
Require Export Setoid.
Local Open Scope nat_scope.
Import ListNotations.
Local Open Scope list_scope.
(** Each process p has a one-bit input register x, an output register y with
values in (b, 0, 1), so (b, f, t) **)
Inductive Register :Type :=
| b
| f
| t.
Definition InternalState:Type := nat.
Definition MessageValue:Type := nat.
Theorem mv_eq_dec : forall x y:MessageValue, {x = y} + {x <> y}.
Proof. intros. auto with *. Qed.
Inductive Message:Type :=
| emptyMessage
| messageValue: MessageValue -> Message.
Inductive Process : Type := {
inputRegister : Register;
outputRegister : Register;
internalState : InternalState;
transitionFunction : Message -> Process;
messagesBuffer : set MessageValue
}.
Definition decisionState (p:Process) : bool :=
match outputRegister p with
|b => false
|_ => true
end.
Parameter numOfProcesses:nat.
Hypothesis np2: numOfProcesses >= 2.
Definition ProcessId := Fin.t numOfProcesses.
Definition Configuration:Type := Vector.t Process numOfProcesses.
Parameter initialConfiguration : Configuration.
Definition NonDeterministicChoice := set MessageValue -> Message.
Variable ndChoiceImpl: NonDeterministicChoice.
Definition updateMsgBuf (p:Process)(mb:set MessageValue):Process :=
({|inputRegister := p.(inputRegister); outputRegister := p.(outputRegister);
internalState := p.(internalState); transitionFunction := p.(transitionFunction);
messagesBuffer := mb |}).
Definition updateCfg (c:Configuration)(pid:ProcessId)(fn: Process -> Process) : Configuration :=
replace c pid (fn (nth c pid)).
Definition send (cfg:Configuration) (pid:ProcessId) (mv: MessageValue) : Configuration :=
updateCfg cfg pid (fun p=> let pmsgs : set MessageValue := messagesBuffer p in
let newmsgs := set_add mv_eq_dec mv pmsgs in updateMsgBuf p newmsgs).
Import VectorNotations.
(** todo: prove the lemma **)
Lemma cfg_replace_replaced: forall pid p (c:Configuration), nth (replace c pid p) pid = p.
(** todo: prove the lemma **)
Lemma cfg_replace_comm: forall pid1 pid2 p1 p2 (c:Configuration), pid1 <> pid2 -> replace (replace c pid1 p1) pid2 p2 = replace (replace c pid2 p2) pid1 p1.
(** todo: prove the lemma **)
Lemma updateCfg_comm: forall p1 p2 pid1 pid2 fn1 fn2 (c:Configuration),
pid1 <> pid2 -> p1 = fn1 c[@pid1] -> p2 = fn2 c[@pid2] -> updateCfg (updateCfg c pid1 fn1) pid2 fn2 = updateCfg (updateCfg c pid2 fn2) pid1 fn1.
(** todo: prove the lemma **)
Lemma send_length_comm: forall pid1 pid2 m c, pid1 <> pid2 -> send (send c pid2 m) pid1 m = send (send c pid1 m) pid2 m.
(** todo: update further code **)
(** todo: re- implement **)
Definition receive (p:Process) (mb:Configuration) : prod Message Configuration :=
let msgsOpt := MP.find p mb in
match option_map (fun msgs => pair msgs (ndChoiceImpl msgs)) msgsOpt with
| Some (pair msgs N0) => pair N0 mb
| Some (pair msgs (Npos n)) => let newMsgs:list MessageValue := remove n msgs in pair n (MP.add p newMsgs mb)
| None => pair N0 (MP.add p nil mb)
end.
Definition ChooseProcess := Configuration -> Process.
Variable chooseProcess: ChooseProcess.
(** update key **)
Fixpoint step (c:Configuration) : Configuration :=
let p := chooseProcess c in
let (msgOpt, cfg) := receive p c in
let newP := transitionFunction p msgOpt in cfg.
Definition Event : Type := prod Process MessageValue.
Definition Schedule := list Event.
Definition Run :=
(**
LEMMA 1. Suppose that from some configuration C, the schedules s1, s2 lead
to configurations C1, C2, respectively. If the sets of processes taking steps
in C1 and C2, respectively, are disjoint, then s2 can be applied to C1 and s1 can be
applied to C2, and both lead to the same configuration Cf.
**)