proposition-0.1: Library for manipulating propositions.ContentsIndex
Data.Proposition.Internal
Description
The module containing Prop and PropLit.
Synopsis
data PropFold lit res = PropFold {
foldOr :: ([res] -> res)
foldAnd :: ([res] -> res)
foldNot :: (res -> res)
foldLit :: (lit -> res)
}
class Prop p where
propTrue :: p a
propFalse :: p a
propIsTrue :: PropLit a => p a -> Bool
propIsFalse :: PropLit a => p a -> Bool
propLit :: PropLit a => a -> p a
propAnd :: PropLit a => p a -> p a -> p a
propOr :: PropLit a => p a -> p a -> p a
propNot :: PropLit a => p a -> p a
propMapM :: (Monad m, PropLit a) => (a -> m (p a)) -> p a -> m (p a)
propFold :: PropLit a => PropFold a res -> p a -> res
propAnds :: PropLit a => [p a] -> p a
propOrs :: PropLit a => [p a] -> p a
propRebuild :: (PropLit a, Prop q) => p a -> q a
propMap :: PropLit a => (a -> p a) -> p a -> p a
propAll :: PropLit a => p a -> [a]
propSimplify :: PropLit a => p a -> p a
propBool :: Bool -> p a
propChange :: (PropLit a, PropLit b) => (a -> p b) -> p a -> p b
data Reduce a
= Value a
| Literal Bool
| None
class (Show a, Ord a) => PropLit a where
(?/\) :: a -> a -> Reduce a
(?\/) :: a -> a -> Reduce a
(?=>) :: [(a, Bool)] -> a -> Maybe Bool
simp :: a -> Maybe Bool
litNot :: a -> Maybe a
reduceOrWithImp :: PropLit a => a -> a -> Maybe (Reduce a)
reduceAndWithImp :: PropLit a => a -> a -> Maybe (Reduce a)
Documentation
data PropFold lit res
How to fold a proposition, named to stop the ordering being confusing.
Constructors
PropFold
foldOr :: ([res] -> res)
foldAnd :: ([res] -> res)
foldNot :: (res -> res)
foldLit :: (lit -> res)
class Prop p where
Standard proposition class, p must be a higher kind
Methods
propTrue :: p a
Literal true
propFalse :: p a
Literal false
propIsTrue :: PropLit a => p a -> Bool
Returns True if the formula is equal to True
propIsFalse :: PropLit a => p a -> Bool
Returns True if the formula is equal to False
propLit :: PropLit a => a -> p a
Make a proposition out of a literal
propAnd :: PropLit a => p a -> p a -> p a
(&&) equivalent
propOr :: PropLit a => p a -> p a -> p a
(||) equivalent
propNot :: PropLit a => p a -> p a
not equivalent
propMapM :: (Monad m, PropLit a) => (a -> m (p a)) -> p a -> m (p a)
a monadic map over a proposition, replacing each item with a whole proposition
propFold :: PropLit a => PropFold a res -> p a -> res
a complete fold over a proposition
propAnds :: PropLit a => [p a] -> p a
and equivalent, a fold on propAnd
propOrs :: PropLit a => [p a] -> p a
or equivalent, a fold on propOr
propRebuild :: (PropLit a, Prop q) => p a -> q a
Convert a proposition from one type to another, typically use propRebuildType instead - otherwise defaulting is an issue
propMap :: PropLit a => (a -> p a) -> p a -> p a
Non monadic map, can be defined in terms of propMapM
propAll :: PropLit a => p a -> [a]
All literals out of the proposition, can be defined in terms of propMapM
propSimplify :: PropLit a => p a -> p a
Simplify a proposition, defaults to id
propBool :: Bool -> p a
Convert a boolean to a proposition, not essential
propChange :: (PropLit a, PropLit b) => (a -> p b) -> p a -> p b
Change from on one literal type to another
show/hide Instances
data Reduce a
How to reduce a pair of values
Constructors
Value aThey reduce to one single value
Literal BoolThey reduce to a literal boolean
NoneThey do not reduce
show/hide Instances
class (Show a, Ord a) => PropLit a where
An instance for things that go inside a Prop. The simplification methods are designed to be terminating. All have default instances.
Methods
(?/\) :: a -> a -> Reduce a
Reduce two variables combined with &&
(?\/) :: a -> a -> Reduce a
Reduce two variables combined with ||
(?=>) :: [(a, Bool)] -> a -> Maybe Bool
Given a list of variables set to True/False, when given an extra value, does it reduce to True or False
simp :: a -> Maybe Bool
Simplify a single literal on its own
litNot :: a -> Maybe a
Negate a literal
show/hide Instances
reduceOrWithImp :: PropLit a => a -> a -> Maybe (Reduce a)
Try and simplify an Or, using implies
reduceAndWithImp :: PropLit a => a -> a -> Maybe (Reduce a)
Try and simplify an And, using implies
Produced by Haddock version 0.8