Map<OWLObjectPropertyExpression,Automaton> automataMap=new HashMap<OWLObjectPropertyExpression,Automaton>();
for (OWLAxioms.ComplexObjectPropertyInclusion inclusion : complexObjectPropertyInclusions) {
OWLObjectPropertyExpression[] subObjectProperties=inclusion.m_subObjectProperties;
OWLObjectPropertyExpression superObjectProperty=inclusion.m_superObjectProperty;
Automaton automaton=null;
State initialState=null;
State finalState=null;
if (!automataMap.containsKey(superObjectProperty)) {
automaton=new Automaton();
initialState=automaton.addState(true,false);
finalState=automaton.addState(false,true);
try {
automaton.addTransition(new Transition(initialState,superObjectProperty,finalState));
}
catch (NoSuchStateException e) {
throw new IllegalArgumentException("Could not create automaton");
}
}
else {
automaton=automataMap.get(superObjectProperty);
initialState=(State)automaton.initials().iterator().next();
finalState=(State)automaton.terminals().iterator().next();
}
// RR->R
if (subObjectProperties.length==2 && subObjectProperties[0].equals(superObjectProperty) && subObjectProperties[1].equals(superObjectProperty)) {
try {
automaton.addTransition(new Transition(finalState,null,initialState));
transitiveProperties.add(superObjectProperty);
}
catch (NoSuchStateException e) {
throw new IllegalArgumentException("Could not create automaton");
}
}
// R S2...Sn->R
else if (subObjectProperties[0].equals(superObjectProperty)) {
State fromState=finalState;
OWLObjectPropertyExpression transitionLabel;
for (int i=1;i<subObjectProperties.length-1;i++) {
transitionLabel=subObjectProperties[i];
if (equivalentPropertiesMap.containsKey(superObjectProperty) && equivalentPropertiesMap.get(superObjectProperty).contains(transitionLabel))
transitionLabel=superObjectProperty;
try {
fromState=addNewTransition(automaton,fromState,transitionLabel);
}
catch (NoSuchStateException e) {
throw new IllegalArgumentException("Could not create automaton");
}
}
try {
transitionLabel=subObjectProperties[subObjectProperties.length-1];
if (equivalentPropertiesMap.containsKey(superObjectProperty) && equivalentPropertiesMap.get(superObjectProperty).contains(transitionLabel))
transitionLabel=superObjectProperty;
automaton.addTransition(new Transition(fromState,transitionLabel,finalState));
}
catch (NoSuchStateException e) {
throw new IllegalArgumentException("Could not create automaton");
}
}
// S1...Sn-1 R->R
else if (subObjectProperties[subObjectProperties.length-1].equals(superObjectProperty)) {
State fromState=initialState;
OWLObjectPropertyExpression transitionLabel;
for (int i=0;i<subObjectProperties.length-2;i++) {
transitionLabel=subObjectProperties[i];
if (equivalentPropertiesMap.containsKey(superObjectProperty) && equivalentPropertiesMap.get(superObjectProperty).contains(transitionLabel))
transitionLabel=superObjectProperty;
try {
fromState=addNewTransition(automaton,fromState,transitionLabel);
}
catch (NoSuchStateException e) {
throw new IllegalArgumentException("Could not create automaton");
}
}
try {
transitionLabel=subObjectProperties[subObjectProperties.length-2];
if (equivalentPropertiesMap.containsKey(superObjectProperty) && equivalentPropertiesMap.get(superObjectProperty).contains(transitionLabel))
transitionLabel=superObjectProperty;
automaton.addTransition(new Transition(fromState,transitionLabel,initialState));
}
catch (NoSuchStateException e) {
throw new IllegalArgumentException("Could not create automaton");
}
}
// S1...Sn->R
else {
State fromState=initialState;
OWLObjectPropertyExpression transitionLabel;
for (int i=0;i<subObjectProperties.length-1;i++) {
transitionLabel=subObjectProperties[i];
if (equivalentPropertiesMap.containsKey(superObjectProperty) && equivalentPropertiesMap.get(superObjectProperty).contains(transitionLabel))
transitionLabel=superObjectProperty;