/** * Add a non-asserted property range axiom * * @param p The property * @param range * @param explanation * @param a A class expression for the domain * @param clashExplanation A set of {@link ATermAppl}s that explain the range axiom. * @return <code>true</code> if range add was successful, <code>false</code> else * @throws IllegalArgumentException if <code>p</code> is not a defined property. */ default boolean addRange(final ATerm p, final ATermAppl range, final Set<ATermAppl> explanation) { final Role r = getRole(p); if (r == null) throw new IllegalArgumentException(p + " is not defined as a property"); Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(r); if (ranges == null) { ranges = new ConcurrentHashMap<>(); getRangeAssertions().put(r, ranges); } Set<Set<ATermAppl>> allExplanations = ranges.get(range); if (allExplanations == null) { allExplanations = new HashSet<>(); ranges.put(range, allExplanations); } return allExplanations.add(explanation); }
/** * Add a non-asserted property range axiom * * @param p The property * @param range * @param explanation * @param a A class expression for the domain * @param clashExplanation A set of {@link ATermAppl}s that explain the range axiom. * @return <code>true</code> if range add was successful, <code>false</code> else * @throws IllegalArgumentException if <code>p</code> is not a defined property. */ default boolean addRange(final ATerm p, final ATermAppl range, final Set<ATermAppl> explanation) { final Role r = getRole(p); if (r == null) throw new IllegalArgumentException(p + " is not defined as a property"); Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(r); if (ranges == null) { ranges = new ConcurrentHashMap<>(); getRangeAssertions().put(r, ranges); } Set<Set<ATermAppl>> allExplanations = ranges.get(range); if (allExplanations == null) { allExplanations = new HashSet<>(); ranges.put(range, allExplanations); } return allExplanations.add(explanation); }
default boolean removeRange(final ATerm p, final ATermAppl range) { if (!OpenlletOptions.USE_TRACING) return false; final Role r = getRole(p); if (r == null) return false; final Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(r); if (ranges == null) return false; final Set<Set<ATermAppl>> allExplanations = ranges.get(range); if (allExplanations == null) return false; final Set<ATermAppl> explanation = Collections.singleton(ATermUtils.makeRange(p, range)); if (!allExplanations.remove(explanation)) return false; if (allExplanations.isEmpty()) ranges.remove(range); return true; }
default boolean removeRange(final ATerm p, final ATermAppl range) { if (!OpenlletOptions.USE_TRACING) return false; final Role r = getRole(p); if (r == null) return false; final Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(r); if (ranges == null) return false; final Set<Set<ATermAppl>> allExplanations = ranges.get(range); if (allExplanations == null) return false; final Set<ATermAppl> explanation = Collections.singleton(ATermUtils.makeRange(p, range)); if (!allExplanations.remove(explanation)) return false; if (allExplanations.isEmpty()) ranges.remove(range); return true; }
default void propagateDomainRange() { for (final Role role : getRoles().values()) role.resetDomainRange(); for (final Role role : getRoles().values()) { final Role invRole = role.getInverse(); if (invRole != null) { final Map<ATermAppl, Set<Set<ATermAppl>>> invDomains = getDomainAssertions().get(invRole); final Map<ATermAppl, Set<Set<ATermAppl>>> invRanges = getRangeAssertions().get(invRole); propogateDomain(role, invRanges); propogateRange(role, invDomains); } final Map<ATermAppl, Set<Set<ATermAppl>>> domains = getDomainAssertions().get(role); final Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(role); propogateDomain(role, domains); propogateRange(role, ranges); } }
default void propagateDomainRange() { for (final Role role : getRoles().values()) role.resetDomainRange(); for (final Role role : getRoles().values()) { final Role invRole = role.getInverse(); if (invRole != null) { final Map<ATermAppl, Set<Set<ATermAppl>>> invDomains = getDomainAssertions().get(invRole); final Map<ATermAppl, Set<Set<ATermAppl>>> invRanges = getRangeAssertions().get(invRole); propogateDomain(role, invRanges); propogateRange(role, invDomains); } final Map<ATermAppl, Set<Set<ATermAppl>>> domains = getDomainAssertions().get(role); final Map<ATermAppl, Set<Set<ATermAppl>>> ranges = getRangeAssertions().get(role); propogateDomain(role, domains); propogateRange(role, ranges); } }