Skip to content

Commit 0149ae9

Browse files
author
magicindian
committed
Test and fix for bug in PLResolution (reported by Huy Dinh)
1 parent 0be05fc commit 0149ae9

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

ReadMe.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ The official release can be found at http://aima.cs.berkeley.edu/java-overview.h
1616
The following people sent in excellent comments and bug reports.
1717
Thank you all
1818

19+
Huy Dinh, for reporting a prticularly insidious bog in the Logic code
1920

20-
Carl Anderson Senior Scientist, ArchimedesModel.com (suggested making heuristic values double instead of int. Excellent suggestion! Than You!)
21+
Carl Anderson Senior Scientist, ArchimedesModel.com (suggested making heuristic values double instead of int. Excellent suggestion! Thank You!)
2122

2223
Don Cochrane from (?) University
2324

2425
Mike Angelotti from Miami University
2526

2627
Chad Carff ,University of Western Florida . EXCELLENT test cases . thank you .
2728

28-
Dr .Eman El-Sheikh, Ph.D.,University of Western Florida
29+
Dr. Eman El-Sheikh, Ph.D.,University of Western Florida
2930

3031
Ravindra Guravannavar, Aztec Software,Bangalore
3132

src/aima/logic/propositional/algorithms/PLResolution.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public boolean plResolution(KnowledgeBase kb, Sentence alpha) {
5050
List<Sentence> pair = pairs.get(i);
5151
// System.out.println("pair number" + i+" of "+pairs.size());
5252
Set<Sentence> resolvents = plResolve(pair.get(0), pair.get(1));
53+
resolvents = filterOutClausesWithTwoComplementaryLiterals(resolvents);
54+
5355
if (resolvents.contains(new Symbol("EMPTY_CLAUSE"))) {
5456
return true;
5557
}

src/aima/test/logictest/prop/algorithms/PLResolutionTest.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Set;
88

99
import junit.framework.TestCase;
10+
import aima.logic.propositional.algorithms.KnowledgeBase;
1011
import aima.logic.propositional.algorithms.PLResolution;
1112
import aima.logic.propositional.parsing.PEParser;
1213
import aima.logic.propositional.parsing.ast.Sentence;
@@ -95,8 +96,18 @@ public void testPLResolve5() {
9596
assertEquals(false, b);
9697
}
9798

98-
// public void testPLResolutionWithChadCarfBugReportData(){
99-
// //commented out coz too slow..
99+
public void testMultipleClauseResolution() {
100+
// test (and fix) suggested by Huy Dinh. Thanks Huy!
101+
PLResolution plr = new PLResolution();
102+
KnowledgeBase kb = new KnowledgeBase();
103+
String fact = "((B11 <=> (P12 OR P21)) AND (NOT B11))";
104+
kb.tell(fact);
105+
plr.plResolution(kb, "(B)");
106+
107+
}
108+
109+
// public void testPLResolutionWithChadCarfBugReportData() {
110+
// commented out coz this needs a major fix wait for a rewrite
100111
// KnowledgeBase kb = new KnowledgeBase();
101112
// kb.tell("(B12 <=> (P11 OR (P13 OR (P22 OR P02))))");
102113
// kb.tell("(B21 <=> (P20 OR (P22 OR (P31 OR P11))))");
@@ -106,7 +117,7 @@ public void testPLResolve5() {
106117
// kb.tell("(NOT B12)");
107118
// kb.tell("(B10)");
108119
// kb.tell("(B01)");
109-
// assertTrue(resolution.plResolution(kb.asSentence().toString(),"(P00)"));
120+
// assertTrue(resolution.plResolution(kb.asSentence().toString(), "(P00)"));
110121
// //assertFalse(kb.askWithDpll("(NOT P00)"));
111122
//
112123
//

0 commit comments

Comments
 (0)