@Override public synchronized boolean addObjectProperty(final ATerm p) { return super.addObjectProperty(p); }
@Override public synchronized boolean addObjectProperty(final ATerm p) { return super.addObjectProperty(p); }
@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))); }
@Test public void bottomObjectSuper() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl p = term("p"); kb.addObjectProperty(p); assertTrue(kb.isSubPropertyOf(BOTTOM_OBJECT_PROPERTY, p)); }
@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 testGetInstances9() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl C = term("C"); final ATermAppl E = term("E"); final ATermAppl p = term("p"); final ATermAppl D = some(p, E); final ATermAppl i = term("i"); kb.addClass(C); kb.addClass(E); kb.addObjectProperty(p); kb.addSubClass(D, C); kb.addIndividual(i); kb.addType(i, D); final Set<ATermAppl> expected = new HashSet<>(); expected.add(i); // Retrieve direct instance of anonymous concept final Set<ATermAppl> actual = kb.getInstances(D, true); assertEquals(expected, actual); }
@Test public void testGetInstances8() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl C = TermFactory.term("C"); final ATermAppl E = TermFactory.term("E"); final ATermAppl p = TermFactory.term("p"); final ATermAppl D = TermFactory.some(p, E); final ATermAppl i = TermFactory.term("i"); kb.addClass(C); kb.addClass(E); kb.addObjectProperty(p); kb.addSubClass(D, C); kb.addIndividual(i); kb.addType(i, C); final Set<ATermAppl> expected = new HashSet<>(); // Retrieve direct instance of anonymous concept final Set<ATermAppl> actual = kb.getInstances(D, true); assertEquals(expected, actual); }
@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 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)); }