项目作者: pcerman

项目描述 :
Implementation of the Binary Decision Diagrams in Racket
高级语言: Racket
项目地址: git://github.com/pcerman/bdd-racket.git
创建时间: 2016-10-25T09:25:54Z
项目社区:https://github.com/pcerman/bdd-racket

开源协议:MIT License

下载


Binary Decision Diagrams (bdd-racket)

This is experimental library which implements Binary Decision Diagrams
(BDD) in Racket programming language.
This is not production library. It will be changed without preserving
backward compatibility in the future. Library implements Reduced
Ordered Binary Decision Diagrams
(ROBDD) and Zero-Suppressed
Binary Decision Diagrams
(ZDD). My intent is to add implementation of
functions transforming ROBDD into ZDD and vice versa. I was inspired
by papers [1], [2].

License

This code is released under MIT License.
Copyright (c) 2016 Peter Cerman (https://github.com/pcerman)

Example of use

ROBDD

  1. (require "bdd.rkt" "robdd.rkt")
  2. (define ex '(xor (xor x y) z))
  3. ;; create ROBDD for this boolean expression
  4. (define bdd (make-robdd ex '(x y z)))
  5. ;; create graph representation of this ROBDD and write it into the file
  6. (bdd->tgf bdd "bdd.tgf" '(x y z))
  7. ;; count number of solutions which evaluates to boolean value true
  8. (robdd-sat-count bdd 3)
  9. ;; it returns: 4
  10. ;; transform ROBDD into boolean expression
  11. (robdd->b-expr bdd '(x y z))
  12. ;; it returns: '(or (and x (or (and y z) (and (not y) (not z))))
  13. ;; (and (not x) (or (and y (not z)) (and (not y) z))))

Graph representation of the ROBDD from example:
bdd.tgf

ZDD

  1. (require "bdd.rkt" "zdd.rkt")
  2. (define ex '(xor (xor x y) z))
  3. ;; create ZDD for this boolean expression
  4. (define zdd (make-zdd ex '(x y z)))
  5. ;; create graph representation of this ZDD and write it into the file
  6. (bdd->tgf zdd "zdd.tgf" '(x y z))
  7. ;; count number of solutions which evaluates to boolean value true
  8. (zdd-count zdd)
  9. ;; it returns: 4
  10. ;; transform ZDD into boolean expression
  11. (zdd->b-expr zdd '(x y z))
  12. ;; it returns: '(or (and x (or (and y z) (and (not y) (not z))))
  13. ;; (and (not x) (or (and y (not z)) (and (not y) z))))

Graph representation of the ZDD from example. It represents subset
{ {x}, {y}, {z}, {x,y,z} } of powerset from {x,y,z}.
zdd.tgf

References

  1. Henrik Reif Andersen, An Introduction to Binary Decision Diagrams, Lecture
    notes for 49285 Advanced Algorithms E97, October 1997, Department of
    Information Technology, Technical University of Denmark
  2. Shin-ichi Minato, Zero-suppressed BDDs and their applications, International
    Journal on Software Tools for Technology Transfer, May 2001, Volume 3,
    Issue 2, pp 156–170, doi:10.1007/s100090100038