Created
January 13, 2011 00:29
-
-
Save msakai/777169 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
sig Coin {} | |
abstract sig State { | |
candidates : set Coin, | |
} | |
sig Branch extends State { | |
left, right : set Coin, | |
eq, lt, gt : State | |
} | |
fact { | |
all b : Branch { | |
not b in b.^(eq+lt+gt) | |
no b.left & b.right | |
#b.left = #b.right | |
b.eq.candidates = b.candidates - (b.left + b.right) | |
b.lt.candidates = b.candidates & b.left | |
b.gt.candidates = b.candidates & b.right | |
} | |
} | |
sig Leaf extends State { } | |
{ lone candidates } | |
pred solve { | |
one root : State { | |
root.candidates = Coin | |
State in root.*(eq+lt+gt) | |
} | |
} | |
run solve for 5 int, 4 Branch, 9 Leaf, exactly 8 Coin |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment