record state =
p :: bool
m :: int
n :: int
u :: bool
v :: bool
type_synonym command = "(state*state) set"
(** The program for process U **)
definition U0 :: command where"U0 = {(s,s'). s' = s (|u:=True, m:=1|) & m s = 0}"
definition U1 :: command where"U1 = {(s,s'). s' = s (|p:= v s, m:=2|) & m s = 1}"
definition U2 :: command where"U2 = {(s,s'). s' = s (|m:=3|) & ~ p s & m s = 2}"
definition U3 :: command where"U3 = {(s,s'). s' = s (|u:=False, m:=4|) & m s = 3}"
definition U4 :: command where"U4 = {(s,s'). s' = s (|p:=True, m:=0|) & m s = 4}"
(** The program for process V **)
definition V0 :: command where"V0 = {(s,s'). s' = s (|v:=True, n:=1|) & n s = 0}"
definition V1 :: command where"V1 = {(s,s'). s' = s (|p:= ~ u s, n:=2|) & n s = 1}"
definition V2 :: command where"V2 = {(s,s'). s' = s (|n:=3|) & p s & n s = 2}"
definition V3 :: command where"V3 = {(s,s'). s' = s (|v:=False, n:=4|) & n s = 3}"
definition V4 :: command where"V4 = {(s,s'). s' = s (|p:=False, n:=0|) & n s = 4}"
definition Mutex :: "state program" where"Mutex = mk_total_program ({s. ~ u s & ~ v s & m s = 0 & n s = 0}, {U0, U1, U2, U3, U4, V0, V1, V2, V3, V4}, UNIV)"
(** The correct invariants **)
definition IU :: "state set" where"IU = {s. (u s = (1 ≤ m s & m s ≤ 3)) & (m s = 3 --> ~ p s)}"
definition IV :: "state set" where"IV = {s. (v s = (1 ≤ n s & n s ≤ 3)) & (n s = 3 --> p s)}"
(** The faulty invariant (for U alone) **)
definition bad_IU :: "state set" where"bad_IU = {s. (u s = (1 ≤ m s & m s ≤ 3)) & (3 ≤ m s & m s ≤ 4 --> ~ p s)}"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.