(***********************************************************)
(* Lemmas about specific sub-predicates *)

(* Specifications: *)
Lemma pt_PhaseOneE d e dt lg pt to ds tms:
let d' :=   {|
dstate := upd cn ds (dstate d);
dsoup := (post_msg (dsoup d) (Msg tms cn to true)).1
|} in
coh d -> pt \in pts -> pt == to = false ->
(forall z : nat, (z == cn) = false -> loc z d' = loc z d) ->
pt_PhaseOne d e dt lg pt ->
pt_PhaseOne d' e dt lg pt.
Lemma pt_PhaseOneRespondedE d e dt lg b pt to ds tms:
let d' :=   {|
dstate := upd cn ds (dstate d);
dsoup := (post_msg (dsoup d) (Msg tms cn to true)).1
|} in
coh d -> pt \in pts -> pt == to = false ->
(forall z : nat, (z == cn) = false -> loc z d' = loc z d) ->
pt_PhaseOneResponded d e dt lg b pt ->
pt_PhaseOneResponded d' e dt lg b pt.
Lemma pt_PhaseTwoCommitE d e dt lg pt to ds tms:
let d' :=   {|
dstate := upd cn ds (dstate d);
dsoup := (post_msg (dsoup d) (Msg tms cn to true)).1
|} in
coh d -> pt \in pts -> pt == to = false ->
(forall z : nat, (z == cn) = false -> loc z d' = loc z d) ->
pt_PhaseTwoCommit d e dt lg pt ->
pt_PhaseTwoCommit d' e dt lg pt.
Lemma pt_PhaseTwoAbortE d e dt lg pt to ds tms:
let d' :=   {|
dstate := upd cn ds (dstate d);
dsoup := (post_msg (dsoup d) (Msg tms cn to true)).1
|} in
coh d -> pt \in pts -> pt == to = false ->
(forall z : nat, (z == cn) = false -> loc z d' = loc z d) ->
pt_PhaseTwoAbort d e dt lg pt ->
pt_PhaseTwoAbort d' e dt lg pt.
Lemma cn_state_consume d ds cs lg i n :
let: d' := {|
dstate := upd n ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
cn != n ->
coh d ->
cn_state d cs lg ->
cn_state d' cs lg.
Lemma pt_state_consume d ds ps lg pt i n :
let: d' := {|
dstate := upd n ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
pt != n ->
coh d ->
pt_state d ps lg pt ->
pt_state d' ps lg pt .
Lemma pt_InitE_consume d e lg pt ds i from to m:
let: d' :=   {|
dstate := upd to ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
coh d -> pt \in pts ->
pt != from ->
pt != to ->
find i (dsoup d) =
Some {| content := m; from := from; to := to; active := true |} ->
pt_Init d e lg pt ->
pt_Init d' e lg pt.
Lemma pt_PhaseOneE_consume d e dt lg pt ds i from to m:
let d' :=   {|
dstate := upd to ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
coh d -> pt \in pts ->
pt != from ->
pt != to ->
find i (dsoup d) =
Some {| content := m; from := from; to := to; active := true |} ->
pt_PhaseOne d e dt lg pt ->
pt_PhaseOne d' e dt lg pt.
Lemma pt_PhaseOneRespondedE_consume d e dt lg b pt ds i from:
let: d' :=   {|
dstate := upd from ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
coh d -> pt \in pts ->
pt != from ->
pt_PhaseOneResponded d e dt lg b pt ->
pt_PhaseOneResponded d' e dt lg b pt.
Lemma cn_PhaseOneReceive_consume d round next_data lg recvd i m from :
cn_PhaseOneReceive d round next_data lg recvd ->
find i (dsoup d) = Some {| content := m; from := from; to := cn; active := true |} ->
from \in pts ->
from \in map fst recvd ->
coh d ->
let: d' :=
{|
dstate := upd cn (mkLocal (round, CWaitPrepResponse next_data recvd, lg)) (dstate d);
dsoup := consume_msg (dsoup d) i |}
in
cn_PhaseOneReceive d' round next_data lg recvd.
Lemma pt_PhaseTwoRespondedE_consume d e dt lg b pt ds i this:
let: d' :=   {|
dstate := upd this ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
coh d -> pt \in pts -> pt != this ->
pt_PhaseTwoResponded d e dt lg b pt ->
pt_PhaseTwoResponded d' e dt lg b pt.
Lemma pt_PhaseTwoCommitE_consume d e dt lg pt ds from to i m:
let: d' :=   {|
dstate := upd to ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
coh d ->
pt != from ->
pt != to ->
find i (dsoup d) =
Some {| content := m; from := from; to := to; active := true |} ->
pt_PhaseTwoCommit d e dt lg pt ->
pt_PhaseTwoCommit d' e dt lg pt.
Lemma pt_PhaseTwoAbortE_consume d e dt lg pt ds from to i m:
let: d' :=   {|
dstate := upd to ds (dstate d);
dsoup := consume_msg (dsoup d) i
|} in
coh d ->
pt != from ->
pt != to ->
find i (dsoup d) =
Some {| content := m; from := from; to := to; active := true |} ->
pt_PhaseTwoAbort d e dt lg pt ->
pt_PhaseTwoAbort d' e dt lg pt.
Lemma cn_state_soupE d ds this h cs lg :
let: d' := {| dstate := upd this h (dstate d);
dsoup := ds |} in
coh d ->
this != cn ->
cn_state d cs lg ->
cn_state d' cs lg.
Lemma pt_state_soupE d ds h ps lg pt n :
let: d' := {|
dstate := upd n h (dstate d);
dsoup := ds
|} in
coh d ->
pt != n ->
pt_state d ps lg pt ->
pt_state d' ps lg pt .
Lemma pt_PhaseOneE' d r nd lg pt from h to m :
let: d' := {| dstate := upd from h (dstate d);
dsoup := (post_msg (dsoup d)
{| content := m; from := from; to := to; active := true |}).1 |} in
coh d ->
from != pt ->
from != cn ->
pt_PhaseOne d r nd lg pt ->
pt_PhaseOne d' r nd lg pt.
Lemma pt_InitE d r lg pt from h to m :
let: d' := {| dstate := upd from h (dstate d);
dsoup := (post_msg (dsoup d)
{| content := m; from := from; to := to; active := true |}).1 |} in
coh d ->
from != pt ->
from != cn ->
pt_Init d r lg pt ->
pt_Init d' r lg pt.
Lemma pt_PhaseOneRespondedE' d r nd lg pt from h to m b :
let: d' := {| dstate := upd from h (dstate d);
dsoup := (post_msg (dsoup d)
{| content := m; from := from; to := to; active := true |}).1 |} in
coh d ->
from != pt ->
from != cn ->
pt_PhaseOneResponded d r nd lg b pt ->
pt_PhaseOneResponded d' r nd lg b pt.
Lemma PhaseTwo_PCommitted_pt d pt round lg next_data r nd (C : coh d)
(Hpt : pt \in nodes _ _ _) :
pt \in pts ->
getStP Hnin C Hpt = (r, PCommitted nd) ->
PhaseTwo d round next_data lg ->
[/\ pt_state d (round, PCommitted next_data) (rcons lg (true, next_data)) pt,
no_msg_from_to cn pt (dsoup d)
& no_msg_from_to pt cn (dsoup d)].
Lemma pt_PhaseTwoCommitE' d r nd lg pt from h to m :
let: d' := {| dstate := upd from h (dstate d);
dsoup := (post_msg (dsoup d)
{| content := m; from := from; to := to; active := true |}).1 |} in
coh d ->
from != pt ->
from != cn ->
pt_PhaseTwoCommit d r nd lg pt ->
pt_PhaseTwoCommit d' r nd lg pt.
Lemma pt_PhaseTwoAbortE' d r nd lg pt from h to m :
let: d' := {| dstate := upd from h (dstate d);
dsoup := (post_msg (dsoup d)
{| content := m; from := from; to := to; active := true |}).1 |} in
coh d ->
from != pt ->
from != cn ->
pt_PhaseTwoAbort d r nd lg pt ->
pt_PhaseTwoAbort d' r nd lg pt.
Lemma pt_PhaseTwoRespondedE' d r nd lg pt from h to m b :
let: d' := {| dstate := upd from h (dstate d);
dsoup := (post_msg (dsoup d)
{| content := m; from := from; to := to; active := true |}).1 |} in
coh d ->
from != pt ->
from != cn ->
pt_PhaseTwoResponded d r nd lg b pt ->
pt_PhaseTwoResponded d' r nd lg b pt.
Lemma PhaseTwo_PAborted_pt d pt round lg next_data r nd (C : coh d)
(Hpt : pt \in nodes _ _ _) :
pt \in pts ->
getStP Hnin C Hpt = (r, PAborted nd) ->
PhaseTwo d round next_data lg ->
[/\ pt_state d (round, PAborted next_data) (rcons lg (false, next_data)) pt,
no_msg_from_to cn pt (dsoup d)
& no_msg_from_to pt cn (dsoup d)].