<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:space="preserve" xmlns="http://www.tei-c.org/ns/1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.tei-c.org/ns/1.0 https://raw.githubusercontent.com/kermitt2/grobid/master/grobid-home/schemas/xsd/Grobid.xsd"
 xmlns:xlink="http://www.w3.org/1999/xlink">
	<teiHeader xml:lang="en">
		<fileDesc>
			<titleStmt>
				<title level="a" type="main">Implementing the p-stable semantics</title>
			</titleStmt>
			<publicationStmt>
				<publisher/>
				<availability status="unknown"><licence/></availability>
			</publicationStmt>
			<sourceDesc>
				<biblStruct>
					<analytic>
						<author>
							<persName><forename type="first">Angel</forename><forename type="middle">Marín</forename><surname>George</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Facultad de Ciencias de la Computación</orgName>
								<orgName type="institution">Benemérita Universidad Autónoma de Puebla</orgName>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Claudia</forename><forename type="middle">Zepeda</forename><surname>Cortés</surname></persName>
							<affiliation key="aff0">
								<orgName type="department">Facultad de Ciencias de la Computación</orgName>
								<orgName type="institution">Benemérita Universidad Autónoma de Puebla</orgName>
							</affiliation>
						</author>
						<title level="a" type="main">Implementing the p-stable semantics</title>
					</analytic>
					<monogr>
						<imprint>
							<date/>
						</imprint>
					</monogr>
					<idno type="MD5">B5973163F1B9B5C09B0DF4B388A3AC19</idno>
				</biblStruct>
			</sourceDesc>
		</fileDesc>
		<encodingDesc>
			<appInfo>
				<application version="0.7.2" ident="GROBID" when="2023-03-24T12:24+0000">
					<desc>GROBID - A machine learning software for extracting information from scholarly documents</desc>
					<ref target="https://github.com/kermitt2/grobid"/>
				</application>
			</appInfo>
		</encodingDesc>
		<profileDesc>
			<textClass>
				<keywords>
					<term>non-monotonic reasoning</term>
					<term>p-stable</term>
					<term>stratified minimal model</term>
				</keywords>
			</textClass>
			<abstract>
<div xmlns="http://www.tei-c.org/ns/1.0"><p>In this paper we review some theoretical results about the p-stable semantics, and based on that, we design some algorithms that search for the p-stable models of a normal program. An important point is that some of these algorithms can also be used to compute the stratified minimal models of a normal program.</p></div>
			</abstract>
		</profileDesc>
	</teiHeader>
	<text xml:lang="en">
		<body>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">Introduction</head><p>Currently, is a promising approach to model features of commonsense reasoning. In order to formalize NMR the research community has applied monotonic logics. In <ref type="bibr" target="#b9">[7]</ref>, Gelfond and Lifschitz defined the stable model semantics by means of an easy transformation. The stable semantics has been successfully used in the modeling of non-monotonic reasoning (NMR). Additionally, Pearce presented a characterization of the stable model semantics in terms of a collection of logics in <ref type="bibr" target="#b22">[20]</ref>. He proved that a formula is "entailed by a disjunctive program in the stable model semantics if and only if it belongs to every intuitionistically complete and consistent extension of the program formed by adding only negated atoms". He also showed that in place of intuitionistic logic, any proper intermediate logic can be used. The construction used by Pearce is called a weak completion.</p><p>In <ref type="bibr" target="#b16">[14]</ref>, a new semantics for normal programs based on weak completions is defined with a three valued logic called G 3 logic. The authors call it the Pstable semantics. In <ref type="bibr" target="#b14">[12]</ref>, the authors define the p-stable semantics for disjunctive programs by means of a transformation similar to the one used by Gelfond and Lifschitz in their definition of the stable semantics. The authors also prove that the p-stable semantics for disjunctive programs can be characterized by means of a concept called weak completions and the G 3 logic, with the same two conditions used by Pearce to characterize the stable semantics of disjunctive programs, that is to say, for normal programs it coincides with the semantics defined in <ref type="bibr" target="#b16">[14]</ref>. In fact, a family of paraconsistent logics studied in <ref type="bibr" target="#b14">[12]</ref> can be used in this characterization of the p-stable semantics.</p><p>In <ref type="bibr" target="#b15">[13]</ref>, the authors offer an axiomatization of the G 3 logic along with a soundness and completeness theorem, i.e., every theorem is a tautology and vice-versa. We also remark that the authors of <ref type="bibr" target="#b14">[12]</ref> present some results that give conditions under which the concepts of stable and p-stable models agree. They present a translation of a disjunctive program D into a normal program N , such that the p-stable model semantics of N corresponds to the stable semantics of D when restricted to the common language of the theories. Besides, they show that if the size of the program D is n then the size of the program N is bounded by An 2 for a constant A. The relevance of this last result is that it shows that the p-stable model semantics for normal programs is powerful enough to express any problem that can be expressed with the stable model semantics for disjunctive programs.</p><p>One major recent result of the p-stable semantics is in the context of argumentation theory <ref type="bibr" target="#b8">[6]</ref>, which explores ways to carry out into the theory of computation the mechanisms humans use in argumentation. The three major semantics of argumentation theory (grounded, stable, and preferred) can be characterized in terms of three logic programming semantics: the well founded semantics <ref type="bibr" target="#b24">[22]</ref>, the stable semantics <ref type="bibr" target="#b9">[7]</ref> and the p-stable semantics, respectively in terms of a unique normal logic program P , that is constructed only in terms of the argumentation framework AF <ref type="bibr">[3]</ref>. Argumentation theory does not depend on a particular semantics. Then, if we want to obtain the stable semantics of AF , we compute the stable semantics of logic programming over P AF . If, on the other hand, we want to obtain the preferred semantics of AF , we compute the p-stable semantics over P AF . Moreover, if we want to obtain the grounded semantics of AF , we compute the well founded semantics over P AF .</p><p>There are also initial work about other two approaches for knowledge representation based on the p-stable semantics: updates, and preferences. In case intelligent agents get new knowledge and this knowledge must be added or updated to their knowledge base, it is important to avoid inconsistencies. An update semantics for update sequences of programs based on p-stable semantics is proposed in <ref type="bibr" target="#b17">[15]</ref>. The concept of preferences is considered a vital component of reasoning with real-world knowledge. In <ref type="bibr" target="#b18">[16]</ref>, the authors introduce preference rules which allow us to specify preferences as an ordering among the possible solutions of a problem. Their approach allow us to express preferences for arbitrary programs. They also define a semantics for those programs. The formalism used to develop their work is p-stable semantics.</p><p>It is important to mention that the p-stable semantics, which can be defined in terms of paraconsistent logics, shares several properties with the stable semantics, but is closer to classical logic. For example, the following program P = {a ← ¬b, a ← b, b ← a} does not have stable models. However, the set {a, b} could be considered the intended model for P in classical logic. In fact, it is the only p-stable model of P .</p><p>In <ref type="bibr" target="#b20">[18]</ref>, a schema for the implementation of the p-stable semantic using two well known open source tools: Lparse and Minisat is described. In <ref type="bibr" target="#b20">[18]</ref>, a prototype<ref type="foot" target="#foot_0">1</ref> written in Java of a tool based on that schema is also presented. In this paper we present an implementation of the p-stable semantics implementation with aim to improve the implementation presented in <ref type="bibr" target="#b20">[18]</ref>, considerable effort has been made in the optimization the code and in the design of the algorithms used, which are theoretically more efficient than those used in <ref type="bibr" target="#b20">[18]</ref>. As this implementation started recently, we have not yet made definitive tests to warrantee that the solver is error-free, nor we can give conclusive comparative tests between our implementation and that on <ref type="bibr" target="#b20">[18]</ref>.</p><p>In the section 2 the basic concepts about the p-stable semantics are introduced, specially the transformations. In the section 3 are presented the algorithms used to apply the transformations. In the section 4 and 5 is explained how to construct the graph of dependencies of the program and how this graph is used to reduce the search space when looking for the p-stable models.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">Background</head><p>In this section, we define some basic concepts in terms of logic programming semantics, including the definitions of the transformations, which are used to simplify a program.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">Syntax</head><p>A signature L is a finite set of elements that we call atoms. A literal is either an atom a, called positive literal, or the negation of an atom ¬a, called negative literal. Given a set of atoms {a 1 , ..., a n }, we write ¬{a 1 , ..., a n } to denote the set of atoms {¬a 1 , ..., ¬a n }. A normal clause or normal rule, r, is a clause of the form a ← b 1 , . . . , b n , ¬b n+1 , . . . , ¬b n+m .</p><p>where a and each of the b i are atoms for 1 ≤ i ≤ n + m, and the commas mean logical conjunction. In a slight abuse of notation we will denote such a clause by the formula a ← B + (r) ∪ ¬B − (r) where the set {b 1 , . . . , b n } will be denoted by B + (r), the set {b n+1 , . . . , b n+m } will be denoted by B − (r), and B + (r) ∪ B − (r) denoted by B(r). We use H(r) to denote a, called the head of r. We define a normal program P , as a finite set of normal clauses. If for a normal clause r, B(r) = ∅, H(r) is known as a fact . We write L P , to denote the set of atoms that appear in the clauses of P .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Semantics</head><p>From now on, we assume that the reader is familiar with the single notion of minimal model <ref type="bibr" target="#b10">[8]</ref>. In order to illustrate this basic notion, let P be the normal program {a ← ¬b., b ← ¬a., a ← ¬c., c ← ¬a.}. As we can see, P has five models: {a}, {b, c}, {a, c}, {a, b}, {a, b, c}; however, P has just two minimal models: {b, c}, {a}. We will denote by M M (P ) the set of all the minimal models of a given logic program P . Usually M M is called minimal model semantics. Now we give the definition of p-stable model semantics for normal programs.</p><p>Definition 1. <ref type="bibr" target="#b21">[19]</ref> Let P be a normal program and M be a set of atoms. We define the reduction of P with respect to M as RED(P, We say that two normal programs P and P are equivalent if and only if they have the same set of p-stable models, this relation is denoted by P ≡ P . An important theorem relating the p-stable and minimal models is the following. Theorem 1. <ref type="bibr" target="#b16">[14]</ref> Let P be a normal program. If M ∈ P S(P ) then M ∈ MM(P ).</p><formula xml:id="formula_0">M ) = {a ← B + ∪¬(B − ∩ M )|a ← B + ∪ ¬B − ∈ P }.</formula></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.3">Transformations preserving equivalence</head><p>The main purpose of the transformations presented in this section is to simplify the input normal program, reducing its size. What allows the use of those transformations under the p-stable semantics are the propositions proved in <ref type="bibr" target="#b19">[17,</ref><ref type="bibr">4]</ref> about equivalence of normal programs under these transformations. Let P be a normal program, the definition of the transformations SUB, TAUT, RED − , RED + , SUCC, LOOP, NAF and EQUIV when applied to P is as follows Proposition 1. <ref type="bibr" target="#b19">[17,</ref><ref type="bibr">4]</ref> Let P be a normal program, and let P be the resulting program from the application to P of any of the transformations SUB, TAUT, EQUIV, SUCC, RED + , RED − , NAF or LOOP. Then P ≡ P .</p><formula xml:id="formula_1">1. SUB(P ) = P \ {r } ⇐⇒ r ∈ P , ∃r ∈ P : r = r , B − (r ) ⊆ B − (r ), B + (r ) ⊆ B + (r ), H(r) = H(r ). 2. TAUT(P ) = P \ {r } ⇐⇒ r ∈ P , H(r ) ∈ B + (r ). 3. EQUIV(P ) = (P \ {r }) ∪ {r} ⇐⇒ r ∈ P, H(r ) ∈ B − (r ), B − (r) = B − (r ) \ {H(r )}, B + (r) = B + (r ), H(r) = H(r ). 4. SUCC(P ) = (P \ {r }) ∪ {r} ⇐⇒ r ∈ P, B − (r) = B − (r ), H(r) = H(r ),</formula></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">Computing the p-stable models</head><p>Now we present the implementation of a p-stable model solver. To find the p-stable models of a program P we can first apply the transformations to P , however the application of the transformations is not absolutely necessary nor sufficient to find the p-stable models of P . In this section we start presenting the implementation of the application of the transformations, and then we give three approaches to find the p-stable models of P , one that follows from the theorem 1, and the others from the theorem 2 which is also presented in this section.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Implementing the transformations</head><p>Given a program P as input to the p-stable solver, we associate to each atom a ∈ L P three sets that are used for the application of the transformations, those sets are initialized as follows, With the information in those sets it is efficient the application of some transformations, because it is avoided the use of a search algorithm, for example, it will not be necessary to search through all the program P when we require all the rules whose head is a particular atom a. Each atom a ∈ L P also has associated a variable state(a), which can hold one of the following values (we refer to this variable as the state of a): if state(a) = state f act then a is a fact, if state(a) = state no f act then a can not be a fact, if state undef ined then we can not tell yet if a is or can not be a fact. The application of the transformations TAUT and EQUIV is easily implemented, and in this paper we do not write the algorithms that apply those transformations. The transformations SUCC, RED + , RED − , NAF and a particular case of SUB are applied iteratively by the algorithm transf ormations iterated(...). This particular version of SUB consists in deleting the rules whose head is a fact. For the general case of SUB it is necessary to check for set inclusion between the bodies of all pairs of rules with the same head, some of our experimental implementations showed that it was very inefficient and in most cases only a few rules were deleted. The LOOP transform was implemented using the Dowling-Gallier algorithm <ref type="bibr" target="#b7">[5]</ref> (which finds the unique minimal model of a positive program in linear time) it is presented in the LOOP (...) algorithm. Also a watched variables scheme <ref type="bibr" target="#b11">[9]</ref> might be used, this technique is effective in some cases when the deletion of atoms from rules needs to be continuously undone, but at this stage we do not need undo any changes.</p><p>For the algorithm transf ormations iterated(...) we need two lists (see the algorithm at the end of the paper), they are Lp and Lf , which have to be initialized before calling to transf ormations iterated(...). Lp is initialized with the atoms that are facts, then for all a ∈ Lp it is assigned state(a) = state f act. Lf initialized with the atoms a such that there is no rule with head a, then for all a ∈ Lf it is assigned state(a) = state no f act. In transf ormations iterated(...) the auxiliary algorithms remove rule(r) and remove atom f rom rule(a, r, B) are used. remove rule(r) removes the rule r and if all the rules with head H(r) have been removed, set state(H(r)) = state no f act and add a to Lf . remove atom f rom rule(a, r, B) removes the atom a from B, where B = B + (r) or B = B − (r), if after removing a from B, |B| = 0, then set state(H(r)) = state f act and add a to Lp</p><p>In the next example we illustrate how the algorithm transf ormations iterated(...) behaves with the program P as input Before starting the transf ormations iterated(...) algorithm, the EQUIV and TAUT transformations are applied obtaining Π 1 (this is an optional step), also Lp and Lf have to be initialized. Then we call transf ormations iterated(Π 1 ). In the first iteration d is removed from Lf , we apply NAF and RED + until d do not appear in the program, obtaining Π 2 . In the second iteration remove b from Lp then apply SUB by removing all the rules whose head is b, then SUCC and RED − are applied until b do not appear in the program, obtaining Π 3 . In the third iteration remove c from Lf , and apply NAF and RED + until c do not appear in the program obtaining Π 4 . In the fourth iteration remove a from Lf , and apply NAF and RED + until a do not appear in the program obtaining Π 5 . At this point Lp and Lf are empty making the algorithm stop.</p><p>During the execution of transf ormations iterated(P ) have been removed all the rules whose head is a fact, including the rules r for which B(r) = ∅, which are precisely the rules that indicate that H(r) is a fact, it does not represent any problem because we can recover the atoms that are facts just by gathering the atoms whose state is state f act. As the transformations applied preserve equivalence, P ≡ Π 5 ∪ {b ←}, we added the rule b ← to Π 5 because state(b) = state f act. The state of all the atoms that were added to Lp was set to state f act (in this case {b}), and the state of the atoms that were added to Lf was set to state no f act ({d, a, c}), it means that b must be in all the p-stable models of P and {d, a, c} can not be in any.</p><p>It is not hard to see that after the application of this algorithm we can no longer apply SUCC, RED − , RED + or NAF.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">The graph of dependencies</head><p>In most cases the application of the transformations is not enough to find a p-stable model of a normal program, and other techniques are required. One of those techniques is to partition the program into sets of rules called modules. Those modules are created based on its graph of dependencies. Before explaining this technique in detail we give the next definition Definition 3. A strongly connected component C of a graph G is a subset of nodes of G. C is a maximal set of nodes(maximal respect to inclusion) such that there is a directed cycle in G that contains all the nodes in C.</p><p>When we have the rule a h ← a 1 , a 2 , ..., a m , not a m+1 , not a m+2 , ..., not a n ., a h is dependent of all the a i s, i = 1...n, in a graph this dependencies can be represented with the directed edges (a i , a h ), i = 1, ..., n. The graph of dependencies of a program P represents all the dependencies between the atoms in L P , given by all the rules of P .</p><p>The following definition states the definition of stratification and module of a program P . Definition 4. Let P be a normal program which can be partitioned into the disjoint sets of rules {P 1 , ..., P n }. Let P i , P j ∈ {P 1 , ..., P n }, P i = P j , we say that P i &lt; P j if ∃r ∈ P j : ∃r ∈ P i : H(r ) ∈ B(r), if from this condition we do not conclude that P i &lt; P j or P j &lt; P i then we can choose to hold whether P i &lt; P j or P j &lt; P i as long as the following properties hold. For every X, Y, Z ∈ {P 1 , ..., P n }, the strict partial order relation properties and the totality property hold: Definition 5. Let P be a normal program, C i a strongly connected component of the graph of dependencies of P , and P i the module constructed from C i . We define h(P i , P ) as the atoms which are represented as nodes in C i .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">Computing the p-stable models</head><p>The purpose of this section is to show how to compute the p-stable models of a program, three approaches to find the p-stable models of a program P are presented. One way is a direct application of the theorem 1, it consist in computing the minimal models of P and choosing those which satisfy the definition of p-stable model. By theorem 2 the p-stable models of P can be computed by computing the p-stable models of the modules of P after the application of certain transformations. Theorem 2. <ref type="bibr" target="#b21">[19]</ref> Let P be a normal logic program, and M a model of P with stratification P = P 1 ∪ P 2 , then RED(P, M ) |= M iff RED(P 1 , M 1 ) |= M 1 and RED(P 2 , M 2 ) |= M 2 with P 2 , M 1 , and M 2 defined as follows:</p><formula xml:id="formula_2">M = M 1 ∪ M 2 , M 1 = h(P 1 , P ) ∩ M , M 2 =</formula><p>h(P 2 , P ) ∩ M , and P 2 is obtained by transforming P 2 as follows:</p><p>1. Removing from P 2 the rules r such that</p><formula xml:id="formula_3">B − (r ) ∩ M 1 = ∅ or B + (r ) ∩ (h(P 1 , P ) \ M 1 ) = ∅, obtaining a new program P 2 . 2.</formula><p>For every r ∈ P 2 , removing from B(r) the occurrences of the atoms in h(P 1 , P ), obtaining P 2 .</p><p>In other words M is a p-stable model of P iff M 1 is a p-stable model of P 1 and M 2 is a p-stable model of P 2 , where P 2 is obtained by removing from P 2 the occurrences of the atoms in h(P 1 , P ) according to the theorem 2. If P can be stratified as P = P 1 ∪ ... ∪ P n , n &gt; 2, then P = P 1 ∪ Q with Q = P 2 ∪ ... ∪ P n is also an stratification of P that has only two modules, and then we can apply the theorem 2.</p><p>From theorems 1 and 2, three different approaches to compute the p-stable models of a program P are known. The first approach has been implemented in <ref type="bibr" target="#b20">[18]</ref>. We propose the other two approaches that reduce the search space respecto to the first approach in many practical examples.</p><p>1. From theorem 1, it follows that in order to find the p-stable models of P , we can generate minimal models M ∈ MM(P ) and accept as p-stable models those for which the consequence test RED(P, M ) |= M is true. To implement the consequence test we take advantage of the fact that RED(P, M ) |= M ⇐⇒ RED(P, M ) ∪ {¬M } is unsatisfiable, to test if RED(P, M ) ∪ {¬M } is unsatisfiable it is used a SAT solver, in this case we used MINISAT <ref type="bibr" target="#b0">[1]</ref>, the consequence test is implemented in the algorithm consequence test(...)(not presented here for lack of space). Using this approach the search space to find the p-stable models of P is M M (P ). The computation of the p-stable models following this approach is implemented in new P S(...).</p><p>2. As we have said, if P can be stratified into n modules P = P 1 ∪ ... ∪ P n , then P can also be stratified into two modules P = P 1 ∪ Q, where Q = P 2 ∪ ... ∪ P n , n &gt; 2, and now we can apply the theorem 2 to find the pstable models of P , this approach is based on the fact that Q (obtained from Q according to theorem 2) can be stratified as</p><formula xml:id="formula_4">Q = Q 2 ∪ ... ∪ Q n</formula><p>where Q i , 2 ≤ i ≤ n is obtained by removing from P i the occurrences of L P1 according to theorem 2. If n &gt; 3, to compute the p-stable models of Q , we argument the same way but now instead of P , we have Q with stratification</p><formula xml:id="formula_5">Q = Q 2 ∪ ... ∪ Q n .</formula><p>We can proceed this way whenever we want to compute the p-stable models of a program stratified into more than two modules, when it only has two modules, we just apply the theorem 2. The search space to find all the p-stable models of a program P using this approach is in the worst case M M (P ), but sometime this search space is bigger than in the third approach. The advantage of this approach over the third approach is that it is not necessary to compute the stratification of a module before computing its p-stable models, we compute only once the stratification of P .</p><p>3. Again following the theorem 2, to compute a p-stable model of P with stratification P = P 1 ∪ P 2 (as we have said a program with n modules can also be stratified into two modules), we can compute a p-stable model of P 1 and one p-stable model of P 2 , and if P 2 can be stratified into</p><formula xml:id="formula_6">P 2 = Q 1 ∪ Q 2 ,</formula><p>we can apply again the theorem and compute the p-stable models of Q 1 and Q 2 .</p><p>The difference with the second approach is that in the second approach the stratification is computed only once, and in this approach we compute the stratification with getM odules(...) each time we want to compute a p-stable model of a module. Using this approach the search space is in many cases considerably smaller than M M (P ), this is because the problem of finding the p-stable models of a program is translated into the problem of finding the p-stable models of many small subprograms, the smaller these subprogram, more chances are to reduce the search space. We distinguish between finding the first and the subsequent p-stable models, to find the first p-stable model use the f irst P S recursive(...) algorithm and to find the another p-stable model use next P S recursive(...).</p><p>We illustrate the second approach by finding the p-stable models of the program Π 5 that resulted from the application of the transformations in the example 1. In the graph 1 we see the graph of dependencies of Π 5 , the dotted edges trace maximal cycles, and determine the strongly connected components of Π 5 .</p><p>We encounter the two p-stable models of P 2 , {{x, u}, {x, v}}, from which we find another two p-stable models of Π 5 , {{t, x, u}, {t, x, v}}. When trying to generate another p-stable model of P 2 we can not find any so we go to P 1 , and can not find another p-stable model of P 1 so we stop. We end up with the four pstable models of Π 5 , PS(Π 5 ) = {{t, x, u}, {t, x, v}, {r, v, z}, {r, u}}. Recall form the example 1 that b was found to be a fact after the application of the transformations to P , for instance PS(P ) = {{b, t, x, u}, {b, t, x, v}, {b, r, v, z}, {b, r, u}}.</p><p>When using the third approach, we stratify Π 5 into Π 5 = P 1 ∪ P 2 as in the second approach, but after obtaining P 2 , try to stratify P 2 , we can see in the graph of dependencies of P 2 (graph 2), that P 2 can be stratified into two modules, so P 2 is stratified into P 2 = Q 1 ∪Q 2 which can be seen in the next figure</p><formula xml:id="formula_7">Q 1 ={ r 1 : u ← not v. r 2 : v ← not u.} Q 2 = { r 4 : x ← y. r 5 : y ← not x, z, not v. r 8 : z ← not u, not x.} Q 2 ={ r 4 : x ← y. r 8 : z ← not x.} R 1 ={} R 2 ={x ← y.} R 3 ={z ← not x.} R 2 ={} R 3 ={z ←.}</formula><p>Applying again the theorem 2, first choose a minimal model of Q 1 , {v} and when doing the consequence test we find that {v} is a p-stable model of Q</p><formula xml:id="formula_8">1 . Now obtain Q 2 (see the anterior figure) which is further partitioned into Q 2 = R 1 ∪ R 2 ∪ R 3 which</formula><p>are respectively the sets of rules with head y, x and z. Then compute a p-stable model of R 1 , the only p-stable model of R 1 is the empty set, R 2 is also empty and also has an empty p-stable model. R 3 (obtained by removing from R 3 the occurrences of L R1 and L R2 ) only has an empty rule z ← and its unique p-stable model is {z}. Merging the p-stable model of the modules P 1 , Q 1 , R 1 , R 2 and R 3 we get a p-stable model of Π 5 , it is {r} ∪ {v} ∪ {} ∪ {} ∪ {z} = {r, v, z}. When trying to generate another p-stable model, first we try to generate another p-stable model of R 3 , it does not have more p-stable models, thus we go back and try on R 2 but it has neither, then try on R 1 that has no more p-stable models, finally we find that Q 1 has another p-stable model, {u}, from this point, to find the other p-stable models of Π 5 , we proceed as we did when we had {v} as a p-stable model of Q 1 .</p><p>To show the performance of each approach we use some examples in <ref type="bibr">[2]</ref>. In the next table we can see the time in seconds it took to find a p-stable model of some of those examples using each of the three approaches. A "-" character means that we stopped the execution after 10 seconds. In the fifth column is the time to find a stable model by smodels. The sixth and seventh columns show the number of atoms and rules of each test program. In the last column is the number of modules in which the program was initially partitioned. It is worth to mention that if we modify the consequence test(...) such that it always return true, instead of using tranf ormations iterated(...) we apply some similar reductions (see <ref type="bibr" target="#b12">[10]</ref>), and if all the tautological rules like a ← b, not b, c are removed, then we end up with a stratified minimal model solver, a detailed description of our stratified minimal model semantics solver can be found in <ref type="bibr" target="#b12">[10]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">Conclusions and future work</head><p>Some preliminary tests to the p-stable solver presented in this paper, shows a bad performance respect to a stable semantics solver(smodels <ref type="bibr" target="#b13">[11]</ref>), for big programs, due to the backtracking driven by the failure of the consequence test, one of the inconveniences of this implementation is that the search space is very big for some programs, research is needed to develop algorithms that reduce the search space or heuristics that show a good performance for some classes of programs.</p></div><figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_0"><head>Definition 2 .</head><label>2</label><figDesc><ref type="bibr" target="#b21">[19]</ref> A set of atoms M is a p-stable model of a normal program P iff RED(P, M ) |= M , where the symbol |= means logical consequence under classical logic semantics. The set of p-stable models of P is denoted by P S(P ).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_1"><head></head><label></label><figDesc>∃r ∈ P : B(r ) = ∅, H(r ) ∈ B + (r ), B + (r) = B + (r ) \ {H(r )}. 5. RED + (P ) = (P \ {r }) ∪ {r} ⇐⇒ r ∈ P, B + (r) = B + (r ), H(r) = H(r ), ∃a ∈ LP : a ∈ B − (r ), B − (r) = B − (r ) \ {a}, ∃r ∈ P : H(r ) = a. 6. RED − (P ) = P \ {r } ⇐⇒ r ∈ P, ∃r ∈ P : B(r ) = ∅, H(r ) ∈ B − (r ). 7. NAF(P ) = P \ {r } ⇐⇒ r ∈ P, ∃a ∈ LP : a ∈ B + (r ), ∃r ∈ P : H(r ) = a. 8. LOOP(P ) = {r : r ∈ P, B + (r ) ⊆ M }, where M is the unique minimal model of MM(POS(P )). The definition of POS(P ) is given by POS(P ) = {r : B − (r ) = ∅, ∃r ∈ P : B + (r) = B + (r ), H(r) = H(r )}.</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_2"><head>1 .</head><label>1</label><figDesc>H(a) = {r : r ∈ P, H(r) = a}. 2. P (a) = {r : a ∈ P, B + (r)}. 3. N (a) = {r : a ∈ P, B − (r)}.</figDesc></figure>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0">http://cxjepa.googlepages.com/home</note>
		</body>
		<back>
			<div type="annex">
<div xmlns="http://www.tei-c.org/ns/1.0"><p>Example 1. Example of the execution of transf ormations iterated P ={ r1 : u ← not v. r2 : v ← not u. r3 : u ← not r, not x, b. r4 : x ← y, r, not c. r5 : y ← not x, z, not v. r6 : x ← not z, t, not d. r7 : z ← t, v. r8 : z ← r, not u, not x. r9 : r ← not t, not a. r10 : t ← not r, b. r11 : a ← not a, c. r12 : b ← not d. r13 : d ← c, d. r14 : c ← not a, b, d, z. r15 : c ← not b, a, x. r16 : b ← not a, not u.} Π1 ={ r1 : u ← not v. r2 : v ← not u. r3 : u ← not r, not x, b. r4 : x ← y, r, not c. r5 : y ← not x, z, not v. r6 : x ← not z, t, not d. r7 : z ← t, v. r8 : z ← r, not u, not x. r9 : r ← not t, not a. r10 : t ← not r, b. r11 : a ← c. r12</p><p>Based on the graph of dependencies of Π 5 (graph 1), we see that Π 5 can be stratified into two modules Π 5 = P 1 ∪ P 2 . To compute a p-stable model of Π 5 we start by finding a p-stable model of P 1 , in this case we found {r} to be a p-stable model of P 1 . Then compute P 2 by removing the occurrences of the atoms r and t from P 2 according to the theorem 2, in the next figure you can see P 1 , P 2 and</p><p>Then find a minimal model of P 2 and do the consequence test, a minimal model of P 2 is {v, x}, but when doing the consequence test we find that RED(P 2 , {v, x}) ∪ {¬{v, x}} = RED(P 2 , {v, x}) ∪ {¬v ∨ ¬x} is satisfiable, thus {v, x} is not a p-stable model of P 2 . We generate another minimal model of P 2 , {v, z}, this time RED(P 2 , {v, z}) ∪ {¬v ∨ ¬z} is unsatisfiable and {v, z} is accepted as a p-stable model of P 2 . Merging the p-stable model of P 1 and the p-stable model of P 2 we obtain a p-stable of Π 5 , {r, v, z}. To look for another p-stable model of Π 5 , we start by looking for another p-stable model of P 2 , we find that {u} is a p-stable model of P 2 , for instance another p-stable model of Π 5 is {r, u}. Again we try to generate another p-stable model of P 2 , but we note that all the p-stable models of P 2 have been generated (all M ∈ M M (P 2 ) have been computed), then we go to the anterior module(P 1 ) and try to generate another p-stable model of P 1 , we find that {t} is another p-stable model of P 1 , then compute P 2 again : {solver is a MINISAT solver associated to P , IDS(a) is the integer that represents the atoms a in solver, when solver = N U LL no models of P have been computed}  </p></div>			</div>
			<div type="references">

				<listBibl>

<biblStruct xml:id="b0">
	<monogr>
		<title level="m">X &lt; X is false (this property holds trivially</title>
				<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b1">
	<monogr>
		<author>
			<persName><surname>Then</surname></persName>
		</author>
		<idno>If X &lt;</idno>
		<title level="m">Y &lt; X is false</title>
				<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b2">
	<monogr>
		<title/>
		<author>
			<persName><forename type="first">Y</forename></persName>
		</author>
		<author>
			<persName><forename type="first">Y</forename><surname>&lt; Z) Then</surname></persName>
		</author>
		<author>
			<persName><forename type="first">X</forename></persName>
		</author>
		<author>
			<persName><forename type="first">Z</forename></persName>
		</author>
		<idno>X &lt;</idno>
		<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b3">
	<analytic>
		<title level="a" type="main">cause there exists a well known algorithm</title>
	</analytic>
	<monogr>
		<title level="m">C n of strongly connected components of the graph of dependencies of P , from which we can construct a stratification of P , P = P 1 ∪</title>
				<imprint/>
	</monogr>
	<note>where P i = {r : r ∈ P, H(r) ∈ C i }, 1 ≤ i ≤ n. Now we define h(P i , P ) References 1</note>
</biblStruct>

<biblStruct xml:id="b4">
	<monogr>
		<title level="m" type="main">Knowledge representation, reasoning and declarative problem solving</title>
		<author>
			<persName><forename type="first">Chitta</forename><surname>Baral</surname></persName>
		</author>
		<ptr target="http://www.baral.us/bookone/code/smodels.html" />
		<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b5">
	<analytic>
		<title level="a" type="main">Inferring preferred extensions by pstable semantics</title>
		<author>
			<persName><forename type="first">J</forename><surname>Carballido</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><forename type="middle">C</forename><surname>Nieves</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Osorio</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Accepted in Revista Iberomericana de Inteligencia Artificial</title>
		<imprint>
			<date type="published" when="2008">2008</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b6">
	<monogr>
		<title/>
		<author>
			<persName><forename type="first">J</forename><forename type="middle">L</forename><surname>Carballido</surname></persName>
		</author>
		<imprint>
			<date type="published" when="2008">2008</date>
		</imprint>
		<respStmt>
			<orgName>BUAP</orgName>
		</respStmt>
	</monogr>
	<note type="report_type">PhD thesis</note>
</biblStruct>

<biblStruct xml:id="b7">
	<analytic>
		<title level="a" type="main">Linear time algorithm for testing the satisfiability of propositional horn formulae</title>
		<author>
			<persName><forename type="first">W</forename><forename type="middle">F</forename><surname>Dowling</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><forename type="middle">H</forename><surname>Gallier</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Journal of logic programming</title>
		<imprint>
			<date type="published" when="1984">1984</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b8">
	<analytic>
		<title level="a" type="main">On the acceptability of arguments and its fundamental role in nonmonotonic reasoning, logic programming and n-person games</title>
		<author>
			<persName><forename type="first">Phan</forename><surname>Minh</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Dung</forename></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Artificial Intelligence</title>
		<imprint>
			<biblScope unit="volume">77</biblScope>
			<biblScope unit="issue">2</biblScope>
			<biblScope unit="page" from="321" to="358" />
			<date type="published" when="1995">1995</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b9">
	<analytic>
		<title level="a" type="main">The Stable Model Semantics for Logic Programming</title>
		<author>
			<persName><forename type="first">Michael</forename><surname>Gelfond</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Vladimir</forename><surname>Lifschitz</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">5th Conference on Logic Programming</title>
				<editor>
			<persName><forename type="first">R</forename><surname>Kowalski</surname></persName>
		</editor>
		<editor>
			<persName><forename type="first">K</forename><surname>Bowen</surname></persName>
		</editor>
		<imprint>
			<publisher>MIT Press</publisher>
			<date type="published" when="1988">1988</date>
			<biblScope unit="page" from="1070" to="1080" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b10">
	<monogr>
		<title level="m" type="main">Foundations of Logic Programming</title>
		<author>
			<persName><forename type="first">John</forename><forename type="middle">W</forename><surname>Lloyd</surname></persName>
		</author>
		<imprint>
			<date type="published" when="1987">1987</date>
			<publisher>Springer</publisher>
			<pubPlace>Berlin</pubPlace>
		</imprint>
	</monogr>
	<note>second edition</note>
</biblStruct>

<biblStruct xml:id="b11">
	<analytic>
		<title level="a" type="main">Chaff: Engineering an efficient sat solver</title>
		<author>
			<persName><forename type="first">Yuting</forename><surname>Zhao</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Lintao</forename><surname>Zhang</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Matthew</forename><forename type="middle">H</forename><surname>Moskewicz</surname></persName>
		</author>
		<author>
			<persName><forename type="first">F</forename><surname>Conor</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Sharad</forename><surname>Madigan</surname></persName>
		</author>
		<author>
			<persName><surname>Malik</surname></persName>
		</author>
		<author>
			<persName><surname>Chaff</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">DAC 01: Proceedings of the 38th Conference on Design Automation</title>
				<meeting><address><addrLine>Las Vegas, NV, USA</addrLine></address></meeting>
		<imprint>
			<date type="published" when="2001-06">June 2001. 2001</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b12">
	<monogr>
		<author>
			<persName><forename type="first">Angel</forename><surname>Marin</surname></persName>
		</author>
		<author>
			<persName><forename type="first">George</forename><forename type="middle">Mauricio</forename><surname>Osorio</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Juan</forename><forename type="middle">Carlos</forename><surname>Nieves</surname></persName>
		</author>
		<title level="m">Computing the stratified minimal models semantic</title>
				<imprint>
			<date type="published" when="2009">2009</date>
		</imprint>
	</monogr>
	<note>unpublished</note>
</biblStruct>

<biblStruct xml:id="b13">
	<analytic>
		<title level="a" type="main">Smodels -an implementation of the stable model and well-founded semantics for normal logic programs</title>
		<author>
			<persName><forename type="first">Ilkka</forename><surname>Niemela</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Patrik</forename><surname>Simons</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="s">Lecture Notes in Artificial Intelligence (LNCS</title>
		<imprint>
			<biblScope unit="volume">1265</biblScope>
			<biblScope unit="page" from="420" to="429" />
			<date type="published" when="1997">1997</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b14">
	<analytic>
		<title level="a" type="main">Logical weak completions of paraconsistent logics</title>
		<author>
			<persName><forename type="first">Mauricio</forename><surname>Osorio</surname></persName>
		</author>
		<author>
			<persName><forename type="first">José</forename><surname>Arrazola</surname></persName>
		</author>
		<author>
			<persName><forename type="first">José</forename><surname>Luis</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Carballido</forename></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Journal of Logic and Computation</title>
		<imprint>
			<date type="published" when="2008-05-09">May 9, 2008</date>
		</imprint>
	</monogr>
	<note>Published on line on</note>
</biblStruct>

<biblStruct xml:id="b15">
	<analytic>
		<title level="a" type="main">Brief study of G&apos;3 logic</title>
		<author>
			<persName><forename type="first">Mauricio</forename><surname>Osorio</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Jose</forename><surname>Luis</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Carballido</forename></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Journal of Applied Non-Classical Logic</title>
		<imprint>
			<biblScope unit="volume">18</biblScope>
			<biblScope unit="issue">4</biblScope>
			<biblScope unit="page" from="79" to="103" />
			<date type="published" when="2009">2009</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b16">
	<analytic>
		<title level="a" type="main">Logics with common weak completions</title>
		<author>
			<persName><forename type="first">Mauricio</forename><surname>Osorio</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Juan</forename><forename type="middle">Antonio</forename><surname>Navarro</surname></persName>
		</author>
		<author>
			<persName><forename type="first">José</forename><surname>Arrazola</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Verónica</forename><surname>Borja</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Journal of Logic and Computation</title>
		<imprint>
			<biblScope unit="volume">16</biblScope>
			<biblScope unit="issue">6</biblScope>
			<biblScope unit="page" from="867" to="890" />
			<date type="published" when="2006">2006</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b17">
	<analytic>
		<title level="a" type="main">Update sequences based on minimal generalized pstable models</title>
		<author>
			<persName><forename type="first">Mauricio</forename><surname>Osorio</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Claudia</forename><surname>Zepeda</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">MICAI</title>
				<imprint>
			<date type="published" when="2007">2007</date>
			<biblScope unit="page" from="283" to="293" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b18">
	<analytic>
		<title level="a" type="main">Pstable theories and preferences</title>
		<author>
			<persName><forename type="first">Mauricio</forename><surname>Osorio</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Claudia</forename><surname>Zepeda</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Electronic Proceedings of the 18th International Conference on Electronics, Communications, and Computers</title>
				<meeting><address><addrLine>CONIELECOMP</addrLine></address></meeting>
		<imprint>
			<date type="published" when="2008-03">2008. March, 2008</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b19">
	<monogr>
		<title level="m" type="main">Syntactic transformation rules under p-stable semantics: theory and implementation</title>
		<author>
			<persName><forename type="first">S</forename><surname>Pascucci</surname></persName>
		</author>
		<author>
			<persName><forename type="first">A</forename><surname>Lopez</surname></persName>
		</author>
		<imprint>
			<date type="published" when="2009">2009</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b20">
	<analytic>
		<title level="a" type="main">Implementing p-stable with simplification capabilities</title>
		<author>
			<persName><forename type="first">S</forename><surname>Pascucci</surname></persName>
		</author>
		<author>
			<persName><forename type="first">A</forename><surname>Lopez</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Submmited to Inteligencia Artificial</title>
				<meeting><address><addrLine>A., Spain</addrLine></address></meeting>
		<imprint>
			<date type="published" when="2008">2008</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b21">
	<monogr>
		<title level="m" type="main">Syntactic properties of normal logic program under pstable semantics: theory and implementation</title>
		<author>
			<persName><forename type="first">Simone</forename><surname>Pascucci</surname></persName>
		</author>
		<imprint>
			<date type="published" when="2009-03">March 2009</date>
		</imprint>
	</monogr>
	<note type="report_type">Master&apos;s thesis</note>
</biblStruct>

<biblStruct xml:id="b22">
	<analytic>
		<title level="a" type="main">Stable Inference as Intuitionistic Validity</title>
		<author>
			<persName><forename type="first">David</forename><surname>Pearce</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Logic Programming</title>
		<imprint>
			<biblScope unit="volume">38</biblScope>
			<biblScope unit="page" from="79" to="91" />
			<date type="published" when="1999">1999</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b23">
	<monogr>
		<title/>
		<author>
			<persName><forename type="first">Thomas</forename><forename type="middle">H</forename><surname>Clifford Stain</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Charles</forename><forename type="middle">E</forename><surname>Cormen</surname></persName>
		</author>
		<author>
			<persName><forename type="first">L</forename><surname>Leiserson Ronald</surname></persName>
		</author>
		<author>
			<persName><surname>Rivest</surname></persName>
		</author>
		<imprint/>
	</monogr>
</biblStruct>

<biblStruct xml:id="b24">
	<analytic>
		<title level="a" type="main">The well-founded semantics for general logic programs</title>
		<author>
			<persName><forename type="first">Kenneth</forename><forename type="middle">A</forename><surname>Allen Van Gelder</surname></persName>
		</author>
		<author>
			<persName><forename type="first">John</forename><forename type="middle">S</forename><surname>Ross</surname></persName>
		</author>
		<author>
			<persName><surname>Schlipf</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Journal of the ACM</title>
		<imprint>
			<biblScope unit="volume">38</biblScope>
			<biblScope unit="page" from="620" to="650" />
			<date type="published" when="1991">1991</date>
		</imprint>
	</monogr>
</biblStruct>

				</listBibl>
			</div>
		</back>
	</text>
</TEI>
