{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wall -Werror #-}
module Documentation.SBV.Examples.Puzzles.Drinker where
import Data.SBV
data P
mkUninterpretedSort ''P
d :: SP -> SBool
d :: SBV P -> SBool
d = String -> SBV P -> SBool
forall a. Uninterpreted a => String -> a
uninterpret String
"D"
drinker1 :: IO ThmResult
drinker1 :: IO ThmResult
drinker1 = SymbolicT IO SBool -> IO ThmResult
forall a. Provable a => a -> IO ThmResult
prove (SymbolicT IO SBool -> IO ThmResult)
-> SymbolicT IO SBool -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ do SBV P
x <- String -> Symbolic (SBV P)
forall a. SymVal a => String -> Symbolic (SBV a)
sbvExists String
"x"
SBV P
y <- String -> Symbolic (SBV P)
forall a. SymVal a => String -> Symbolic (SBV a)
sbvForall String
"y"
SBool -> SymbolicT IO SBool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SBool -> SymbolicT IO SBool) -> SBool -> SymbolicT IO SBool
forall a b. (a -> b) -> a -> b
$ SBV P -> SBool
d SBV P
x SBool -> SBool -> SBool
.=> SBV P -> SBool
d SBV P
y
drinker2 :: IO ThmResult
drinker2 :: IO ThmResult
drinker2 = SymbolicT IO SBool -> IO ThmResult
forall a. Provable a => a -> IO ThmResult
prove (SymbolicT IO SBool -> IO ThmResult)
-> SymbolicT IO SBool -> IO ThmResult
forall a b. (a -> b) -> a -> b
$ [String] -> (SBV P -> SymbolicT IO SBool) -> SymbolicT IO SBool
forall a. Provable a => [String] -> a -> SymbolicT IO SBool
existential [String
"x"] ((SBV P -> SymbolicT IO SBool) -> SymbolicT IO SBool)
-> (SBV P -> SymbolicT IO SBool) -> SymbolicT IO SBool
forall a b. (a -> b) -> a -> b
$ \SBV P
x ->
[String] -> (SBV P -> SBool) -> SymbolicT IO SBool
forall a. Provable a => [String] -> a -> SymbolicT IO SBool
universal [String
"y"] ((SBV P -> SBool) -> SymbolicT IO SBool)
-> (SBV P -> SBool) -> SymbolicT IO SBool
forall a b. (a -> b) -> a -> b
$ \SBV P
y ->
SBV P -> SBool
d SBV P
x SBool -> SBool -> SBool
.=> SBV P -> SBool
d SBV P
y