Skip to content

Instantly share code, notes, and snippets.

@hironow
Created October 28, 2015 17:34
Show Gist options
  • Save hironow/af777a153660fe0abfe2 to your computer and use it in GitHub Desktop.
Save hironow/af777a153660fe0abfe2 to your computer and use it in GitHub Desktop.
Alloy File System Lesson I
sig FSObject {
parent: lone Dir
}
sig Dir extends FSObject {
contents: set FSObject
}
sig File extends FSObject {}
fact {
all d: Dir, o: d.contents | o.parent = d
}
fact {
File + Dir = FSObject
}
one sig Root extends Dir {} { no parent }
fact {
FSObject in Root.*contents
}
assert acyclic {
no d: Dir | d in d.^contents
}
check acyclic for 5
assert oneRoot {
one d: Dir | no d.parent
}
check oneRoot for 5
assert oneLocation {
all o: FSObject | lone d: Dir | o in d.contents
}
check oneLocation for 5
assert Wrong {
all obj, p: (FSObject - Root) | obj.parent = p.parent
}
check Wrong for 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment