@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 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 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 testUnsatClasses2() { classes(_B, _C, _D); _kb.addDisjointClass(_C, _D); _kb.addSubClass(_B, and(_C, _D)); assertEquals(singleton(_B), _kb.getUnsatisfiableClasses()); assertEquals(SetUtils.create(_B, BOTTOM), _kb.getAllUnsatisfiableClasses()); assertFalse(_kb.isClassified()); assertEquals(singleton(_B), _kb.getUnsatisfiableClasses()); assertEquals(SetUtils.create(_B, BOTTOM), _kb.getAllUnsatisfiableClasses()); }
@Test public void transitivityInverse() { classes(_C, _D); objectProperties(_p, _q, _r); _kb.addTransitiveProperty(_r); _kb.addSubProperty(_r, _q); _kb.addSubClass(_D, all(_q, _C)); assertTrue(_kb.isConsistent()); assertFalse(_kb.isSatisfiable(some(_p, and(_D, some(_p, and(some(inv(_r), _D), some(_r, not(_C)))))))); }
@Test public void testBottom1() { classes(_A, _B, _C, _D); _kb.addSubClass(_A, ATermUtils.BOTTOM); _kb.addSubClass(_C, and(_A, _B)); _kb.addSubClass(ATermUtils.BOTTOM, _D); final Taxonomy<ATermAppl> hierarchy = getHierarchy(); assertEquals(SetUtils.create(_A, _C), hierarchy.getEquivalents(ATermUtils.BOTTOM)); }
@Test public void testReflexiveRole() { classes(_A, _B, _C, _D, _E, _F, _G); objectProperties(_p, _q, _r, _s); _kb.addReflexiveProperty(_p); _kb.addRange(_p, _A); _kb.addRange(_p, and(_B, _C)); final Taxonomy<ATermAppl> hierarchy = getHierarchy(); assertEquals(SetUtils.create(_A, _B, _C), hierarchy.getEquivalents(ATermUtils.TOP)); }
@Test public void functionalSubTrans() { classes(_A); objectProperties(_r, _f); _kb.addFunctionalProperty(_f); _kb.addTransitiveProperty(_r); _kb.addSubProperty(_f, _r); _kb.addEquivalentClass(_D, and(_C, some(_f, not(_C)))); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSatisfiable(and(not(_A), some(inv(_f), _A), all(inv(_r), some(inv(_f), _A))))); }
@Test public void doubleBlockingExample() { classes(_C, _D); objectProperties(_f, _r); _kb.addTransitiveProperty(_r); _kb.addSubProperty(_f, _r); _kb.addEquivalentClass(_D, and(_C, some(_f, not(_C)))); _kb.addSubClass(TOP, max(_f, 1, TOP)); assertTrue(_kb.isConsistent()); assertFalse(_kb.isSatisfiable(and(not(_C), some(inv(_f), _D), all(inv(_r), some(inv(_f), _D))))); }
@Test public void testEL3c() { classes(_A, _C, _D, _E); objectProperties(_p); _kb.addSubClass(_A, some(_p, and(_C, _D))); _kb.addSubClass(some(_p, _C), _E); final Taxonomy<ATermAppl> hierarchy = getHierarchy(); assertEquals(singletonSets(_E), hierarchy.getSupers(_A, true)); }
@Test public void testRange5() { classes(_A, _B, _C, _D, _E, _F, _G); objectProperties(_p, _q, _r, _s); _kb.addRange(_p, _A); _kb.addSubClass(_B, and(_A, some(_p, _C))); _kb.addSubClass(_C, _A); _kb.addEquivalentClass(_D, some(_p, _C)); final Taxonomy<ATermAppl> hierarchy = getHierarchy(); assertEquals(singletonSets(_B, _C), hierarchy.getSubs(_A, true)); }
@Test public void testRange4() { classes(_A, _B, _C, _D, _E, _F, _G); objectProperties(_p, _q, _r, _s); _kb.addRange(_p, _C); _kb.addSubClass(_A, some(_p, _B)); _kb.addSubClass(and(_B, _C), _D); _kb.addSubClass(some(_p, _D), _E); final Taxonomy<ATermAppl> hierarchy = getHierarchy(); assertEquals(singletonSets(_A), hierarchy.getSubs(_E, true)); }
@Test public void cachedIntersectionUnsat() { classes(_B, _C, _D); objectProperties(_p); _kb.addDisjointClass(_C, _D); _kb.addSubClass(_B, some(_p, some(inv(_p), and(_C, _D)))); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSatisfiable(_C)); assertTrue(_kb.isSatisfiable(_D)); assertFalse(_kb.isSatisfiable(_B)); }
@Test public void somePQallAnonInvR1() { classes(_C); objectProperties(_p, _q, _r); _kb.addSubProperty(list(_p, _q), _r); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSatisfiable(_C)); assertTrue(_kb.isSatisfiable(all(inv(_r), not(_C)))); assertFalse(_kb.isSatisfiable(and(_C, some(_p, some(_q, all(inv(_r), not(_C))))))); }
@Test public void somePQallAnonInvR2() { classes(_C); objectProperties(_p, _q, _r); _kb.addSubProperty(list(_p, _q), _r); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSatisfiable(_C)); assertTrue(_kb.isSatisfiable(some(_q, all(inv(_r), not(_C))))); assertFalse(_kb.isSatisfiable(and(_C, some(_p, some(_q, all(inv(_r), not(_C))))))); }
@Test public void nestedPropertyChains() { classes(_C); objectProperties(_p, _q, _r, _f); _kb.addSubProperty(list(_p, _q), _r); _kb.addSubProperty(list(_r, _q), _f); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSatisfiable(_C)); assertTrue(_kb.isSatisfiable(all(inv(_f), not(_C)))); assertFalse(_kb.isSatisfiable(and(_C, some(_p, some(_q, some(_q, all(inv(_f), not(_C)))))))); }