use of fr.lirmm.graphik.graal.io.dlp.DlgpParser in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testIsConsistentFalse.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#isConsistent()}.
* @throws KnowledgeBaseException
* @throws AtomSetException
*/
@Test
public void testIsConsistentFalse() throws KnowledgeBaseException, AtomSetException {
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("[R] p(X) :- q(X). q(a). [NC] ! :- q(X), p(X)."));
Assert.assertFalse(kb.isConsistent());
kb.close();
}
use of fr.lirmm.graphik.graal.io.dlp.DlgpParser in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testDefaultKnowledgeBaseParserOfObject.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#DefaultKnowledgeBase(fr.lirmm.graphik.graal.api.io.Parser)}.
*
* @throws ParseException
* @throws AtomSetException
*/
@Test
public void testDefaultKnowledgeBaseParserOfObject() throws ParseException, AtomSetException {
Atom aa = DlgpParser.parseAtom("q(a).");
Atom ab = DlgpParser.parseAtom("q(b).");
Atom ac = DlgpParser.parseAtom("q(c).");
Rule r = DlgpParser.parseRule("[R] p(X) :- q(X).");
NegativeConstraint nc = DlgpParser.parseNegativeConstraint("[NC] ! :- q(X), p(X).");
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("[R] p(X) :- q(X). q(a), q(b). q(c). [NC] ! :- q(X), p(X)."));
Assert.assertTrue(kb.getOntology().contains(r));
Assert.assertTrue(kb.getOntology().contains(nc));
Assert.assertTrue(kb.getFacts().contains(aa));
Assert.assertTrue(kb.getFacts().contains(ab));
Assert.assertTrue(kb.getFacts().contains(ac));
kb.close();
}
use of fr.lirmm.graphik.graal.io.dlp.DlgpParser in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testIsConsistentFalse2.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#isConsistent()}.
* @throws KnowledgeBaseException
* @throws AtomSetException
* @throws KBBuilderException
*/
@Test
public void testIsConsistentFalse2() throws KnowledgeBaseException, AtomSetException, KBBuilderException {
KBBuilder kbb = new KBBuilder();
kbb.addAll(new DlgpParser("q2(X) :- q(X). pr(X) :- p(X), r(X). q(a), p(a), r(a). [NC] ! :- q2(X), pr(X)."));
kbb.setApproach(Approach.REWRITING_FIRST);
KnowledgeBase kb = kbb.build();
Assert.assertFalse(kb.isConsistent());
kb.close();
}
use of fr.lirmm.graphik.graal.io.dlp.DlgpParser in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testIsConsistentTrue.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#isConsistent()}.
*/
@Test
public void testIsConsistentTrue() throws KnowledgeBaseException, AtomSetException {
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("[R] p(X) :- q(X). p(a). [NC] ! :- q(X), p(X)."));
Assert.assertTrue(kb.isConsistent());
kb.close();
}
use of fr.lirmm.graphik.graal.io.dlp.DlgpParser in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testSaturate.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#saturate()}.
* @throws AtomSetException
* @throws ParseException
* @throws KnowledgeBaseException
*/
@Test
public void testSaturate() throws ParseException, AtomSetException, KnowledgeBaseException {
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("p(X) :- q(X). q(X) :- r(X). r(X) :- s(X). s(a)."));
kb.saturate();
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("r(a).")));
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("q(a).")));
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("p(a).")));
kb.close();
}
Aggregations