Copyright | (c) Nicolas Pouillard 20082009 |
---|---|
License | BSD3 |
Maintainer | Nicolas Pouillard <nicolas.pouillard@gmail.com> |
Stability | provisional |
Portability | |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Boolean expressions and various representations.
Synopsis
- class Boolean f where
- data BoolExpr a
- reduceBoolExpr :: BoolExpr Bool -> Bool
- evalBoolExpr :: (a -> Bool) -> BoolExpr a -> Bool
- newtype Eval b a = Eval {
- runEval :: (a -> b) -> b
- runEvalId :: Eval a a -> a
- data Signed a
- negateSigned :: Signed a -> Signed a
- evalSigned :: (a -> Bool) -> Signed a -> Bool
- constants :: BoolExpr a -> [Signed a]
- negateConstant :: Boolean f => Signed a -> f a
- newtype CNF a = CNF {}
- newtype Conj a = Conj {
- unConj :: [a]
- boolTreeToCNF :: BoolExpr a -> CNF a
- newtype Disj a = Disj {
- unDisj :: [a]
- newtype DNF a = DNF {}
- boolTreeToDNF :: BoolExpr a -> DNF a
- dualize :: Boolean f => BoolExpr a -> f a
- fromBoolExpr :: Boolean f => BoolExpr a -> f a
- pushNotInwards :: Boolean f => BoolExpr a -> f a
A boolean class
class Boolean f where Source #
A boolean type class.
Boolean trees
Syntax of boolean expressions parameterized over a set of leaves, named constants.
BAnd (BoolExpr a) (BoolExpr a) | |
BOr (BoolExpr a) (BoolExpr a) | |
BNot (BoolExpr a) | |
BTrue | |
BFalse | |
BConst (Signed a) |
Instances
reduceBoolExpr :: BoolExpr Bool -> Bool Source #
Reduce a boolean tree annotated by booleans to a single boolean.
Boolean evaluation semantic
Instances
Signed constants
Signed values are either positive or negative.
Instances
negateSigned :: Signed a -> Signed a Source #
constants :: BoolExpr a -> [Signed a] Source #
Returns constants used in a given boolean tree, these constants are returned signed depending one how many negations stands over a given constant.
negateConstant :: Boolean f => Signed a -> f a Source #
Conjunctive Normal Form
boolTreeToCNF :: BoolExpr a -> CNF a Source #
Convert a boolean tree to a conjunctive normal form.
Disjunctive Normal Form
boolTreeToDNF :: BoolExpr a -> DNF a Source #
Convert a boolean tree to a disjunctive normal form.
Other transformations
fromBoolExpr :: Boolean f => BoolExpr a -> f a Source #
Turns a boolean tree into any boolean type.
pushNotInwards :: Boolean f => BoolExpr a -> f a Source #
Push the negations inwards as much as possible. The resulting boolean tree no longer use negations.