Efficient Implementation of the Well-founded and Stable Model Semantics

An implementation of the well-founded and stable model semantics for range-restricted function-free normal programs is presented. It includes two modules: an algorithm for implementing the two semantics for ground programs and an algorithm for computing a grounded version of a range-restricted function-free normal program. The latter algorithm does not produce the whole set of ground instances of the program but a subset which is suucient in the sense that no stable models are lost. The implementation of the stable model semantics for ground programs is based on bottom-up backtracking search. It works in linear space and employs a powerful pruning method based on an approximation technique for stable models which is closely related to the well-founded semantics. The implementation includes an eecient algorithm for computing the well-founded model of a ground program. The implementation has been tested extensively and compared with a state of the art implementation of the stable model semantics, the SLG system. In tests involving ground programs it clearly outperforms SLG.