Skip to content

Instantly share code, notes, and snippets.

@parlarjb
Created May 19, 2020 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parlarjb/3fbfd653a145f81b9fa1aa78202e4808 to your computer and use it in GitHub Desktop.
Save parlarjb/3fbfd653a145f81b9fa1aa78202e4808 to your computer and use it in GitHub Desktop.
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