Esempio n. 1
0
  /**
   * B ⊑ ∃r.C' → {B ⊑ ∃r.A, A ⊑ C'}
   *
   * @param gcis
   * @return
   */
  boolean rule6(final IFactory factory, final Inclusion[] gcis) {
    boolean result = false;

    if (rhs instanceof Existential) {
      Existential existential = (Existential) rhs;
      final AbstractConcept cHat = existential.getConcept();
      if (!(cHat instanceof Concept)) {
        result = true;
        Concept a = getA(factory, cHat);
        gcis[0] = new GCI(lhs, new Existential(existential.getRole(), a));
        gcis[1] = new GCI(a, cHat);
      }
    }

    return result;
  }
Esempio n. 2
0
  @Override
  public NormalFormGCI getNormalForm() {
    final NormalFormGCI result;
    // try {
    if (lhs instanceof Concept) {
      if (rhs instanceof Concept) {
        final int newLhs = lhs.hashCode();
        result = NF1a.getInstance(newLhs, rhs.hashCode());
      } else if (rhs instanceof Existential) {
        final Existential existential = (Existential) rhs;
        result =
            NF2.getInstance(
                lhs.hashCode(), existential.getRole(), existential.getConcept().hashCode());
      } else if (rhs instanceof Datatype) {
        final Datatype datatype = (Datatype) rhs;
        result = NF7.getInstance(lhs.hashCode(), datatype);
      } else {
        throw new IllegalStateException(
            "GCI is not in Normal Form: "
                + "lhs is Concept but rhs is neither Concept, "
                + "Existential nor Datatype; it is "
                + rhs);
      }
    } else if (lhs instanceof Conjunction) {
      final Conjunction conjunction = (Conjunction) lhs;
      final AbstractConcept[] concepts = conjunction.getConcepts();
      if (concepts.length == 1) {
        result = NF1a.getInstance(concepts[0].hashCode(), rhs.hashCode());
      } else if (concepts.length == 2) {
        result = NF1b.getInstance(concepts[0].hashCode(), concepts[1].hashCode(), rhs.hashCode());
      } else {
        throw new IllegalStateException(
            "Conjunction should have exactly one or two "
                + "Concepts not "
                + concepts.length
                + ": "
                + conjunction);
      }
    } else if (lhs instanceof Existential) {
      Existential existential = (Existential) lhs;
      result =
          NF3.getInstance(
              existential.getRole(), existential.getConcept().hashCode(), rhs.hashCode());
    } else if (lhs instanceof Datatype) {
      Datatype datatype = (Datatype) lhs;
      result = NF8.getInstance(datatype, rhs.hashCode());
    } else {
      throw new IllegalStateException("GCI is not in Normal Form: " + lhs + ", " + rhs);
    }

    return result;
  }