public void reset() { _kb = new KnowledgeBaseImpl(); } }
@Override public synchronized void addClass(final ATermAppl c) { super.addClass(c); }
@Override public synchronized boolean addDatatypeProperty(final ATerm p) { return super.addDatatypeProperty(p); }
@Test public void testGetInstances1() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl C = term("C"); final ATermAppl i = term("i"); kb.addClass(C); kb.addIndividual(i); kb.addType(i, C); final Set<ATermAppl> expected = new HashSet<>(); expected.add(i); // Named concept, all instances final Set<ATermAppl> actual = kb.getInstances(C); assertEquals(expected, actual); }
@Test public void topObjectDomain() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl c = term("C"); final ATermAppl x = term("x"); final ATermAppl y = term("y"); final ATermAppl z = term("z"); kb.addClass(c); kb.addIndividual(x); kb.addIndividual(y); kb.addIndividual(z); kb.addDifferent(x, y); kb.addDifferent(x, z); kb.addSubClass(c, oneOf(x, y)); kb.addDomain(TOP_OBJECT_PROPERTY, c); assertTrue(kb.isSameAs(y, z)); }
@Test public void userDefinedDatatypes303a() { final ATermAppl c = TermFactory.term("C"); final ATermAppl v = TermFactory.term("v"); final ATermAppl i = TermFactory.term("i"); final ATermAppl one = TermFactory.literal(1); final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); kb.addClass(c); kb.addDatatypeProperty(v); kb.addIndividual(i); kb.addSubClass(c, TermFactory.min(v, 1, INTEGER)); kb.addRange(v, TermFactory.oneOf(one)); kb.addType(i, c); assertTrue(kb.hasPropertyValue(i, v, one)); }
@Test public void testRuleExplanation() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl C = ATermUtils.makeTermAppl("C"); final ATermAppl D = ATermUtils.makeTermAppl("D"); final ATermAppl i = ATermUtils.makeTermAppl("i"); final List<RuleAtom> body = new ArrayList<>(); final List<RuleAtom> head = new ArrayList<>(); body.add(new ClassAtom(C, new AtomIVariable("x"))); head.add(new ClassAtom(D, new AtomIVariable("x"))); final Rule rule = new Rule(head, body); kb.addClass(C); kb.addClass(D); kb.addIndividual(i); kb.addType(i, C); kb.addRule(rule); kb.setDoExplanation(true); assertTrue(kb.isConsistent()); assertTrue(kb.isType(i, D)); final Set<ATermAppl> actual = kb.getExplanationSet(); kb.setDoExplanation(false); final Set<ATermAppl> expected = new HashSet<>(); final ATermAppl x = ATermUtils.makeVar("x"); final ATermAppl[] b = new ATermAppl[] { ATermUtils.makeTypeAtom(x, C) }; final ATermAppl[] h = new ATermAppl[] { ATermUtils.makeTypeAtom(x, D) }; expected.add(ATermUtils.makeTypeAtom(i, C)); expected.add(ATermUtils.makeRule(h, b)); assertEquals(expected, actual); }
public void testProgresMonitorRealization() final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl E = term("E"); kb.addClass(A); kb.addClass(B); kb.addClass(C); kb.addClass(D); kb.addClass(E); kb.addSubClass(B, A); kb.addSubClass(C, A); kb.addSubClass(D, B); kb.addSubClass(D, C); kb.addSubClass(E, D); kb.addIndividual(i); kb.addType(i, E); kb.addIndividual(j); kb.addType(j, E); kb.setTaxonomyBuilderProgressMonitor(progressMonitor); kb.realize();
@Test public void bottomDataAssertion() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl x = term("x"); final ATermAppl y = literal("y"); kb.addIndividual(x); assertFalse(kb.hasPropertyValue(x, BOTTOM_DATA_PROPERTY, y)); assertTrue(kb.isType(x, not(some(BOTTOM_DATA_PROPERTY, TOP_LIT)))); assertTrue(kb.isType(x, not(hasValue(BOTTOM_DATA_PROPERTY, y)))); kb.addPropertyValue(BOTTOM_DATA_PROPERTY, x, y); assertFalse(kb.isConsistent()); }
@Test public void topObjectDisjoints() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl p = term("p"); final ATermAppl subP = term("subP"); final ATermAppl q = term("q"); kb.addObjectProperty(p); kb.addObjectProperty(subP); kb.addObjectProperty(q); kb.addSubProperty(subP, p); kb.addDisjointProperty(p, q); kb.getRoleTaxonomy(true).getTop().print(); kb.getRoleTaxonomy(false).getTop().print(); assertTrue(kb.isDisjointProperty(BOTTOM_OBJECT_PROPERTY, TOP_OBJECT_PROPERTY)); assertTrue(kb.isDisjointProperty(TOP_OBJECT_PROPERTY, BOTTOM_OBJECT_PROPERTY)); assertEquals(singletonSets(BOTTOM_OBJECT_PROPERTY), kb.getDisjointProperties(TOP_OBJECT_PROPERTY)); assertEquals(singletonSets(BOTTOM_OBJECT_PROPERTY, TOP_OBJECT_PROPERTY, p, subP, q), kb.getDisjointProperties(BOTTOM_OBJECT_PROPERTY)); assertEquals(singletonSets(BOTTOM_OBJECT_PROPERTY, q), kb.getDisjointProperties(p)); assertEquals(singletonSets(BOTTOM_OBJECT_PROPERTY, p, subP), kb.getDisjointProperties(q)); assertEquals(singletonSets(BOTTOM_OBJECT_PROPERTY), kb.getDisjointProperties(TOP_OBJECT_PROPERTY, true)); assertEquals(singletonSets(TOP_OBJECT_PROPERTY), kb.getDisjointProperties(BOTTOM_OBJECT_PROPERTY, true)); assertEquals(singletonSets(q), kb.getDisjointProperties(p, true)); assertEquals(singletonSets(p), kb.getDisjointProperties(q, true)); }
@Test public void topEquivalent() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl p = term("concrete"); final ATermAppl r = term("abstract"); final ATermAppl s = term("universal"); kb.addObjectProperty(p); kb.addObjectProperty(r); kb.addObjectProperty(s); kb.addSubProperty(p, r); kb.addSubProperty(r, s); assertTrue(kb.isSubPropertyOf(p, s)); assertTrue(kb.getSubProperties(s).contains(Collections.singleton(p))); kb.addEquivalentProperty(s, TOP_OBJECT_PROPERTY); assertTrue(kb.isSubPropertyOf(p, s)); assertTrue(kb.getSubProperties(s).contains(Collections.singleton(p))); }
@Before public void setUp() { _kb = new KnowledgeBaseImpl(); _x = new AtomIVariable("x"); _y = new AtomIVariable("y"); _z = new AtomDVariable("z"); _kb.addDatatypeProperty(dp1); _kb.addDatatypeProperty(dp2); _kb.addSubProperty(dp1, dp2); _kb.addIndividual(mary); _kb.addIndividual(robert); _kb.addIndividual(victor); _kb.addPropertyValue(dp1, mary, data1); _kb.addPropertyValue(dp2, mary, data2); _kb.addPropertyValue(dp1, robert, data2); _kb.addPropertyValue(dp1, robert, data3); _kb.addPropertyValue(dp2, victor, data4); }
@Test public void topDataAssertion() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl r = term("r"); final ATermAppl x = term("x"); final ATermAppl y = literal("y"); kb.addDatatypeProperty(r); kb.addIndividual(x); kb.addPropertyValue(r, x, y); assertTrue(kb.hasPropertyValue(x, TOP_DATA_PROPERTY, y)); }
@Test public void anyURI383() { final ATermAppl C = TermFactory.term("C"); final ATermAppl D = TermFactory.term("D"); final ATermAppl p = TermFactory.term("p"); final ATermAppl uri = TermFactory.literal(URI.create("http://www.example.org")); final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); kb.addClass(C); kb.addClass(D); kb.addDatatypeProperty(p); kb.addRange(p, ANY_URI); kb.addEquivalentClass(C, hasValue(p, uri)); kb.addEquivalentClass(D, min(p, 1, TOP_LIT)); assertSubClass(kb, C, D, true); assertSubClass(kb, D, C, false); }
@Test public void topObjectallValuesFreshInd() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl c = term("_C_"); final ATermAppl notC = not(c); final ATermAppl a = term("a"); final ATermAppl b = term("b"); kb.addIndividual(a); kb.addType(a, all(TOP_OBJECT_PROPERTY, notC)); kb.addIndividual(b); kb.addType(b, some(TOP_OBJECT_PROPERTY, c)); assertFalse(kb.isConsistent()); }
_expChecker = new ExpressivityChecker(this, kb.getExpressivity()); for (final ATermAppl nominal : kb.getExpressivity().getNominals()) addIndividual(nominal); _instances.putAll(kb._instances); _deletedAssertions.addAll(kb.getDeletedAssertions()); // copy deleted assertions if (kb.isConsistencyDone()) prepare();
@Test public void testIsAtomTrue() { _kb.addObjectProperty(p); _kb.addIndividual(mary); _kb.addIndividual(robert); _kb.addPropertyValue(p, mary, robert); final VariableBinding binding = new VariableBinding(_kb.getABox()); binding.set(_x, mary); binding.set(_y, robert); final RuleAtom atom = new IndividualPropertyAtom(p, _x, _y); final TrivialSatisfactionHelpers tester = new TrivialSatisfactionHelpers(_kb.getABox()); assertTrue(tester.isAtomTrue(atom, binding) != null); }
@Test public void topDataSuper() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl p = term("p"); kb.addDatatypeProperty(p); assertTrue(kb.isSubPropertyOf(p, TOP_DATA_PROPERTY)); }
@Test public void topObjectSuper() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl p = term("p"); kb.addObjectProperty(p); assertTrue(kb.isSubPropertyOf(p, TOP_OBJECT_PROPERTY)); }
@Test public void bottomObjectFunc() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); assertTrue(kb.isFunctionalProperty(BOTTOM_OBJECT_PROPERTY)); assertTrue(kb.getFunctionalProperties().contains(BOTTOM_OBJECT_PROPERTY)); }