Created
February 20, 2019 11:57
-
-
Save fsubal/208551996044b1d226950552cebbd1a7 to your computer and use it in GitHub Desktop.
alloy 入門ハンズオン
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
abstract sig Object {} | |
sig File extends Object {} | |
sig Directory extends Object { | |
children: set Object | |
} | |
// singleParent が欠けると => 複数の directory に属する file があらわれる | |
fact singleParent { | |
all o : Object | lone children.o | |
} | |
// acyclic が欠けると => 自分自身に属する directory が現れる | |
fact acyclic { | |
all d, child : Directory | | |
child in d.^children => child != d | |
} | |
// connected が欠けると => ツリーが2つ以上出現する | |
fact connected { | |
all f : File | one children.f | |
one d : Directory | no children.d | |
} | |
// 空ディレクトリ | |
pred emptyDirectory { | |
some d: Directory | no d.children | |
} | |
run emptyDirectory for 4 | |
// 空でないディレクトリ | |
pred presentDirectory { | |
some d: Directory | some d.children | |
} | |
run presentDirectory for 4 | |
// 3 段以上の深いディレクトリ | |
pred manyNestedDirectory { | |
some d: Directory | some d.children.children.^children | |
} | |
run manyNestedDirectory for 4 | |
// 複数のファイルを含むディレクトリ | |
pred directoryWithMultipleFiles { | |
some d: Directory | #d.children > 1 | |
} | |
run directoryWithMultipleFiles for 4 | |
// 親を持たないオブジェクトが常にちょうど 1 個だけ存在する | |
assert rootIsSingleton { | |
one o : Object | no children.o | |
} | |
check rootIsSingleton for 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment