01: /*
02: * Copyright (C) 1999-2004 <a href="Hans-Henning.Wiesner@bauer-partner.com">Hans-Henning Wiesner</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package test.org.mandarax.reference;
20:
21: import org.mandarax.kernel.InferenceEngine;
22: import org.mandarax.kernel.KnowledgeBase;
23: import org.mandarax.kernel.Predicate;
24: import org.mandarax.kernel.Query;
25: import org.mandarax.kernel.SimplePredicate;
26:
27: /**
28: * Simple NAF test to show strange behavior.
29: * @author <A HREF="mailto:Hans-Henning.Wiesner@bauer-partner.com">Hans-Henning Wiesner</A>
30: * @version 3.4 <7 March 05>
31: * @since 2.2.1
32: */
33: public class TestInferenceEngineNAF8 extends TestInferenceEngineNAF {
34: protected static final Class[] structExtended = { String.class,
35: String.class };
36: protected static final Predicate Pextended = new SimplePredicate(
37: "Pextended", structExtended);
38:
39: /**
40: * Constructor.
41: * @param aKnowledgeBase a new, uninitialized knowledge base that will be used
42: * @param anInferenceEngine the inference engine that will be tested
43: */
44: public TestInferenceEngineNAF8(KnowledgeBase aKnowledgeBase,
45: InferenceEngine anInferenceEngine) {
46: super (aKnowledgeBase, anInferenceEngine);
47: }
48:
49: /**
50: * Add facts and rules to the knowledge base.
51: *
52: * Compare these settings with TestInferenceEngineNAF3.
53: * Threre is expected nothing. Here is retrieved R(a).
54: *
55: * @param knowledge org.mandarax.kernel.KnowledgeBase
56: */
57: public void feedKnowledgeBase(KnowledgeBase knowledge) {
58: knowledge.removeAll();
59:
60: knowledge.add(lfs.rule(lfs.prereq(Pextended, lfs.cons("A",
61: String.class), lfs.variable("x"), true), lfs.prereq(
62: Pextended, lfs.cons("B", String.class), lfs
63: .variable("x"), false), lfs.fact(R, lfs
64: .variable("x"))));
65:
66: knowledge.add(lfs.fact(Pextended, "A", "a"));
67: knowledge.add(lfs.fact(Pextended, "B", "a"));
68: }
69:
70: /**
71: * Get a description of this test case.
72: * This is used by the <code>org.mandarax.demo</code>
73: * package to display the test cases.
74: * @return a brief description of the test case
75: */
76: public String getDescription() {
77: return "Test for NAF";
78: }
79:
80: /**
81: * Get the expected result.
82: * @return a string
83: */
84: public String getExpected() {
85: return null;
86: }
87:
88: /**
89: * Get the query.
90: * @return a query
91: */
92: public Query getQuery() {
93: return lfs.query(lfs.fact(R, lfs.variable(QUERY_VARIABLE)),
94: "?R(x)");
95: }
96: }
|