default boolean removeDomain(final ATerm p, final ATermAppl domain) { if (!OpenlletOptions.USE_TRACING) return false; final Role r = getRole(p); if (r == null) return false; final Map<ATermAppl, Set<Set<ATermAppl>>> domains = getDomainAssertions().get(r); if (domains == null) return false; final Set<Set<ATermAppl>> allExplanations = domains.get(domain); if (allExplanations == null) return false; final Set<ATermAppl> explanation = Collections.singleton(ATermUtils.makeDomain(p, domain)); if (!allExplanations.remove(explanation)) return false; if (allExplanations.isEmpty()) domains.remove(domain); return true; }
default boolean removeDomain(final ATerm p, final ATermAppl domain) { if (!OpenlletOptions.USE_TRACING) return false; final Role r = getRole(p); if (r == null) return false; final Map<ATermAppl, Set<Set<ATermAppl>>> domains = getDomainAssertions().get(r); if (domains == null) return false; final Set<Set<ATermAppl>> allExplanations = domains.get(domain); if (allExplanations == null) return false; final Set<ATermAppl> explanation = Collections.singleton(ATermUtils.makeDomain(p, domain)); if (!allExplanations.remove(explanation)) return false; if (allExplanations.isEmpty()) domains.remove(domain); return true; }
/** * Add a non-asserted property domain axiom * * @param p The property * @param domain A class expression for the domain * @param explanation A set of {@link ATermAppl}s that explain the domain axiom. * @return <code>true</code> if domain add was successful, <code>false</code> else * @throws IllegalArgumentException if <code>p</code> is not a defined property. */ default boolean addDomain(final ATerm p, final ATermAppl domain, 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>>> domains = getDomainAssertions().get(r); if (domains == null) { domains = new ConcurrentHashMap<>(); getDomainAssertions().put(r, domains); } Set<Set<ATermAppl>> allExplanations = domains.get(domain); if (allExplanations == null) { allExplanations = SetUtils.create(); domains.put(domain, allExplanations); } return allExplanations.add(explanation); }
/** * Add a non-asserted property domain axiom * * @param p The property * @param domain A class expression for the domain * @param explanation A set of {@link ATermAppl}s that explain the domain axiom. * @return <code>true</code> if domain add was successful, <code>false</code> else * @throws IllegalArgumentException if <code>p</code> is not a defined property. */ default boolean addDomain(final ATerm p, final ATermAppl domain, 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>>> domains = getDomainAssertions().get(r); if (domains == null) { domains = new ConcurrentHashMap<>(); getDomainAssertions().put(r, domains); } Set<Set<ATermAppl>> allExplanations = domains.get(domain); if (allExplanations == null) { allExplanations = SetUtils.create(); domains.put(domain, allExplanations); } return allExplanations.add(explanation); }
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); } }