Skip to content

Commit

Permalink
Add theorems
Browse files Browse the repository at this point in the history
Helps document what invariants should hold.
  • Loading branch information
changlinli committed Jul 25, 2019
1 parent f3155bb commit 54fc6fb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Peterson.tla
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,17 @@ SpecWithFairness == Spec /\ WF_vars(Next) /\ \A p \in {0, 1} : WF_vars(ProcessRe
(***************************************************************************)
MutualExclusion == ~(processState[0] = "critical" /\ processState[1] = "critical")

THEOREM Spec => []MutualExclusion

(***************************************************************************)
(* This is a basic liveness requirement that corresponds to what is called *)
(* "Progress" in the Wikipedia article. Both processes should eventually *)
(* be able to enter their critical sections. *)
(***************************************************************************)
WillEventuallyEnterCritical == <>(processState[0] = "critical") /\ <>(processState[1] = "critical")

THEOREM SpecWithFairness => WillEventuallyEnterCritical

(***************************************************************************)
(* THIS INVARIANT DOES NOT HOLD AND SHOULD NOT HOLD! It's merely *)
(* instructive of something a reader may intuitively believe about this *)
Expand All @@ -247,7 +251,13 @@ WillEventuallyEnterCritical == <>(processState[0] = "critical") /\ <>(processSta
(***************************************************************************)
CanOnlyBeCriticalIfTurn == \A p \in {0, 1} : processState[p] = "critical" => turn = p

(***************************************************************************)
(* Finally we note simply that our variables should always stay within the *)
(* bounds we enumerated earlier. *)
(***************************************************************************)
THEOREM Spec => TypeOK

=============================================================================
\* Modification History
\* Last modified Thu Jul 25 02:13:09 EDT 2019 by changlin
\* Last modified Thu Jul 25 11:05:46 EDT 2019 by changlin
\* Created Wed Jul 24 18:56:50 EDT 2019 by changlin

0 comments on commit 54fc6fb

Please sign in to comment.