-- the kernel data structure has two components representing -- 1) a mapping with the current status of the lights for each -- direction and 2) an unordered collection of conflicts between -- paths.
Kernel :: lights : map Path to Light
conflicts : setof Conflict inv mk_Kernel(ls,cs) == forall c inset cs &
mk_Conflict(c.path2,c.path1) inset cs and
c.path1 insetdom ls and
c.path2 insetdom ls and
(ls(c.path1) = <Red> or ls(c.path2) = <Red>)
functions
-- changing the light to green for a given path
ToGreen: Path * Kernel -> Kernel
ToGreen(p,mk_Kernel(lights,conflicts)) ==
mk_Kernel(ChgLight(lights,p,<Green>),conflicts) pre p insetdom lights and
lights(p) = <Red> and forall mk_Conflict(p1,p2) inset conflicts &
(p = p1 => lights(p2) = <Red>);
-- changing the light to red for a given path
ToRed: Path * Kernel -> Kernel
ToRed(p,mk_Kernel(lights,conflicts)) ==
mk_Kernel(ChgLight(lights,p,<Red>),conflicts) pre p insetdom lights and lights(p) = <Amber>;
-- changing the light to amber for a given path
ToAmber: Path * Kernel -> Kernel
ToAmber(p,mk_Kernel(lights,conflicts)) ==
mk_Kernel(ChgLight(lights,p,<Amber>),conflicts) pre p insetdom lights and lights(p) = <Green>;
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 ist noch experimentell.