sempr-tk / sempr

SEMPR - Semantic Environment Mapping, Processing and Reasoning
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

SopranoModule Inference loop #34

Open niniemann opened 6 years ago

niniemann commented 6 years ago

initial situation

Rule: [equivalentSymmetric: (?a owl:equivalentClass ?b) -> (?b owl:equivalentClass ?a)]

Model: (foo owl:equivalentClass bar) (bar owl:equivalentClass foo) << inferred

what I did

remove the first statement

what happened

Model: (foo owl:equivalentClass bar) << inferred (bar owl:equivalentClass foo) << inferred

what to do?

The commit 01e2f4b20402ba325a71b6dca82b0a3a13e84f45 fixes this problem for my special use case, but makes everything slower -- every insert and removal takes longer, as well as every sparql query. Where before only the first query was slow, and all removals/insertions were fast.

The problem seems to be the consecutive call of performInference(), which is still called when rules are added/removed! The documentation says this should be fine, though:

Normally inferencing is done once new statements are added to the model or statements are removed. This method performs inferencing on the whole model. It is useful for initializing a model that already contains statements or update the model if it has been modified bypassing this filter model.

I don't really know how to solve this yet, or why it's so slow...

niniemann commented 6 years ago

Small addition:

clearInference(): Removes all statements infered by this model. This can be useful if the parent model has been changed without informing the inference model and statements have been removed.

Does this imply that we have to use "clearInference()" when removing statements from the parent model? And "performInference()" alone is only okay if nothing was removed, only added?