@Test public void testDoubleNormalize() { testDoubleNormalize(and(_a, _b, _c, _d), and(_d, _c, _a, _b)); testDoubleNormalize(and(_a, _b, _c, _d), and(_d, _c, _a, _b, _b, _d, _a, _c)); testDoubleNormalize(and(_a, and(_b, _c)), and(_a, _b, _c)); testDoubleNormalize(or(_a, _b, _c, _d), or(_d, _c, _a, _b)); testDoubleNormalize(or(_a, _b, _c, _d), or(_d, _c, _a, _b, _b, _d, _a, _c)); testDoubleNormalize(or(_a, or(_b, _c)), or(_a, _b, _c)); }
@Test public void testDoubleNormalize() { testDoubleNormalize(and(_a, _b, _c, _d), and(_d, _c, _a, _b)); testDoubleNormalize(and(_a, _b, _c, _d), and(_d, _c, _a, _b, _b, _d, _a, _c)); testDoubleNormalize(and(_a, and(_b, _c)), and(_a, _b, _c)); testDoubleNormalize(or(_a, _b, _c, _d), or(_d, _c, _a, _b)); testDoubleNormalize(or(_a, _b, _c, _d), or(_d, _c, _a, _b, _b, _d, _a, _c)); testDoubleNormalize(or(_a, or(_b, _c)), or(_a, _b, _c)); }
@Test public void testDNF() { testDNF(_a, _a); testDNF(not(_a), not(_a)); testDNF(and(_a, _b), and(_a, _b)); testDNF(or(_a, _b), or(_a, _b)); testDNF(or(_a, and(_b, _c)), or(_a, and(_b, _c))); testDNF(and(_a, or(_b, _c)), or(and(_a, _b), and(_a, _c))); testDNF(and(or(_a, _b), or(_b, _c)), or(and(_a, _b), and(_a, _c), _b, and(_b, _c))); testDNF(and(or(_a, _b), or(_c, _d)), or(and(_a, _c), and(_a, _d), and(_b, _c), and(_b, _d))); testDNF(and(_a, or(and(_b, _c), _d)), or(and(_a, _b, _c), and(_a, _d))); }
@Test public void testDNF() { testDNF(_a, _a); testDNF(not(_a), not(_a)); testDNF(and(_a, _b), and(_a, _b)); testDNF(or(_a, _b), or(_a, _b)); testDNF(or(_a, and(_b, _c)), or(_a, and(_b, _c))); testDNF(and(_a, or(_b, _c)), or(and(_a, _b), and(_a, _c))); testDNF(and(or(_a, _b), or(_b, _c)), or(and(_a, _b), and(_a, _c), _b, and(_b, _c))); testDNF(and(or(_a, _b), or(_c, _d)), or(and(_a, _c), and(_a, _d), and(_b, _c), and(_b, _d))); testDNF(and(_a, or(and(_b, _c), _d)), or(and(_a, _b, _c), and(_a, _d))); }
@Test public void testDomainExpression() { classes(_A, _B); objectProperties(_p); individuals(_a, _b); _kb.addDomain(_p, or(_A, _B)); _kb.addType(_a, not(or(_A, _B))); _kb.addPropertyValue(_p, _a, _b); explainInconsistency(ATermUtils.makeDomain(_p, or(_A, _B)), ATermUtils.makeTypeAtom(_a, not(or(_A, _B))), ATermUtils.makePropAtom(_p, _a, _b)); }
@Test public void testRangeExpression() { classes(_A, _B); objectProperties(_p); individuals(_a, _b); _kb.addRange(_p, or(_A, _B)); _kb.addType(_b, not(or(_A, _B))); _kb.addPropertyValue(_p, _a, _b); explainInconsistency(ATermUtils.makeRange(_p, or(_A, _B)), ATermUtils.makeTypeAtom(_b, not(or(_A, _B))), ATermUtils.makePropAtom(_p, _a, _b)); }
@Test public void testOr() { final StringWriter s = new StringWriter(); final ATermRenderer r = new ATermManchesterSyntaxRenderer(); r.setWriter(new PrintWriter(s)); final ATermAppl C = term("C"); final ATermAppl D = term("D"); final ATermAppl E = term("E"); r.visit(or(C, D, E)); final String expected = "(C or D or E)"; final String actual = s.toString(); assertEquals(expected, actual); }
@Test public void testOr() { final StringWriter s = new StringWriter(); final ATermRenderer r = new ATermManchesterSyntaxRenderer(); r.setWriter(new PrintWriter(s)); final ATermAppl C = term("C"); final ATermAppl D = term("D"); final ATermAppl E = term("E"); r.visit(or(C, D, E)); final String expected = "(C or D or E)"; final String actual = s.toString(); assertEquals(expected, actual); }
@Test public void test532a() { classes(_A, _B, _C, _D); individuals(_a, _b, _c, _d); objectProperties(_p, _q); _kb.addDisjointClasses(Arrays.asList(_A, _B, _C, _D)); _kb.addType(_a, or(_A, _B)); _kb.addType(_b, or(_C, _D)); assertTrue(_kb.isConsistent()); _kb.addSame(_a, _b); assertFalse(_kb.isConsistent()); }
@Test public void testDisjunction() { classes(_A, _B); objectProperties(_p); individuals(_a, _b); _kb.addType(_a, _A); _kb.addPropertyValue(_p, _a, _b); _kb.addType(_a, or(not(_A), all(_p, _B))); explainEntailment(_kb.isType(_b, _B), ATermUtils.makeTypeAtom(_a, _A), ATermUtils.makePropAtom(_p, _a, _b), ATermUtils.makeTypeAtom(_a, or(not(_A), all(_p, _B)))); }
@Test public void unionWithEmptyDatatype() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl dt1 = restrict(INTEGER, minInclusive(literal(1)), maxInclusive(literal(3))); final ATermAppl dt2 = restrict(INTEGER, minInclusive(literal(4)), maxInclusive(literal(6))); final ATermAppl dt3 = and(NEGATIVE_INTEGER, POSITIVE_INTEGER); final ATermAppl datarange = or(dt1, dt2, dt3); assertTrue(reasoner.isSatisfiable(Collections.singleton(datarange))); assertTrue(reasoner.containsAtLeast(6, Collections.singleton(datarange))); assertFalse(reasoner.containsAtLeast(7, Collections.singleton(datarange))); }
@Test public void testInternalization() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl A = term("A"); final ATermAppl B = term("B"); final ATermAppl C = term("C"); kb.addClass(A); kb.addClass(B); kb.addClass(C); kb.addSubClass(TOP, and(or(B, not(A)), or(C, not(B)))); assertSubClass(kb, A, B); assertSubClass(kb, B, C); kb.classify(); }
@Test public void bottomObjectInverseManual() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl c = term("_C_"); final ATermAppl notC = not(c); final ATermAppl r = BOTTOM_OBJECT_PROPERTY; final ATermAppl test = and(c, or(some(r, all(r, notC)), some(r, all(r, notC)))); assertFalse(kb.isSatisfiable(test)); }
@Test public void testFindPrimitives() { testFindPrimitives(some(_p, not(_c)), new ATermAppl[] { _c }); testFindPrimitives(and(_c, _b, all(_p, _a)), new ATermAppl[] { _a, _b, _c }); testFindPrimitives(max(_p, 1, not(some(_p, or(_a, _b)))), new ATermAppl[] { _a, _b }); testFindPrimitives(min(_p, 2, or(_a, and(_b, not(_c)))), new ATermAppl[] { _a, _b, _c }); testFindPrimitives(and(some(_p, ATermUtils.TOP), all(_p, _a), and(some(_p, value(_r)), or(self(_p), max(_p, 1, _b)))), new ATermAppl[] { ATermUtils.TOP, _a, _b }); testFindPrimitives(and(_d1, _d2, _d3), new ATermAppl[] { _d3 }); testFindPrimitives(not(and(not(_d1), _d2, _d3)), new ATermAppl[] { _d3 }); testFindPrimitives(some(_p, and(_d1, _d3)), new ATermAppl[] { _d3 }); }
@Test public void testFindPrimitives() { testFindPrimitives(some(_p, not(_c)), new ATermAppl[] { _c }); testFindPrimitives(and(_c, _b, all(_p, _a)), new ATermAppl[] { _a, _b, _c }); testFindPrimitives(max(_p, 1, not(some(_p, or(_a, _b)))), new ATermAppl[] { _a, _b }); testFindPrimitives(min(_p, 2, or(_a, and(_b, not(_c)))), new ATermAppl[] { _a, _b, _c }); testFindPrimitives(and(some(_p, ATermUtils.TOP), all(_p, _a), and(some(_p, value(_r)), or(self(_p), max(_p, 1, _b)))), new ATermAppl[] { ATermUtils.TOP, _a, _b }); testFindPrimitives(and(_d1, _d2, _d3), new ATermAppl[] { _d3 }); testFindPrimitives(not(and(not(_d1), _d2, _d3)), new ATermAppl[] { _d3 }); testFindPrimitives(some(_p, and(_d1, _d3)), new ATermAppl[] { _d3 }); }
@Test public void topObjectInverseManual() { final KnowledgeBaseImpl kb = new KnowledgeBaseImpl(); final ATermAppl c = term("_C_"); final ATermAppl notC = not(c); final ATermAppl r = TOP_OBJECT_PROPERTY; final ATermAppl test = and(c, or(some(r, all(r, notC)), some(r, all(r, notC)))); assertFalse(kb.isSatisfiable(test)); }
/** * Same as {@link #testTopClass2()} but tests the EL classifier. */ @Test public void testTopClass2EL() { // This test was failing due to the issue explained in #157 at some point but not anymore // The issue explained in #157 is still valid even though this test passes final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl A = term("A"); final ATermAppl B = term("B"); kb.addClass(A); kb.addClass(B); kb.addEquivalentClass(A, or(B, not(B))); assertTrue(kb.isConsistent()); kb.classify(); assertTrue(kb.isEquivalentClass(A, TOP)); assertFalse(kb.isEquivalentClass(B, TOP)); }
@Test public void binaryAbsorption() { final ATermAppl SPECIALCLIENT = term("SPECIALCLIENT"); final ATermAppl CLIENT = term("CLIENT"); final ATermAppl EXPENSIVE = term("EXPENSIVE"); final ATermAppl PROFITABLE = term("PROFITABLE"); final ATermAppl TRUSTEDCLIENT = term("TRUSTEDCLIENT"); final ATermAppl Recommend = term("Recommend"); final ATermAppl Buy = term("Buy"); classes(SPECIALCLIENT, CLIENT, EXPENSIVE, PROFITABLE, TRUSTEDCLIENT); objectProperties(Buy, Recommend); tbox.addAxiom(makeSub(SPECIALCLIENT, TRUSTEDCLIENT)); tbox.addAxiom(makeEqClasses(SPECIALCLIENT, and(CLIENT, some(Buy, or(EXPENSIVE, PROFITABLE)), some(inv(Recommend), TRUSTEDCLIENT)))); prepareTBox(); }
@Test public void testNNF() { testNNF(not(some(_p, _c)), all(_p, not(_c))); testNNF(not(all(_p, _c)), some(_p, not(_c))); testNNF(not(min(_p, 1, _c)), max(_p, 0, _c)); testNNF(not(max(_p, 0, _c)), min(_p, 1, _c)); testNNF(not(max(_p, 1, not(some(_p, _c)))), min(_p, 2, all(_p, not(_c)))); testNNF(and(_d1, _d2, _d3), and(_d1, _d2, _d3)); testNNF(not(and(_d1, _d2, _d3)), or(not(_d1), not(_d2), not(_d3))); testNNF(some(_p, and(_d1, _d3)), some(_p, and(_d1, _d3))); testNNF(not(some(_p, and(_d1, _d3))), all(_p, or(not(_d1), not(_d3)))); }
@Test public void testNNF() { testNNF(not(some(_p, _c)), all(_p, not(_c))); testNNF(not(all(_p, _c)), some(_p, not(_c))); testNNF(not(min(_p, 1, _c)), max(_p, 0, _c)); testNNF(not(max(_p, 0, _c)), min(_p, 1, _c)); testNNF(not(max(_p, 1, not(some(_p, _c)))), min(_p, 2, all(_p, not(_c)))); testNNF(and(_d1, _d2, _d3), and(_d1, _d2, _d3)); testNNF(not(and(_d1, _d2, _d3)), or(not(_d1), not(_d2), not(_d3))); testNNF(some(_p, and(_d1, _d3)), some(_p, and(_d1, _d3))); testNNF(not(some(_p, and(_d1, _d3))), all(_p, or(not(_d1), not(_d3)))); }