0% found this document useful (0 votes)
45 views8 pages

Implementation of Pstable Model Semantics

The document describes an implementation of Pstable model semantics for logic programs. It uses MiniSat as a SAT solver and Lparse as a front-end parser to generate a variable-free logic program. It then develops a custom Java parser to convert the logic program into Conjunctive Normal Form (CNF) that can be solved by MiniSat to find Pstable models. The implementation provides a way to automatically solve problems involving inconsistencies that were previously difficult to model and solve using stable model semantics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views8 pages

Implementation of Pstable Model Semantics

The document describes an implementation of Pstable model semantics for logic programs. It uses MiniSat as a SAT solver and Lparse as a front-end parser to generate a variable-free logic program. It then develops a custom Java parser to convert the logic program into Conjunctive Normal Form (CNF) that can be solved by MiniSat to find Pstable models. The implementation provides a way to automatically solve problems involving inconsistencies that were previously difficult to model and solve using stable model semantics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Implementation of Pstable Model Semantics

Fernando Zacarias1 , Rosalba Cuapa,2 Guillermo De Ita1 , Juan Ayala2 , and


Oscar Garcia1
1
Benemerita Universidad Autonoma de Puebla, Puebla Pue., Mexico,
[email protected],
WWW home page: http://users/~iekeland/web/welcome.html
2
Universite de Paris-Sud, Laboratoire dAnalyse Numerique, Batiment 425,
F-91405 Orsay Cedex, France

Abstract. An implementation of pstable model semantics is deployed.


MiniSat is a minimalistic, open-source SAT used and developed to help
researchers and developers in a number of projects such as ours. Fur-
thermore, we use Lparse as a front-end that adds variables (and a lot
of other stuff) to the accepted language and generates a variable-free
simple logic program that can be given to Smodels. Also we show the
utility of an automatic demonstrator implemented with these tools for
applications where the logic has consistence problems. Finally, we show
algorithm developed to calculate Pstable models.

Keywords: Satisfactibility, Pstable, Text Implication

1 Introduction

A program written in a logic programming language is a set of sentences in log-


ical form, expressing facts and rules about some problem domain. Major logic
programming language families include Prolog, Answer set programming (ASP)
and Datalog. However, in classical logic it is not always possible to express ev-
erything we want. Furthermore, the generalization of SLD resolution used by
Prolog in the presence of negation in the bodies of rules does not fully match
the truth tables familiar from classical propositional logic [1].

The meaning of negation in logic programs is closely related to two theories


of nonmonotonic reasoning autoepistemic logic and default logic. The discovery
of these relationships was a key step towards the invention of the stable model
semantics. The stable model semantics for logic programming support it self
within the non-monotonic reasoning, [1]. This approach has been widely used and
it is perhaps the most well known semantics for knowledge representation. The
Pstable model semantics, introduced in [2] shares several properties with stable
model semantics, but it is closer to classical logic than stable. Pstable model
semantics has at least the same expressiveness of stable, this means we can model
anything that is modeled in stable model semantics, and how we proof with our
experiments Pstable can model things, hard or may be impossible of model with
stable models. This is why we are interested in a good implementation. The
purpose of this paper is to show the utility and reach of these tools.
in section 2 the background necessary for the development of our proposal
is defined. Next, in section 3 we show how the implementation of our proposal
called Pstable solver is developed. At once, our plug-in for Text implication is
showed in section 4. Finally, our conclusions about our proposal are presented.

2 Background

In this section, we give the necessary definitions to develop our work. Some of the
most outstanding definitions refer to the semantics in question called Pstable.
Thus, definition of the pstable model semantics was show in [2] and it is as
following:
A normal logic program (sometimes a general logic program) is a set of clauses
of the form:

A L1 , , Ln (n 0)
where A is an atom and each Li is a literal. A literal is either an atom or a nbf -
literal of the form not A where A is an atom. not denotes negation by failure.

A model of a normal logic program P is a set of atoms X such that TP


(X) subset X, or equivalently, such that X is an (ordinary, classical) model of
the clauses P obtained by replacing every occurrence of not in P by ordinary,
truth-functional negation .

Stable models [1] also called answer sets provide a simple semantics for
normal logic programs that works even for programs like this:

p(1,2)
q(X) p(X,Y), not q(Y)

This program is not stratified, and not even locally stratified. Yet it seems
to have a clear intuitive meaning (such programs arise very naturally in many
forms of default reasoning). Even in Prolog the query ?-q(X) does not loop and
returns the answer you would intuitively expect. The ideas of stable models
can be generalised very naturally to extended logic programs, which combine
negation-by-failure not with classical(strong, explicit) negation . For a normal
logic program, a stable model is a set of atoms. For an extended logic program,
a stable model (alias an answer set) is a set of literals. We will look at extended
logic programs later. There is a strong connection between stable models and
autoepistemiclogic, which is an attempt to formalize how a rational agent can
reason about its own beliefs. We wont pursue the connection to auto-epistemic
logic.
Definition. For a normal logic program, a stable model is a set of atoms [1].

Pstable model semantics. Let P be a normal program, and M a set of


atoms. We say that M is a pstable model of P if M is a model of P and RedM (P )
|= M .

Textual Implication. This term is used when from the semantics of a text
in natural language, is possible to infer, another text in natural language. More
specifically, if the true of one sentence implies the true of the other one, also call
hypothesis [3].

3 A Fast and Pstable Solver

The previous analysis of graph problems and text implication solving, add to the
intention of solving by using logic, make a big gap, mainly because the classic
logic requires complex modeling, just for pre-solving inconsistencies. There is a
logic extension able to solve inconsistencies, so that is the logic modeling we will
use for our implementation.

Logical solution tools are available; unfortunately, ASP is still weak for pro-
blems as simple as:

a b and
b a and
b.
this look like a contradiction, strangely if we make a deep look of this we can
see it as:

(a or b) and (b or a) and b.

is a sentence with a main characteristic, the property of having satisfiable


values for a simple solution implying b and a, even been false values they make
true the problem, this models are stable for the solution and they are also solu-
tion of the original problem form.

Satisfiability can be done by many SAT solvers, we choose the MINISAT [4]
solver, because won all the industrial categories of the SAT 2005 competition
and the SAT-Race 2006. MiniSat is a good starting point both for future re-
search in SAT, and for applications using SAT, like all sat solvers MINISAT use
the DIMACS CNF format as an input, so if we wanna make a PSTALBE solver
its gonna be important first convert traditional logic input to the exclusively
disjunctive form.

First attempt to make this made us look to Lparse, most of all because works
with variable-free programs that are quite cumbersome to generate by hand also
is a front-end that adds variables (and a lot of other stuff) to the accepted
language of smodels [5] and generates a variable-free simple logic program that
can be given to smodels and we suppose that the resulting file will be easier to
convert in DIMACS CNF file. to do the parsing, but we dont get the expected
result as we show as follows:
input:
a b, not c.
c b, not a.
e c.
b.

output
110 0
121 03
131 14
141 13
0
1b
2e
3c
4a
0
B+
0
B-
0
1

is easy see how its too bounden in with smodels format and that only lead us
to a mayor level of complexity in the final parsing, and its gonna make harder,
analysis-matching of the output with the program for performing the adjustment
and actualization in the body.

Taking this experiences in consideration we decide to develop a custom parser


this parsing step and conversion thread was implemented in java, because we look
forward, and the further work will end-up in a online portal [6], once we choose
this path, the proofs gave us java as a good environment for integrate all the
work.
Later on, to parsing of a translation is done a input program like the one
below:
c b, d.
b a.
a c.
not b.
At once, the conversion of program looks like this:
c
c comments
c1c
c2b
c3d
c4a
p cnf 4 5
1 -3 0
1 -2 0
2 -4 0
4 -1 0
-2 0

taking this as an example, let us show how the program work, the variables
are not stored and converted by alphabetical or numeric order, they are parsed
by order of apparition, the variables are stored in a modified hash table (see
table 1) with sub-classing, if the memory can be seen the table be this:

Table 1. Hash table

Var Not Fact And Or


c 1 False False 0 3,2 0
b 2 True False 3 4 0
d 3 False False 2 0 0
a 4 False False 0 1 0

The table use only numeric values, we put label for easier understanding.
Structured as a dynamic structure has no limits of variables and connections
between them, also make trivial, add actions or deletion, but can increase the
time of searching a negated variable.

Search of a negated variable is tricky because SAT solvers use the disjunc-
tive for of the implication this mean that a variable may be negated in the new
format, so we make a extra table to index the first one:

The table is shown very simplified but, it contains the information of the row
where the variable occur and link the search process with the insert process.

These two structures make easy the iterative process of calculate PSTABLE
models. The process is simple and have these steps:
I. Parsing
II. Build Dynamics tables
III. Convert dynamics tables in to DIMACS CNF file
Table 2. Table for search process

Complement
c False
b True
d True
a True

IV. Invoke minisat


V. Call answer analyst
VI. Search negated variables that are not in the solution model
or in the assuming set
VII. Insert negated row to the program
VIII. Show PSTABLE model

The application of step 4 to 7 are only performed until the sat solver is unable
to find a solution that can satisfy the program and all possible models where
checked, in this moment all models that can not be satisfied.

4 Plug-in for Textual Implication

Taking the Pstable-Solver program as a core-system with the ability of accept


plug-ins we develop a plug-in with the characteristic of convert logical expressed
text in to a logical inconsistent program, this because we want to express the pro-
gram as a automatic theorem demonstrator using the contradiction way. With
this, we obtain the PStable model of the text and the implication we want to
prove is or not true, obviously if the Pstable model have only true atoms and is
equal to the facts in the logical program, we can say that the logic is tight and
the text truly implies what the input suppose. By the other side is all the atoms
from the supposition are false and the minimal model can not make true any of
its atoms, we can know for sure that the logic is not tight and is not adventure to
say the text implication is false, how ever if part of the atoms are true and other
false, the logic is obviously weak, in this cases we get advantage of the Pstable
characteristics for the analysis of the false atoms, the goal is find a model where
this atoms can be true. If the atoms can be true in a model the conjunction of
the models gave us an answer true of false as a value of the implication.

Next, we present our application with the plug-in as it is shown in the fol-
lowing figure 1.
The application can support batching and multiple log solving. To illustrate
the complexity of this calculus we compare our demonstrator with the automatic
demonstrator Otter. This demonstrator is well known as one of the best auto-
matic tools.

For the challenge we take 322 text implications of different type in logic form,
in 77 the implication was true, 235 was false and 10 where so complex that even
people could not say if theres or not implication.

With this set of proofs Otter answer to 3 problems with a yes, those were
corrects, but the 319 remaining problems could not been solve and was unable
to gave an answer, this results was very poor but the tools we develop gave much
better results, anwer 32 correct yes 235 corrects no and 3 corrects unknown , to
45 problems answer unknown but the answer must be yes, we think that this is
because the logic was very weak, even with that the pstable model proof to be
a better aproch to the solution of this problem.

Fig. 1. Aplication with Plug-in

5 Conclusions
We decide to do this investigation, and gave this direction, because, hybrid
systems and fuzzy solutions are taking lead in this day so we want to prove
that, classic logic is a prower full tool if its uses properly. During the realization
of this experiments we discover that our Textual Implication tool depend by
the moment of the accuracy, existed in the parsing tool which translate natural
language to logic, we really think that this tool can be improve with Pstable
or Stable models, Any way our tool show to be more precise, and we came to
the conclusion that is because the logic we are using and the way we pass the
problem to the logic, in fact the more important thing is the right modeling of
the problem that why our tool is less sensitive to a bad parsing than, ordinal
logic demonstrators.

References
1. Michael Gelfond and Vladimir Lifschitz.: The stable model semantics for
logic programming. In Robert A. Kowalski and Kenneth Bowen, editors, Pro-
ceedings of the Fifth International Conference on Logic Programming, pages
10701080, Cambridge, Massachusetts, 1988. The MIT Press, URL citeseer.
ist.psu.edu/gelfond88stable.html.
2. Mauricio Osorio Galindo and Juan Antonio Navarro Perez and Jose R. Arrazola
Ramrez and Veronica Borja Macas. Logics with common weak completions. Jour-
nal of Logic and Computation, 2006. URL doi: 10.1093/logcom/exl013
3. Jesus Herrera, Anselmo Penas, Felisa Verdejo Tecnicas Aplicadas al Re-
conocimiento de Implicacion Textual Departamento de Lenguajes y Sistemas In-
formaticos, Universidad Nacional de Educacion a Distancia Madrid, Espana.
4. MiniSat is a minimalistic, open-source SAT solver, developed to help researchers
and developers alike to get started on SAT. It is released under the MIT licence,
and is currently used in a number of projects. http://minisat.se/
5. Niemel and P. Simons. Extending the Smodels system with cardinality and weight
constraints. In Jack Minker, editor, Logic-Based Artificial Intelligence, chapter 21,
pages 491521. Kluwer Academic Publishers, 2000. 435

You might also like