Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
SBV proof of the drinker paradox: http://en.wikipedia.org/wiki/Drinker_paradox
Let P be the non-empty set of people in a bar. The theorem says if there is somebody drinking in the bar, then everybody is drinking in the bar. The general formulation is:
∃x : P. D(x) -> ∀y : P. D(y)
In SBV, quantifiers are allowed, but you need to put the formula into prenex normal form manually. See http://en.wikipedia.org/wiki/Prenex_normal_form for details. (Note that you do not need to do skolemization by hand, though SBV will do that for you automatically as well as it casts the problem into an SMT query.) If we transform the above to prenex form, we get:
∃x : P. ∀y : P. D(x) -> D(y)
In this file, we show two different ways of proving the above in SBV; one using the monadic style, and the other using the expression style.
Documentation
Declare a carrier data-type in Haskell named P, representing all the people in a bar.
Instances
Data P Source # | |
Defined in Documentation.SBV.Examples.Puzzles.Drinker gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> P -> c P # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c P # dataTypeOf :: P -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c P) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c P) # gmapT :: (forall b. Data b => b -> b) -> P -> P # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> P -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> P -> r # gmapQ :: (forall d. Data d => d -> u) -> P -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> P -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> P -> m P # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> P -> m P # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> P -> m P # | |
Read P Source # | |
Show P Source # | |
SymVal P Source # | |
Defined in Documentation.SBV.Examples.Puzzles.Drinker mkSymVal :: MonadSymbolic m => VarContext -> Maybe String -> m (SBV P) Source # literal :: P -> SBV P Source # isConcretely :: SBV P -> (P -> Bool) -> Bool Source # sbvForall :: MonadSymbolic m => String -> m (SBV P) Source # sbvForall_ :: MonadSymbolic m => m (SBV P) Source # mkForallVars :: MonadSymbolic m => Int -> m [SBV P] Source # sbvExists :: MonadSymbolic m => String -> m (SBV P) Source # sbvExists_ :: MonadSymbolic m => m (SBV P) Source # mkExistVars :: MonadSymbolic m => Int -> m [SBV P] Source # free :: MonadSymbolic m => String -> m (SBV P) Source # free_ :: MonadSymbolic m => m (SBV P) Source # mkFreeVars :: MonadSymbolic m => Int -> m [SBV P] Source # symbolic :: MonadSymbolic m => String -> m (SBV P) Source # symbolics :: MonadSymbolic m => [String] -> m [SBV P] Source # unliteral :: SBV P -> Maybe P Source # | |
HasKind P Source # | |
Defined in Documentation.SBV.Examples.Puzzles.Drinker | |
SatModel P Source # | |
Declare the uninterpret function d
, standing for drinking. For each person, this function
assigns whether they are drinking; but is otherwise completely uninterpreted. (i.e., our theorem
will be true for all such functions.)