Skip to content

Instantly share code, notes, and snippets.

@LeventErkok
Created May 28, 2017 17:15
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 LeventErkok/1b5962193d16273c320f61da442e7406 to your computer and use it in GitHub Desktop.
Save LeventErkok/1b5962193d16273c320f61da442e7406 to your computer and use it in GitHub Desktop.
import Data.SBV
p :: Goal
p = do a <- sInteger "a"
b <- sInteger "b"
ab <- sInteger "ab"
constrain $ a*a - b*b .== 21
constrain $ a*a + b*b .== 29
constrain $ ab .== a*b
{-
*Main> main
Solution #1:
a = -5 :: Integer
b = 2 :: Integer
ab = -10 :: Integer
Solution #2:
a = 5 :: Integer
b = 2 :: Integer
ab = 10 :: Integer
Solution #3:
a = -5 :: Integer
b = -2 :: Integer
ab = 10 :: Integer
Solution #4:
a = 5 :: Integer
b = -2 :: Integer
ab = -10 :: Integer
Found 4 different solutions.
-}
main :: IO ()
main = print =<< allSat p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment