Skip to content

Instantly share code, notes, and snippets.

@LeventErkok
Last active August 29, 2015 14:24
Show Gist options
  • Save LeventErkok/e65095f98a38de579016 to your computer and use it in GitHub Desktop.
Save LeventErkok/e65095f98a38de579016 to your computer and use it in GitHub Desktop.
import Data.SBV
choice = allSat $ do
[a, b, c, d, e, f] <- sBools ["a", "b", "c", "d", "e", "f"]
solve [ a .== bAnd [b, c, d, e] -- a. All of the below
, b .== bAnd (map bnot [c, d, e]) -- b. None of the below
, c .== bAnd [a, b] -- c. All of the above
, d .== ((1::SInteger) .== sum (map oneIf [a, b, c])) -- d. One of the above
, e .== bAnd (map bnot [a, b, c, d]) -- e. None of the above
, f .== bAnd (map bnot [a, b, c, d, e]) -- f. None of the above
]
{-
*Main> choice
Solution #1:
a = False
b = False
c = False
d = False
e = True
f = False
This is the only solution.
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment