private TransitionGraph<Role> mirror(final TransitionGraph<Role> tg) { final Map<State<Role>, State<Role>> newStates = new HashMap<>(); final TransitionGraph<Role> mirror = new TransitionGraph<>(); final State<Role> oldInitialState = tg.getInitialState(); final State<Role> newFinalState = copyState(oldInitialState, mirror, newStates); mirror.addFinalState(newFinalState); final Set<State<Role>> oldFinalStates = tg.getFinalStates(); State<Role> newInitialState = null; if (oldFinalStates.size() == 1) { final State<Role> oldFinalState = oldFinalStates.iterator().next(); newInitialState = newStates.get(oldFinalState); } else { newInitialState = mirror.newState(); for (final State<Role> oldFinalState : oldFinalStates) mirror.addTransition(newInitialState, newStates.get(oldFinalState)); } mirror.setInitialState(newInitialState); return mirror; }
private TransitionGraph<Role> mirror(final TransitionGraph<Role> tg) { final Map<State<Role>, State<Role>> newStates = new HashMap<>(); final TransitionGraph<Role> mirror = new TransitionGraph<>(); final State<Role> oldInitialState = tg.getInitialState(); final State<Role> newFinalState = copyState(oldInitialState, mirror, newStates); mirror.addFinalState(newFinalState); final Set<State<Role>> oldFinalStates = tg.getFinalStates(); State<Role> newInitialState = null; if (oldFinalStates.size() == 1) { final State<Role> oldFinalState = oldFinalStates.iterator().next(); newInitialState = newStates.get(oldFinalState); } else { newInitialState = mirror.newState(); for (final State<Role> oldFinalState : oldFinalStates) mirror.addTransition(newInitialState, newStates.get(oldFinalState)); } mirror.setInitialState(newInitialState); return mirror; }
newStates.put(tg.getInitialState(), i);
newStates.put(tg.getInitialState(), i);
private boolean addRoleChainTransition(final TransitionGraph<Role> tg, final Role s, final ATermList chain) { final Role firstRole = _rbox.getRole(chain.getFirst()); final Role lastRole = _rbox.getRole(chain.getLast()); final boolean firstRoleSame = s.isEquivalent(firstRole); final boolean lastRoleSame = s.isEquivalent(lastRole); final int length = chain.getLength(); if (firstRoleSame) { if (lastRoleSame && length != 2) return false; addRoleChainTransition(tg, tg.getFinalState(), tg.getFinalState(), chain.getNext(), length - 1); } else if (lastRoleSame) addRoleChainTransition(tg, tg.getInitialState(), tg.getInitialState(), chain, length - 1); else addRoleChainTransition(tg, tg.getInitialState(), tg.getFinalState(), chain, length); return true; }
private boolean addRoleChainTransition(final TransitionGraph<Role> tg, final Role s, final ATermList chain) { final Role firstRole = _rbox.getRole(chain.getFirst()); final Role lastRole = _rbox.getRole(chain.getLast()); final boolean firstRoleSame = s.isEquivalent(firstRole); final boolean lastRoleSame = s.isEquivalent(lastRole); final int length = chain.getLength(); if (firstRoleSame) { if (lastRoleSame && length != 2) return false; addRoleChainTransition(tg, tg.getFinalState(), tg.getFinalState(), chain.getNext(), length - 1); } else if (lastRoleSame) addRoleChainTransition(tg, tg.getInitialState(), tg.getInitialState(), chain, length - 1); else addRoleChainTransition(tg, tg.getInitialState(), tg.getFinalState(), chain, length); return true; }
private static Bool checkAllValuesClash(final KnowledgeBase kb, final ATermAppl av, final CachedNode root, final CachedNode otherRoot) { ATerm r = av.getArgument(0); if (r.getType() == ATerm.LIST) r = ((ATermList) r).getFirst(); final Role role = kb.getRole(r); if (null == role) // FIXME : null is unexpected. return Bool.UNKNOWN; if (!role.hasComplexSubRole()) { if (otherRoot.hasRNeighbor(role)) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + role + " _neighbor"); return Bool.UNKNOWN; } } else { final TransitionGraph<Role> tg = role.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (otherRoot.hasRNeighbor(t.getName())) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + t.getName() + " _neighbor"); return Bool.UNKNOWN; } } return null; }
private static Bool checkAllValuesClash(final KnowledgeBase kb, final ATermAppl av, final CachedNode root, final CachedNode otherRoot) { ATerm r = av.getArgument(0); if (r.getType() == ATerm.LIST) r = ((ATermList) r).getFirst(); final Role role = kb.getRole(r); if (null == role) // FIXME : null is unexpected. return Bool.UNKNOWN; if (!role.hasComplexSubRole()) { if (otherRoot.hasRNeighbor(role)) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + role + " _neighbor"); return Bool.UNKNOWN; } } else { final TransitionGraph<Role> tg = role.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (otherRoot.hasRNeighbor(t.getName())) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has " + av + " " + otherRoot + " has " + t.getName() + " _neighbor"); return Bool.UNKNOWN; } } return null; }
@Override public void getObjectPropertyValues(final ATermAppl s, final Role role, final Set<ATermAppl> knowns, final Set<ATermAppl> unknowns, final boolean getSames) { assert isComplete() : "Initial consistency check has not been performed!"; Individual subj = getIndividual(s); boolean isIndependent = true; if (subj.isMerged()) { isIndependent = subj.getMergeDependency(true).isIndependent(); subj = subj.getSame(); } if (role.isSimple()) getSimpleObjectPropertyValues(subj, role, knowns, unknowns, getSames); else if (!role.hasComplexSubRole()) getTransitivePropertyValues(subj, role, knowns, unknowns, getSames, new HashMap<Individual, Set<Role>>(), true); else { final TransitionGraph<Role> tg = role.getFSM(); getComplexObjectPropertyValues(subj, tg.getInitialState(), tg, knowns, unknowns, getSames, new HashMap<Individual, Set<State<Role>>>(), true); } if (!isIndependent) { unknowns.addAll(knowns); knowns.clear(); } }
@Override public void getObjectPropertyValues(final ATermAppl s, final Role role, final Set<ATermAppl> knowns, final Set<ATermAppl> unknowns, final boolean getSames) { assert isComplete() : "Initial consistency check has not been performed!"; Individual subj = getIndividual(s); boolean isIndependent = true; if (subj.isMerged()) { isIndependent = subj.getMergeDependency(true).isIndependent(); subj = subj.getSame(); } if (role.isSimple()) getSimpleObjectPropertyValues(subj, role, knowns, unknowns, getSames); else if (!role.hasComplexSubRole()) getTransitivePropertyValues(subj, role, knowns, unknowns, getSames, new HashMap<Individual, Set<Role>>(), true); else { final TransitionGraph<Role> tg = role.getFSM(); getComplexObjectPropertyValues(subj, tg.getInitialState(), tg, knowns, unknowns, getSames, new HashMap<Individual, Set<State<Role>>>(), true); } if (!isIndependent) { unknowns.addAll(knowns); knowns.clear(); } }
private static boolean isAllValuesSafe(final KnowledgeBase kb, final Individual parent, final Role role, final ATermAppl term) { final Role s = kb.getRole(term.getArgument(0)); if (!s.hasComplexSubRole()) { final ATermAppl c = (ATermAppl) term.getArgument(1); if (role.isSubRoleOf(s) && !parent.hasType(c)) return false; } else { final TransitionGraph<Role> tg = s.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (role.isSubRoleOf(t.getName())) return false; } return true; }
private static boolean isAllValuesSafe(final KnowledgeBase kb, final Individual parent, final Role role, final ATermAppl term) { final Role s = kb.getRole(term.getArgument(0)); if (!s.hasComplexSubRole()) { final ATermAppl c = (ATermAppl) term.getArgument(1); if (role.isSubRoleOf(s) && !parent.hasType(c)) return false; } else { final TransitionGraph<Role> tg = s.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (role.isSubRoleOf(t.getName())) return false; } return true; }
final Iterator<Transition<Role>> it = tg.getInitialState().getTransitions().iterator(); while (!found && it.hasNext())
final Iterator<Transition<Role>> it = tg.getInitialState().getTransitions().iterator(); while (!found && it.hasNext())