public void visit(OWLDataAllValuesFrom object) {
      // if the filler is the negation of a supported range then we will leave the expression as if
      // it was in the head,
      // because when we overapproximate we are only going to look at the property so there's no
      // point in decomposing it further
      // if the filler is positive, however, we will decompose it a bit
      LiteralDataRange literalRange = m_dataRangeConverter.convertDataRange(object.getFiller());
      if (object.getProperty().isOWLTopDataProperty()) {
        if (literalRange.isAlwaysFalse()) return; // bottom
      }

      Variable y = nextY();
      m_bodyAtoms.add(getRoleAtom(object.getProperty(), X, y));
      if (literalRange.isNegatedInternalDatatype()) {
        InternalDatatype negatedRange = (InternalDatatype) literalRange.getNegation();
        if (!negatedRange.isAlwaysTrue()) m_bodyAtoms.add(Atom.create(negatedRange, y));
      } else {
        if (!literalRange.isAlwaysFalse()) {
          if (object.getFiller() instanceof OWLDataOneOf) {
            for (OWLLiteral lit : ((OWLDataOneOf) object.getFiller()).getValues())
              m_headAtoms.add(
                  Atom.create(Equality.INSTANCE, y, (Constant) lit.accept(m_dataRangeConverter)));
          } else m_headAtoms.add(Atom.create((DLPredicate) literalRange, y));
        }
      }
    }
 public void visit(OWLClassAssertionAxiom object) {
   OWLClassExpression description = object.getClassExpression();
   if (description instanceof OWLClass) {
     AtomicConcept atomicConcept =
         AtomicConcept.create(((OWLClass) description).getIRI().toString());
     Atom atom = Atom.create(atomicConcept, getIndividual(object.getIndividual()));
     Collection<OWLAxiom> originalAxioms = m_positiveFacts_map.get(atom);
     if (originalAxioms == null) {
       originalAxioms = new ArrayList<OWLAxiom>();
       m_positiveFacts_map.put(atom, originalAxioms);
     }
     if (originalAxiom != null) originalAxioms.add(originalAxiom);
   } else if (description instanceof OWLObjectComplementOf
       && ((OWLObjectComplementOf) description).getOperand() instanceof OWLClass) {
     AtomicConcept atomicConcept =
         AtomicConcept.create(
             ((OWLClass) ((OWLObjectComplementOf) description).getOperand())
                 .getIRI()
                 .toString());
     Atom atom = Atom.create(atomicConcept, getIndividual(object.getIndividual()));
     Collection<OWLAxiom> originalAxioms = m_negativeFacts_map.get(atom);
     if (originalAxioms == null) {
       originalAxioms = new ArrayList<OWLAxiom>();
       m_negativeFacts_map.put(atom, originalAxioms);
     }
     if (originalAxiom != null) originalAxioms.add(originalAxiom);
   } else if (description instanceof OWLObjectHasSelf) {
     OWLObjectHasSelf self = (OWLObjectHasSelf) description;
     Atom atom =
         getRoleAtom(
             self.getProperty(),
             getIndividual(object.getIndividual()),
             getIndividual(object.getIndividual()));
     Collection<OWLAxiom> originalAxioms = m_positiveFacts_map.get(atom);
     if (originalAxioms == null) {
       originalAxioms = new ArrayList<OWLAxiom>();
       m_positiveFacts_map.put(atom, originalAxioms);
     }
     if (originalAxiom != null) originalAxioms.add(originalAxiom);
   } else if (description instanceof OWLObjectComplementOf
       && ((OWLObjectComplementOf) description).getOperand() instanceof OWLObjectHasSelf) {
     OWLObjectHasSelf self =
         (OWLObjectHasSelf) (((OWLObjectComplementOf) description).getOperand());
     Atom atom =
         getRoleAtom(
             self.getProperty(),
             getIndividual(object.getIndividual()),
             getIndividual(object.getIndividual()));
     Collection<OWLAxiom> originalAxioms = m_negativeFacts_map.get(atom);
     if (originalAxioms == null) {
       originalAxioms = new ArrayList<OWLAxiom>();
       m_negativeFacts_map.put(atom, originalAxioms);
     }
     if (originalAxiom != null) originalAxioms.add(originalAxiom);
   } else throw new IllegalStateException("Internal error: invalid normal form.");
 }
    protected void clausify(
        OWLAxioms.DisjunctiveRule rule, boolean restrictToNamed, OWLAxiom originalAxiom) {
      m_headAtoms.clear();
      m_bodyAtoms.clear();
      m_abstractVariables.clear();
      for (SWRLAtom atom : rule.m_body) m_bodyAtoms.add(atom.accept(this));
      for (SWRLAtom atom : rule.m_head) m_headAtoms.add(atom.accept(this));
      if (restrictToNamed) {
        for (Variable variable : m_abstractVariables)
          m_bodyAtoms.add(Atom.create(AtomicConcept.INTERNAL_NAMED, variable));
      }
      DLClause dlClause =
          DLClause.create(
              m_headAtoms.toArray(new Atom[m_headAtoms.size()]),
              m_bodyAtoms.toArray(new Atom[m_bodyAtoms.size()]));

      Collection<OWLAxiom> originalAxioms = m_dlClauses_map.get(dlClause);
      if (originalAxioms == null) {
        originalAxioms = new ArrayList<OWLAxiom>();
        m_dlClauses_map.put(dlClause, originalAxioms);
      }
      originalAxioms.add(originalAxiom);

      m_headAtoms.clear();
      m_bodyAtoms.clear();
      m_abstractVariables.clear();
    }
 public Atom visit(SWRLClassAtom atom) {
   if (atom.getPredicate().isAnonymous())
     throw new IllegalStateException(
         "Internal error: SWRL rule class atoms should be normalized to contain only named classes, but this class atom has a complex concept: "
             + atom.getPredicate());
   Variable variable = toVariable(atom.getArgument());
   m_abstractVariables.add(variable);
   return Atom.create(
       AtomicConcept.create(atom.getPredicate().asOWLClass().getIRI().toString()), variable);
 }
 public void visit(OWLDataSomeValuesFrom object) {
   if (!object.getProperty().isOWLBottomDataProperty()) {
     AtomicRole atomicRole = getAtomicRole(object.getProperty());
     OWLDataRange filler = object.getFiller();
     if (filler instanceof OWLDataOneOf) {
       for (OWLLiteral lit : ((OWLDataOneOf) filler).getValues()) {
         LiteralDataRange literalRange =
             m_dataRangeConverter.convertDataRange(m_factory.getOWLDataOneOf(lit));
         AtLeastDataRange atLeastDataRange =
             AtLeastDataRange.create(1, atomicRole, literalRange);
         if (!atLeastDataRange.isAlwaysFalse())
           m_headAtoms.add(Atom.create(atLeastDataRange, X));
       }
     } else {
       LiteralDataRange literalRange = m_dataRangeConverter.convertDataRange(object.getFiller());
       AtLeastDataRange atLeastDataRange = AtLeastDataRange.create(1, atomicRole, literalRange);
       if (!atLeastDataRange.isAlwaysFalse()) m_headAtoms.add(Atom.create(atLeastDataRange, X));
     }
   }
 }
 public void visit(OWLDataMinCardinality object) {
   if (!object.getProperty().isOWLBottomDataProperty() || object.getCardinality() == 0) {
     AtomicRole atomicRole = getAtomicRole(object.getProperty());
     if (object.getCardinality() == 1) {
       m_factory.getOWLDataSomeValuesFrom(object.getProperty(), object.getFiller()).accept(this);
       // if the cardinality is more than one then we don't make the disjunction explicit because
       // of how we are going
       // to overapproximate it (also, making the disjunction explicitly would be exponential)
     } else {
       LiteralDataRange literalRange = m_dataRangeConverter.convertDataRange(object.getFiller());
       AtLeastDataRange atLeast =
           AtLeastDataRange.create(object.getCardinality(), atomicRole, literalRange);
       if (!atLeast.isAlwaysFalse()) m_headAtoms.add(Atom.create(atLeast, X));
     }
   }
 }
 public void visit(OWLSameIndividualAxiom object) {
   OWLIndividual[] individuals = new OWLIndividual[object.getIndividuals().size()];
   object.getIndividuals().toArray(individuals);
   for (int i = 0; i < individuals.length - 1; i++) {
     Atom atom =
         Atom.create(
             Equality.create(),
             getIndividual(individuals[i]),
             getIndividual(individuals[i + 1]));
     Collection<OWLAxiom> originalAxioms = m_positiveFacts_map.get(atom);
     if (originalAxioms == null) {
       originalAxioms = new ArrayList<OWLAxiom>();
       m_positiveFacts_map.put(atom, originalAxioms);
     }
     if (originalAxiom != null) originalAxioms.add(originalAxiom);
   }
 }
 public Atom visit(SWRLDifferentIndividualsAtom atom) {
   Variable variable1 = toVariable(atom.getFirstArgument());
   Variable variable2 = toVariable(atom.getSecondArgument());
   return Atom.create(Inequality.INSTANCE, variable1, variable2);
 }
  public DLOntology_withMaps clausify_withMaps(
      OWLDataFactory factory,
      String ontologyIRI,
      OWLAxioms_withMaps axioms,
      OWLAxiomsExpressivity axiomsExpressivity) {
    Map<DLClause, Collection<OWLAxiom>> dlClauses = new HashMap<DLClause, Collection<OWLAxiom>>();
    Map<Atom, Collection<OWLAxiom>> positiveFacts = new HashMap<Atom, Collection<OWLAxiom>>();
    Map<Atom, Collection<OWLAxiom>> negativeFacts = new HashMap<Atom, Collection<OWLAxiom>>();
    for (Entry<OWLAxiom, Collection<OWLObjectPropertyExpression[]>> entry :
        axioms.m_simpleObjectPropertyInclusions_map.entrySet()) {
      for (OWLObjectPropertyExpression[] inclusion : entry.getValue()) {
        Atom subRoleAtom = getRoleAtom(inclusion[0], X, Y);
        Atom superRoleAtom = getRoleAtom(inclusion[1], X, Y);
        DLClause dlClause = DLClause.create(new Atom[] {superRoleAtom}, new Atom[] {subRoleAtom});
        Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
        if (correspAxioms == null) {
          correspAxioms = new ArrayList<OWLAxiom>();
          dlClauses.put(dlClause, correspAxioms);
        }
        correspAxioms.add(entry.getKey());
      }
    }
    for (Entry<OWLAxiom, Collection<OWLDataPropertyExpression[]>> entry :
        axioms.m_dataPropertyInclusions_map.entrySet()) {
      for (OWLDataPropertyExpression[] inclusion : entry.getValue()) {
        Atom subProp = getRoleAtom(inclusion[0], X, Y);
        Atom superProp = getRoleAtom(inclusion[1], X, Y);
        DLClause dlClause = DLClause.create(new Atom[] {superProp}, new Atom[] {subProp});
        Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
        if (correspAxioms == null) {
          correspAxioms = new ArrayList<OWLAxiom>();
          dlClauses.put(dlClause, correspAxioms);
        }
        correspAxioms.add(entry.getKey());
      }
      if (entry
          .getValue()
          .contains(factory.getOWLDataProperty(IRI.create(AtomicRole.BOTTOM_DATA_ROLE.getIRI())))) {
        Atom bodyAtom = Atom.create(AtomicRole.BOTTOM_DATA_ROLE, X, Y);
        DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {bodyAtom});
        Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
        if (correspAxioms == null) {
          correspAxioms = new ArrayList<OWLAxiom>();
          dlClauses.put(dlClause, correspAxioms);
        }
        correspAxioms.add(entry.getKey());
      }
    }
    for (OWLObjectPropertyExpression objectPropertyExpression :
        axioms.m_symmetricObjectProperties) {
      Atom roleAtom = getRoleAtom(objectPropertyExpression, X, Y);
      Atom inverseRoleAtom = getRoleAtom(objectPropertyExpression, Y, X);
      DLClause dlClause = DLClause.create(new Atom[] {inverseRoleAtom}, new Atom[] {roleAtom});
      Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
      if (correspAxioms == null) {
        correspAxioms = new ArrayList<OWLAxiom>();
        dlClauses.put(dlClause, correspAxioms);
      }
      correspAxioms.add(factory.getOWLSymmetricObjectPropertyAxiom(objectPropertyExpression));
    }
    for (OWLObjectPropertyExpression objectPropertyExpression :
        axioms.m_asymmetricObjectProperties) {
      Atom roleAtom = getRoleAtom(objectPropertyExpression, X, Y);
      Atom inverseRoleAtom = getRoleAtom(objectPropertyExpression, Y, X);
      DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {roleAtom, inverseRoleAtom});
      Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
      if (correspAxioms == null) {
        correspAxioms = new ArrayList<OWLAxiom>();
        dlClauses.put(dlClause, correspAxioms);
      }
      correspAxioms.add(factory.getOWLAsymmetricObjectPropertyAxiom(objectPropertyExpression));
    }
    for (OWLObjectPropertyExpression objectPropertyExpression :
        axioms.m_reflexiveObjectProperties) {
      Atom roleAtom = getRoleAtom(objectPropertyExpression, X, X);
      Atom bodyAtom = Atom.create(AtomicConcept.THING, X);
      DLClause dlClause = DLClause.create(new Atom[] {roleAtom}, new Atom[] {bodyAtom});
      Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
      if (correspAxioms == null) {
        correspAxioms = new ArrayList<OWLAxiom>();
        dlClauses.put(dlClause, correspAxioms);
      }
      correspAxioms.add(factory.getOWLReflexiveObjectPropertyAxiom(objectPropertyExpression));
    }
    for (OWLObjectPropertyExpression objectPropertyExpression :
        axioms.m_irreflexiveObjectProperties) {
      Atom roleAtom = getRoleAtom(objectPropertyExpression, X, X);
      DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {roleAtom});
      Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
      if (correspAxioms == null) {
        correspAxioms = new ArrayList<OWLAxiom>();
        dlClauses.put(dlClause, correspAxioms);
      }
      correspAxioms.add(factory.getOWLIrreflexiveObjectPropertyAxiom(objectPropertyExpression));
    }
    for (OWLObjectPropertyExpression[] properties : axioms.m_disjointObjectProperties) {
      OWLAxiom axiom = factory.getOWLDisjointObjectPropertiesAxiom(properties);
      for (int i = 0; i < properties.length; i++)
        for (int j = i + 1; j < properties.length; j++) {
          Atom atom_i = getRoleAtom(properties[i], X, Y);
          Atom atom_j = getRoleAtom(properties[j], X, Y);
          DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {atom_i, atom_j});
          Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
          if (correspAxioms == null) {
            correspAxioms = new ArrayList<OWLAxiom>();
            dlClauses.put(dlClause, correspAxioms);
          }
          correspAxioms.add(axiom);
        }
    }
    for (OWLDataPropertyExpression[] properties : axioms.m_disjointDataProperties) {
      OWLAxiom axiom = factory.getOWLDisjointDataPropertiesAxiom(properties);
      for (int i = 0; i < properties.length; i++)
        for (int j = i + 1; j < properties.length; j++) {
          Atom atom_i = getRoleAtom(properties[i], X, Y);
          Atom atom_j = getRoleAtom(properties[j], X, Z);
          Atom atom_ij = Atom.create(Inequality.create(), Y, Z);
          DLClause dlClause = DLClause.create(new Atom[] {atom_ij}, new Atom[] {atom_i, atom_j});
          Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
          if (correspAxioms == null) {
            correspAxioms = new ArrayList<OWLAxiom>();
            dlClauses.put(dlClause, correspAxioms);
          }
          correspAxioms.add(axiom);
        }
    }
    DataRangeConverter dataRangeConverter =
        new DataRangeConverter(
            m_configuration.warningMonitor,
            axioms.m_definedDatatypesIRIs,
            new HashSet<DatatypeRestriction>(),
            m_configuration.ignoreUnsupportedDatatypes);
    Set<Atom> auxiliaryFacts = new HashSet<Atom>();
    NormalizedAxiomClausifier_withMaps clausifier =
        new NormalizedAxiomClausifier_withMaps(dataRangeConverter, auxiliaryFacts, factory);
    for (Entry<OWLAxiom, Collection<OWLClassExpression[]>> entry :
        axioms.m_conceptInclusions_map.entrySet())
      for (OWLClassExpression[] inclusion : entry.getValue()) {
        for (OWLClassExpression description : inclusion) description.accept(clausifier);
        DLClause dlClause = clausifier.getDLClause().getSafeVersion(AtomicConcept.THING);
        Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
        if (correspAxioms == null) {
          correspAxioms = new ArrayList<OWLAxiom>();
          dlClauses.put(dlClause, correspAxioms);
        }
        correspAxioms.add(entry.getKey());
      }
    for (OWLClassExpression[] inclusion : axioms.m_auxiliaryConceptInclusions) {
      for (OWLClassExpression description : inclusion) description.accept(clausifier);
      DLClause dlClause = clausifier.getDLClause().getSafeVersion(AtomicConcept.THING);
      Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
      if (correspAxioms == null) {
        correspAxioms = new ArrayList<OWLAxiom>();
        dlClauses.put(dlClause, correspAxioms);
      }
    }
    //        NormalizedDataRangeAxiomClausifier_withMaps normalizedDataRangeAxiomClausifier=new
    // NormalizedDataRangeAxiomClausifier_withMaps(dataRangeConverter,factory,axioms.m_definedDatatypesIRIs);
    //
    //        for (Entry<OWLAxiom,Collection<OWLDataRange[]>> entry :
    // axioms.m_dataRangeInclusions_map.entrySet()) {
    //        	for (OWLDataRange[] inclusion : entry.getValue()) {
    //        		for (OWLDataRange description : inclusion)
    //        			description.accept(normalizedDataRangeAxiomClausifier);
    //        		DLClause
    // dlClause=normalizedDataRangeAxiomClausifier.getDLClause().getSafeVersion(InternalDatatype.RDFS_LITERAL);
    //        		Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
    //                if (correspAxioms == null) {
    //        			correspAxioms = new ArrayList<OWLAxiom>();
    //        			dlClauses.put(dlClause, correspAxioms);
    //        		}
    //        		correspAxioms.add(entry.getKey());
    //        	}
    //        }
    //        for (OWLDataRange[] inclusion : axioms.m_auxiliaryDataRangeInclusions) {
    //            for (OWLDataRange description : inclusion)
    //                description.accept(normalizedDataRangeAxiomClausifier);
    //            DLClause
    // dlClause=normalizedDataRangeAxiomClausifier.getDLClause().getSafeVersion(InternalDatatype.RDFS_LITERAL);
    //            Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
    //            if (correspAxioms == null) {
    //    			correspAxioms = new ArrayList<OWLAxiom>();
    //    			dlClauses.put(dlClause, correspAxioms);
    //    		}
    //        }
    //        for (Entry<OWLAxiom,OWLHasKeyAxiom> entry : axioms.m_hasKeys_map.entrySet()) {
    //        	DLClause dlClause = clausifyKey(entry.getValue());
    //        	Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause);
    //            if (correspAxioms == null) {
    //    			correspAxioms = new ArrayList<OWLAxiom>();
    //    			dlClauses.put(dlClause, correspAxioms);
    //    		}
    //    		correspAxioms.add(entry.getKey());
    //        }

    FactClausifier_withMaps factClausifier =
        new FactClausifier_withMaps(dataRangeConverter, positiveFacts, negativeFacts);
    for (Entry<OWLAxiom, Collection<OWLIndividualAxiom>> entry : axioms.m_facts_map.entrySet())
      for (OWLIndividualAxiom fact : entry.getValue()) factClausifier.process(entry.getKey(), fact);
    for (Atom atom : auxiliaryFacts) {
      Collection<OWLAxiom> originalAxioms = positiveFacts.get(atom);
      if (originalAxioms == null) {
        originalAxioms = new ArrayList<OWLAxiom>();
        positiveFacts.put(atom, originalAxioms);
      }
    }
    //		OWLLiteral[] literals = new OWLLiteral[axioms.m_literals.size()];
    //		int i = 0;
    //		for (OWLLiteral lit : axioms.m_literals)
    //			literals[i++] = lit;
    //		for (i = 0; i<literals.length; i++)
    //			for (int j = i+1; j<literals.length; j++) {
    //				factClausifier.process(null,
    // factory.getOWLDifferentIndividualsAxiom(factory.getOWLNamedIndividual(IRI.create(literals[i].toString())), factory.getOWLNamedIndividual(IRI.create(literals[j].toString()))));
    //				//        		positiveFacts.put(Atom.create(Inequality.INSTANCE, literals[i], literals[j]),
    // new ArrayList<OWLAxiom>());
    //			}

    Set<Individual> individuals = new HashSet<Individual>();
    for (OWLNamedIndividual owlIndividual : axioms.m_namedIndividuals) {
      Individual individual = Individual.create(owlIndividual.getIRI().toString());
      individuals.add(individual);
      // all named individuals are tagged with a concept, so that keys/rules are
      // only applied to them
      if (!axioms.m_hasKeys.isEmpty() || !axioms.m_rules.isEmpty()) {
        Atom atom = Atom.create(AtomicConcept.INTERNAL_NAMED, individual);
        Collection<OWLAxiom> originalAxioms = positiveFacts.get(atom);
        if (originalAxioms == null) {
          originalAxioms = new ArrayList<OWLAxiom>();
          positiveFacts.put(atom, originalAxioms);
        }
      }
    }

    // Clausify SWRL rules
    if (!axioms.m_rules.isEmpty())
      new NormalizedRuleClausifier_withMaps(
              axioms.m_objectPropertiesOccurringInOWLAxioms, dataRangeConverter, dlClauses)
          .processRules(axioms.m_rules_map);
    // Create the DL ontology
    return new DLOntology_withMaps(dlClauses, positiveFacts, negativeFacts, axioms.m_literals);
  }