Safe Haskell | None |
---|---|
Language | Haskell98 |
implementation of reduced ordered binary decision diagrams.
- data OBDD v
- size :: OBDD v -> Index
- null :: OBDD v -> Bool
- satisfiable :: OBDD v -> Bool
- number_of_models :: Ord v => Set v -> OBDD v -> Integer
- some_model :: Ord v => OBDD v -> IO (Maybe (Map v Bool))
- all_models :: Ord v => OBDD v -> [Map v Bool]
- fold :: Ord v => (Bool -> a) -> (v -> a -> a -> a) -> OBDD v -> a
- foldM :: (Monad m, Ord v) => (Bool -> m a) -> (v -> a -> a -> m a) -> OBDD v -> m a
- full_fold :: Ord v => Set v -> (Bool -> a) -> (v -> a -> a -> a) -> OBDD v -> a
- full_foldM :: (Monad m, Ord v) => Set v -> (Bool -> m a) -> (v -> a -> a -> m a) -> OBDD v -> m a
- toDot :: Show v => OBDD v -> String
- display :: Show v => OBDD v -> IO ()
- data Node v i
- make :: State (OBDD v) Index -> OBDD v
- register :: Ord v => Node v Index -> State (OBDD v) Index
- checked_register :: Ord v => Node v Index -> State (OBDD v) Index
- cached :: Ord v => (Index, Index) -> State (OBDD v) Index -> State (OBDD v) Index
- top :: OBDD v -> Index
- access :: OBDD v -> Node v (OBDD v)
the data type
for external use
satisfiable :: OBDD v -> Bool Source #
does the OBDD have any models?
number_of_models :: Ord v => Set v -> OBDD v -> Integer Source #
Number of satisfying assignments with given set of variables. The set of variables must be given since the current OBDD may not contain all variables that were used to construct it, since some nodes may have been removed because they had identical children.
some_model :: Ord v => OBDD v -> IO (Maybe (Map v Bool)) Source #
randomly select one model, if possible
all_models :: Ord v => OBDD v -> [Map v Bool] Source #
list of all models (WARNING not using variables that had been deleted)
fold :: Ord v => (Bool -> a) -> (v -> a -> a -> a) -> OBDD v -> a Source #
Apply function in each node, bottom-up.
return the value in the root node.
Will cache intermediate results.
You might think that
count_models = fold (b -> if b then 1 else 0) (v l r -> l + r)
but that's not true because a path might omit variables.
Use full_fold
to fold over interpolated nodes as well.
foldM :: (Monad m, Ord v) => (Bool -> m a) -> (v -> a -> a -> m a) -> OBDD v -> m a Source #
Run action in each node, bottum-up. return the value in the root node. Will cache intermediate results.
full_fold :: Ord v => Set v -> (Bool -> a) -> (v -> a -> a -> a) -> OBDD v -> a Source #
Apply function in each node, bottom-up.
Also apply to interpolated nodes: when a link
from a node to a child skips some variables:
for each skipped variable, we run the branch
function
on an interpolated node that contains this missing variable,
and identical children.
With this function, number_of_models
can be implemented as
full_fold vars (bool 0 1) ( const (+) )
.
And it actually is, see the source.
full_foldM :: (Monad m, Ord v) => Set v -> (Bool -> m a) -> (v -> a -> a -> m a) -> OBDD v -> m a Source #
toDot :: Show v => OBDD v -> String Source #
toDot outputs a string in format suitable for input to the "dot" program from the graphviz suite.
display :: Show v => OBDD v -> IO () Source #
Calls the dot
executable (must be in $PATH
) to draw a diagram
in an X11 window. Will block until this window is closed.
Window can be closed gracefully by typing q
when it has focus.