boolexpr-0.1: Boolean expressions with various representations and search queries.

PortabilityBoolean expressions and various representations.
Stabilityprovisional
MaintainerNicolas Pouillard <nicolas.pouillard@gmail.com>

Data.BoolExpr

Contents

Description

 

Synopsis

A boolean class

class Boolean f whereSource

A boolean type class.

Methods

(/\) :: f a -> f a -> f aSource

(\/) :: f a -> f a -> f aSource

bNot :: f a -> f aSource

bTrue :: f aSource

bFalse :: f aSource

bConst :: a -> f aSource

Boolean trees

data BoolExpr a Source

Syntax of boolean expressions parameterized over a set of leaves, named constants.

Constructors

BAnd (BoolExpr a) (BoolExpr a) 
BOr (BoolExpr a) (BoolExpr a) 
BNot (BoolExpr a) 
BTrue 
BFalse 
BConst a 

reduceBoolExpr :: BoolExpr Bool -> BoolSource

Reduce a boolean tree annotated by booleans to a single boolean.

Signed constants

data Signed a Source

Signed values are either positive of negative.

Constructors

Positive a 
Negative a 

Instances

Eq a => Eq (Signed a) 
Ord a => Ord (Signed a) 
Read a => Read (Signed a) 
Show a => Show (Signed a) 

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.

Conjunctive Normal Form

newtype CNF a Source

Constructors

CNF 

Fields

unCNF :: Conj (Disj a)
 

Instances

newtype Conj a Source

Constructors

Conj 

Fields

unConj :: [a]
 

Instances

Functor Conj 
Show a => Show (Conj a) 
Monoid (Conj a) 

boolTreeToCNF :: NegateConstant a -> BoolExpr a -> CNF aSource

Convert a boolean tree to a conjunctive normal form.

reduceCNF :: CNF Bool -> BoolSource

Reduce a boolean expression in conjunctive normal form to a single boolean.

Disjunctive Normal Form

newtype Disj a Source

Constructors

Disj 

Fields

unDisj :: [a]
 

Instances

Functor Disj 
Show a => Show (Disj a) 
Monoid (Disj a) 

newtype DNF a Source

Constructors

DNF 

Fields

unDNF :: Disj (Conj a)
 

Instances

boolTreeToDNF :: (a -> BoolExpr a) -> BoolExpr a -> DNF aSource

Convert a boolean tree to a disjunctive normal form.

reduceDNF :: DNF Bool -> BoolSource

Reduce a boolean expression in disjunctive normal form to a single boolean.

Other transformations

dualize :: NegateConstant a -> BoolExpr a -> BoolExpr aSource

pushNotInwards :: NegateConstant a -> BoolExpr a -> BoolExpr aSource

Push the negations inwards as much as possible. The resulting boolean tree no longer use negations.