@Override protected Boolean defaultVisit(ClassConclusion conclusion) { Context originContext = state_.getContext(conclusion.getTraceRoot()); if (originContext.isInitialized() && originContext.isSaturated()) { LOGGER_.error("{}: adding conclusion {} to saturated context {}", contextRef_, conclusion, get().containsConclusion(conclusion) ? "(it is already there)" : ""); } return true; }
@Override public void execute() throws ElkException { // check roots for all contexts now for (Context context : reasoner_.saturationState.getContexts()) { if (!context.getComposedSubsumers().contains(context.getRoot())) { LOGGER_.error(context.getRoot() + (context.isSaturated() ? " [saturated]" : " [modified]") + ": not a subsumer of itself"); } ClassInference inference = context.takeToDo(); if (inference != null) { LOGGER_.error(context.getRoot() + ": non-empty TODO: " + inference); } } }
@Override protected Boolean defaultVisit(ClassConclusion conclusion) { Context context = get(); boolean result = context.addConclusion(conclusion); if (LOGGER_.isTraceEnabled()) { LOGGER_.trace("{}: inserting {}: {}", context, conclusion, result ? "success" : "failure"); } return result; }
@Override public boolean holds(final IndexedContextRoot root) { final Context context = saturationState_.getContext(root); return context == null || !context.isInitialized() || !context.isSaturated(); } };
@Override public void contextMarkSaturated(C context) { IndexedContextRoot root = context.getRoot(); if (!context.containsConclusion( conclusionFactory_.getContradiction(root))) { return; } // else if (root instanceof IndexedIndividual) { tellInconsistentIndividual( (IndexedIndividual) root); } else if (root == owlThing_) { tellInconsistentOwlThing(); } }
.getContextInitialization(context.getRoot()); LinkedContextInitRule nextContextInitRule = changedContextInitRuleHead_; while (nextContextInitRule != null) { .getComposedSubsumers(); if (composedSubsumers .size() > changedComposedSubsumers_.length >> 2) { .getDecomposedSubsumers(); if (decomposedSubsumers .size() > changedDecomposedSubsumers_.length >> 2) {
private void validate(Context context) { LOGGER_.trace("Validating context for " + context.getRoot()); IndexedContextRoot root = context.getRoot(); root.accept(rootValidator_); if (saturationState_.getContext(root) != context) .getComposedSubsumers()) { iceValidator_.checkNew(composedSubsumer); .getDecomposedSubsumers()) { iceValidator_.checkNew(decomposedSubsumer); .getSubContextPremisesByObjectProperty().values()) { for (IndexedContextRoot linkedRoot : subContext .getLinkedRoots()) { LinkableBackwardLinkRule rule = context.getBackwardLinkRuleHead();
cleanedContexts.add(context.getRoot()); if (!context.getComposedSubsumers().isEmpty()) { LOGGER_.error( "{}: context not cleaned: there are {} subsumers: {}", context, context.getComposedSubsumers().size(), context.getComposedSubsumers()); if (!context.getLocalReflexiveObjectProperties().isEmpty()) { LOGGER_.error( "{}: context not cleaned: there are {} backward reflexive properties: {}" + context, context .getLocalReflexiveObjectProperties().size(), context.getLocalReflexiveObjectProperties()); continue; Map<IndexedObjectProperty, ? extends SubContextPremises> subContextMap = context .getSubContextPremisesByObjectProperty(); for (IndexedPropertyChain ipc : subContextMap.keySet()) { for (IndexedContextRoot target : subContextMap.get(ipc)
@Override public void contextMarkNonSaturated(final C context) { final IndexedContextRoot root = context.getRoot(); if (root instanceof IndexedIndividual) { final IndexedIndividual ind = (IndexedIndividual) root; toRemove_.add(ind); } }
/** * Process all pending {@link ClassInference}s of the given {@link Context} * * @param context * the active {@link Context} with unprocessed * {@link ClassInference}s */ void process(Context context) { activeContext_.set(context); // at this point workerLocalTodo_ must be empty workerLocalTodo_.setActiveRoot(context.getRoot()); for (;;) { ClassInference inference = workerLocalTodo_.poll(); if (inference == null) { inference = context.takeToDo(); if (inference == null) return; } LOGGER_.trace("{}: processing inference {}", context, inference); inference.accept(inferenceProcessor_); } }
@Override public Collection<? extends EntailmentInference> getInferences( final Object conclusion) { if (!getQuery().equals(conclusion)) { return Collections.emptySet(); } // else final C context = saturationState.getContext(existential_); if (context == null) { // not entailed return Collections.emptySet(); } // else final SubClassInclusionComposed subsumption = conclusionFactory .getSubClassInclusionComposed(existential_, domain_); if (context.containsConclusion(subsumption)) { return Collections.singleton( new DerivedClassInclusionEntailsObjectPropertyDomainAxiomImpl( getQuery(), subsumption)); } // else return Collections.emptySet(); }
@Override protected Boolean defaultVisit(ClassConclusion conclusion) { Context context = get(); IndexedContextRoot root = context.getRoot(); if (context.isEmpty()) { producer_.produce(new ContextInitializationNoPremises(root)); } if (conclusion instanceof SubClassConclusion) { IndexedObjectProperty subRoot = ((SubClassConclusion) conclusion) .getSubDestination(); if (context.isEmpty(subRoot)) { producer_.produce( new SubContextInitializationNoPremises(root, subRoot)); } } return super.defaultVisit(conclusion); } }
/** * Constructing the state for the initiator job. It is required that the * saturation is already computed for the root of the initiator job. * * @param initiatorJob * @param saturationState */ TransitiveReductionState(J initiatorJob, SaturationState<?> saturationState) { this.initiatorJob = initiatorJob; this.rootEquivalent = new ArrayList<ElkClass>(1); this.prunedSubsumers = new ArrayHashSet<IndexedClass>(8); Set<IndexedClassExpression> subsumers = saturationState.getContext( initiatorJob.getInput()).getComposedSubsumers(); this.subsumerIterator = subsumers.iterator(); this.subsumerCount = subsumers.size(); }
/** * Remove the {@link ContradictionOverBackwardLinkRule} from the * {@link BackwardLinkRule}s of the given {@link Context} * * @param context */ public static void removeFrom(Context context) { context.getBackwardLinkRuleChain().remove(MATCHER_); }
/** * Removes from {@link #toDoEntities_} the entities which no longer occur in * the ontology or for the context is already saturated (thus consistency is * already checked) * * @return the number of the remaining entries in {@link #toDoEntities_} */ private int pruneToDo() { int size = 0; Iterator<IndexedClassEntity> itr = toDoEntities_.iterator(); while (itr.hasNext()) { IndexedClassEntity next = itr.next(); if (!next.occurs()) { itr.remove(); continue; } // else Context context = saturationState_.getContext(next); if (context != null && context.isSaturated()) { itr.remove(); } else { size++; } } return size; }
@Override public Boolean visit( ContextInitialization conclusion) { IndexedContextRoot root = conclusion .getTraceRoot(); Context mainContext = mainSaturationState_ .getContext(root); for (IndexedObjectProperty subRoot : mainContext .getSubContextPremisesByObjectProperty() .keySet()) { localWriter.produce( new SubContextInitializationNoPremises( root, subRoot)); } return true; } })));
@Override public boolean holds(final IndexedContextRoot root) { final Context context = saturationState_.getContext(root); return context == null || !context.isInitialized() || !context.isSaturated(); } };
@Override public void contextMarkSaturated(C context) { IndexedContextRoot root = context.getRoot(); if (!context.containsConclusion( conclusionFactory_.getContradiction(root))) { return; } // else if (root instanceof IndexedIndividual) { tellInconsistentIndividual( (IndexedIndividual) root); } else if (root == owlThing_) { tellInconsistentOwlThing(); } }
.getContextInitialization(context.getRoot()); LinkedContextInitRule nextContextInitRule = changedContextInitRuleHead_; while (nextContextInitRule != null) { .getComposedSubsumers(); if (composedSubsumers .size() > changedComposedSubsumers_.length >> 2) { .getDecomposedSubsumers(); if (decomposedSubsumers .size() > changedDecomposedSubsumers_.length >> 2) {
@Override public void contextMarkNonSaturated(final C context) { final IndexedContextRoot root = context.getRoot(); if (root instanceof IndexedClass) { final IndexedClass cls = (IndexedClass) root; toRemove_.add(cls); } }