Last active
December 3, 2021 15:49
-
-
Save y-taka-23/c7f8cdd865d53662863d0d2954afdca5 to your computer and use it in GitHub Desktop.
Traffic signals with Alloy 6's temporal logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module signal | |
enum LightState { On, Off, Blink } | |
abstract sig Light { | |
var state: one LightState | |
} | |
one sig Red, Green extends Light {} | |
pred stopToGo { | |
Red.state = On | |
Green.state = Off | |
Red.state' = Off | |
Green.state' = On | |
} | |
pred goToCaution { | |
Red.state = Off | |
Green.state = On | |
Red.state' = Off | |
Green.state' = Blink | |
} | |
pred cautionToStop { | |
Red.state = Off | |
Green.state = Blink | |
Red.state' = On | |
Green.state' = Off | |
} | |
pred step { | |
stopToGo || goToCaution || cautionToStop | |
} | |
pred spec { | |
Red.state = On | |
Green.state = Off | |
always step | |
} | |
cannotOnInTheSameTime: check { | |
spec => { | |
always !(Red.state = On && Green.state = On) | |
} | |
} | |
canGoInfinitelyManyTimes: check { | |
spec => { | |
always eventually { | |
Red.state = Off | |
Green.state = On | |
} | |
} | |
} | |
run { spec } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment