Hi!
Is there anyone who can send me LISP code for transforming formula
into disjunctive normal form, or at least point where can I find it. This
code is supposed to be a small part of my program, and I have no too much
time to do it myself.
Thanks in advance
Dragan, ······@coli.uni-sb.de
······@coli.uni-sb.de (Dragan Cvetkovic) writes:
Is there anyone who can send me LISP code for transforming formula
into disjunctive normal form, or at least point where can I find it. This
code is supposed to be a small part of my program, and I have no too much
time to do it myself.
Here's some code that may help. It assumes a representation of formulas
(formulae?), called "items," as one of several different structure types for
propositions ("item-basic") conjunctions ("item-and"), disjunctions
("item-or"), universals, or existentials. I'm sure that it can fairly easily
be converted to whatever representation you have.
(defun item-dnf (item)
(cond ((item-basic-p item)
(make-item-or :item-list
(list (make-item-and :item-list (list item)))))
((item-or-p item)
(make-item-or :item-list
(apply #'append
(mapcar #'(lambda (x)
(item-or-item-list (item-dnf x)))
(item-or-item-list item)))))
((item-and-p item)
(let* ((cnf (item-cnf item))
(list-of-cnf-lists (mapcar #'ITEM-OR-ITEM-LIST
(item-and-item-list cnf)))
(cross-product (set-cross-product list-of-cnf-lists)))
(make-item-or :item-list
(mapcar #'(lambda (sym0.922)
(make-item-and :item-list sym0.922))
cross-product))))
((item-not-p item) (item-negation (item-cnf (item-not-item item))))
((item-univ-p item)
(make-item-univ :var (item-univ-var item)
:item (item-dnf (item-univ-item item))))
(else (make-item-or :item-list
(list (make-item-and :item-list (list item)))))))
Bruce Krulwich
Institute for the Learning Sciences
········@ils.nwu.edu
In article <·····················@coli.uni-sb.de>, ······@coli.uni-sb.de (Dragan Cvetkovic) writes:
|>
|> Hi!
|> Is there anyone who can send me LISP code for transforming formula
|> into disjunctive normal form, or at least point where can I find it. This
|> code is supposed to be a small part of my program, and I have no too much
|> time to do it myself.
|> Thanks in advance
|> Dragan, ······@coli.uni-sb.de
I have some code for finding DNF or CNF that I wrote about 3 years ago
and am able to distribute. I remember little about its internals, but
in response to the above post I at least verified it to be
not-obviously-broken. It's written in CL and uses the Loop macro.
--
Raul E. Valdes-Perez ······@cs.cmu.edu
Carnegie Mellon University (412) 268-7127