Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solving Einstein's riddle (zebra puzzle) #3

Open
blokhin opened this issue Dec 6, 2017 · 10 comments
Open

Solving Einstein's riddle (zebra puzzle) #3

blokhin opened this issue Dec 6, 2017 · 10 comments
Assignees

Comments

@blokhin
Copy link

blokhin commented Dec 6, 2017

Dear all,

there are two known implementations of the famous Einstein's riddle (zebra puzzle) in OWL:

Unlike Protégé, this brute-force reasoner fails to solve both of these implementations (an expanded graph does not contain any triples connecting zebra and Japanese, which is an answer).

Is it an expected behavior?

@nicholascar
Copy link
Member

I will look into this after the Python3 version is properly released

@nicholascar nicholascar self-assigned this Feb 21, 2018
@blokhin
Copy link
Author

blokhin commented Aug 9, 2018

@nicholascar my understanding is that the expressivity of these two ontologies is just too high. Please, correct me if I'm wrong.

@blokhin
Copy link
Author

blokhin commented Oct 11, 2018

@iherman what do you think?

@ashleysommer
Copy link
Collaborator

@blokhin I've been looking into how these zebra-puzzle ontologies work within this implementation of OWL-RL, why they don't produce a solution, and what it would take for this implementation to be able to solve this puzzle using those ontologies.

I think it comes down to the restrictions of the specific flavour of OWL (RL) that is used.

See this page: https://www.w3.org/TR/owl2-profiles/#OWL_2_RL

[OWL-RL is] designed to accommodate both OWL 2 applications that can trade the full expressivity of the language for efficiency ...

This is achieved by defining a syntactic subset of OWL 2 which is amenable to implementation using rule-based technologies ... and presenting a partial axiomatization of the OWL 2 RDF-Based Semantics

a suitable rule-based implementation ... will have desirable computational properties; for example, it can return all and only the correct answers to certain kinds of query

Such an implementation can also be used with arbitrary RDF graphs. In this case, however, these properties no longer hold — in particular, it is no longer possible to guarantee that all correct answers can be returned

And in the Computational Properties section: https://www.w3.org/TR/owl2-profiles/#Computational_Properties

OWL-RL is PTIME-complete

PTIME is the class of problems solvable by a deterministic algorithm using time that is at most polynomial in the size of the input.

So by using a brute-force axiomatic rule-base approach (for performance, efficiency, and simplicity reasons), this implementation conforms to OWL-RL entailments/inferences but does not go as far as to automatically solve this kind of puzzle.

It seems to me that solving this puzzle would require the integration of a backtracking-capable Constraint Solving Problem resolver (CSP) such as https://labix.org/python-constraint. The OWL inferencer could build the constraints using an OWL->CSP axiom mapping, then after the OWL inferencing has finished, it could run the CSP resolver to get the solutions and plug them into the graph.

Unfortunately by doing this, it introduces a further layer of complexity to the OWL inferencer, and will significantly slow down the inferencing process. Furthermore, by doing this the problem is no longer solvable in PTIME, and is starting to stray away from the strictly rule-based approach of OWL-RL (correct me if I'm wrong).

@blokhin
Copy link
Author

blokhin commented Oct 13, 2018

@ashleysommer many thanks for your kind explanation. Actually, @wrobell tried to solve this riddle as a case study for FaCT++ reasoning using his new Python bindings for rdflib and, although succeeded, found an uncontrolled performance degradation. So indeed this riddle is difficult.

@blokhin
Copy link
Author

blokhin commented Apr 19, 2019

Well, it's not the Einstein's riddle is difficult, it's that the OWL2 QL/RL is difficult :)

And as far as I understand, the only way to tackle this difficulty is to resolve for heuristics... causing sometimes the uncontrolled performance degradations...

@cknoll
Copy link

cknoll commented Oct 23, 2020

I think the package owlready might be a way to go. I achieved to load the above ontologies but they seem to be incompletely represented. See this notebook for details:

https://github.com/cknoll/demo-material/blob/master/expertise_system/einstein-zebra-puzzle-owlready-solution-attempt.ipynb

I think, once the ontology is correctly loaded/represented the solution could be obtained via something like owlready2.sync_reasoner_pellet(infer_property_values=True, infer_data_property_values=True)

For Reference: I have two pending questions concerning this topic:

@cknoll
Copy link

cknoll commented Oct 24, 2020

Update: with the first ontology file I now get convincing results with the pellet-reasoner:

https://github.com/cknoll/demo-material/blob/master/expertise_system/einstein-zebra-puzzle-owlready-solution1.ipynb

@nicholascar
Copy link
Member

So I guess owlread2 is using Pellet in DL mode underneath? I don't think we have a DL reasoner in Python, or at least not one for use with RDFlib!

I now have a student looking at updating OWL-RL (and probably renaming it) and I want to see support for EL & QL, as well as the current RDFS & RL. I also want assurance that all RL reasoning is being carried out properly, but I don't have plans for DL reasoning as that's a very different thing.

@blokhin
Copy link
Author

blokhin commented Sep 14, 2024

Out of rigorousness, here’s the solution using FaCT++ reasoner in Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants