Ejemplo n.º 1
0
  @Test
  public void testFunctionalSomeTermNoGovTerm()
      throws ENodeMergeException, ParseException, EReasonerException, EInconsistencyException {
    final IIndividualABoxNode<String, String, String, String> node = _abox.createIndividualNode();
    _abox.getAssertedRBox().addRole("r", RoleType.OBJECT_PROPERTY);
    _abox.getAssertedRBox().setRoleProperty("r", RoleProperty.FUNCTIONAL);

    node.addClassTerm(_parser.parse("(some r A)"));

    assertFalse(_abox.getDependencyMap().hasGoverningTerm(node, _parser.parse("(some r A)")));
    _reasoner.getReasonerOptions().setSemanticBranching(false);
    final Collection<? extends IReasonerResult<String, String, String, String>> results =
        _reasoner.checkConsistency(_abox, false);
    assertEquals(1, results.size());

    for (IReasonerResult<String, String, String, String> result : results) {
      final IABox<String, String, String, String> abox = result.getABox();
      final IABoxNode<String, String, String, String> node2 = abox.getNode(node.getNodeID());
      assertEquals(1, node2.getRABox().getSuccessorNodes().size());
      final IABoxNode<String, String, String, String> succ =
          node2.getRABox().getSuccessorNodes().iterator().next();
      assertFalse(abox.getDependencyMap().hasGoverningTerm(succ, _parser.parse("A")));
      assertFalse(abox.getDependencyMap().hasGoverningTerm(node2, _parser.parse("(some r A)")));
    }
  }
Ejemplo n.º 2
0
  @Override
  public ReasonerContinuationState completeNode(
      final IDecisionTree.Node<Branch<I, L, K, R>> branchNode, IABoxNode<I, L, K, R> node)
      throws EReasonerException {
    final Iterator<IDLTerm<I, L, K, R>> iter =
        ChainIterator.decorate(
            node.getTerms().subSet(DLTermOrder.DL_OBJECT_UNION).iterator(),
            node.getTerms().subSet(DLTermOrder.DL_DATA_UNION).iterator());

    final BranchActionList<I, L, K, R> branchActions = new BranchActionList<>();

    while (iter.hasNext()) {
      final IDLTerm<I, L, K, R> desc = iter.next();
      if (desc instanceof IDLUnion) {
        final IDLUnion<I, L, K, R> union = (IDLUnion<I, L, K, R>) desc;
        /* union condition: If not already one of the subterms present */
        final TermEntry<I, L, K, R> parentTerm =
            node.getABox().getTermEntryFactory().getEntry(node, desc);

        if (!CollectionUtil.containsOne(node.getTerms(), union.getTerms())) {
          for (IDLNodeTerm<I, L, K, R> subTerm : union.getTerms()) {
            branchActions.add(new TermAddBranchAction<>(parentTerm, node, subTerm));
          }
          assert !branchActions.isEmpty();
        }

        /* remove the union as a governing term */
        node.getABox()
            .getDependencyMap()
            .getGoverningTerms()
            .remove(node.getABox().getTermEntryFactory().getEntry(node, union));

        final List<BranchCreationInfo<I, L, K, R>> branchCreationInfos =
            branchActions.commit(branchNode.getData(), getNodeConsistencyChecker());

        /**
         * If we needed to branch, but all branches are inconsistent. Don't throw Exception, when we
         * did not find a branch point.
         */
        if (!branchActions.isEmpty()) {
          if (branchCreationInfos.isEmpty()) {
            /* this only happens for node merge clashes, not otherwise */
            /* XXX - do we need to change the branches consistency info? */
            return ReasonerContinuationState.INCONSISTENT;
          } else {
            if (isTracing()) {
              _logger.trace("Created %d branches", branchCreationInfos.size());
            }
            final ReasonerContinuationState contState =
                handleBranchCreation(branchCreationInfos, branchNode, node);
            if (contState != ReasonerContinuationState.CONTINUE) {
              return contState;
            }
          }
        }
      }
    }
    return ReasonerContinuationState.CONTINUE;
  }
Ejemplo n.º 3
0
  @Test
  public void testComplexTermPropagation1()
      throws ENodeMergeException, ParseException, EReasonerException, EInconsistencyException {
    final IIndividualABoxNode<String, String, String, String> node = _abox.createIndividualNode();
    _abox.getAssertedRBox().addRole("r", RoleType.OBJECT_PROPERTY);
    _abox.getAssertedRBox().setRoleProperty("r", RoleProperty.FUNCTIONAL);
    final IIndividualABoxNode<String, String, String, String> node2 = _abox.createIndividualNode();
    node.getRABox().getAssertedSuccessors().put("r", node2);

    node.addClassTerm(_parser.parse("(only r (some r (some r A)))"));
    _abox.getDependencyMap().addGoverningTerm(node, _parser.parse("(only r (some r (some r A)))"));
    assertTrue(
        _abox
            .getDependencyMap()
            .hasGoverningTerm(node, _parser.parse("(only r (some r (some r A)))")));

    final Collection<? extends IReasonerResult<String, String, String, String>> results =
        _reasoner.checkConsistency(_abox, false);
    assertEquals(1, results.size());

    final IABox<String, String, String, String> result = results.iterator().next().getABox();
    final IABoxNode<String, String, String, String> n = result.getNode(node.getNodeID());
    assertFalse(
        result
            .getDependencyMap()
            .hasGoverningTerm(n, _parser.parse("(only r (some r (some r A)))")));
    assertFalse(
        result.getDependencyMap().hasGoverningTerm(n, _parser.parse("(some r (some r A))")));
    assertEquals(1, n.getRABox().getSuccessorNodes().size());
    final IABoxNode<String, String, String, String> n2 =
        n.getRABox().getSuccessorNodes().iterator().next();
    assertFalse(result.getDependencyMap().hasGoverningTerm(n2, _parser.parse("(some r A)")));
    assertEquals(1, n2.getRABox().getSuccessorNodes().size());
    final IABoxNode<String, String, String, String> n3 =
        n2.getRABox().getSuccessorNodes().iterator().next();
    assertFalse(result.getDependencyMap().hasGoverningTerm(n3, _parser.parse("(some r A)")));
    assertEquals(1, n3.getRABox().getSuccessorNodes().size());
    final IABoxNode<String, String, String, String> n4 =
        n3.getRABox().getSuccessorNodes().iterator().next();
    assertTrue(result.getDependencyMap().hasGoverningTerm(n4, _parser.parse("A")));
  }