Created
May 19, 2020 15:59
-
-
Save parlarjb/3fbfd653a145f81b9fa1aa78202e4808 to your computer and use it in GitHub Desktop.
This file contains 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
open util/ordering[Time] | |
sig Time {} | |
sig Key { | |
pressed: set Time | |
} | |
abstract sig Event { | |
pre, post: Time, | |
key: Key | |
} | |
sig Press extends Event {} { | |
pre not in key.pressed | |
post in key.pressed | |
noPressChangeExcept [key] | |
} | |
sig Release extends Event {} { | |
pre in key.pressed | |
post not in key.pressed | |
noPressChangeExcept [key] | |
} | |
pred Event.noPressChangeExcept (key: Key) { | |
all k: Key - key | { | |
(this.pre) in k.pressed implies (this.post) in k.pressed | |
(this.pre) not in k.pressed implies (this.post) not in k.pressed | |
} | |
} | |
pred init (t: Time) { | |
t not in Key.pressed | |
} | |
fact Traces { | |
first.init | |
all t: Time - last | let t' = t.next | | |
some e: Event { | |
e.pre = t and e.post = t' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment