This repo contains a group project from the course Knowledge Representation (2024-25) at the Vrije Universiteit Amsterdam (VU). The task was to create an intelligent reasoning system based on Description Logic (DL) consisting of an ontology and a reasoner based on Efficient Reasoning (EL). The goal of this system was to query a restaurant's menu items - in our case the restaurant theme is Curry.
The Curry ontology is inspired by the pizza ontology and employs Attributive Concept Language with Complements (ALC). In addition, we enhanced the Curry ontology to go beyond the expressivity of ALC, for example through the use of transitive roles, inversion, and nominals. It is a consistent ontology and contains 260 axioms, 70 classes, eight roles, and four individuals. In addition, the ontology includes 107 subclasses, 11 equivalences, and 14 disjoint classes. Examples of classes are MassamanCurry, CurryIngredient, or Chicken. Examples of roles include hasCurryIngredient or hasSpiciness. More examples of the Curry ontology can be found in the report. The Curry ontology was implemented using the software tool Protegé.
To query the Curry ontology, we implemented an EL reasoner using the dl4python library, also described below. The assignment required that the reasoner would return all subsumers of a given class. The efficiency of EL is obtained by the use of a restricted set of logical constructors, namely
The report contains further details on the structure of the reasoner and ontology and provides a nuanced perspective on several challenges. In addition, we evaluate how the expressivity of the Curry ontology requires a similar level of expressivity from the reasoner. While EL reasoners are popular due to their efficiency in the case of this small ontology it is more pragmatic to apply reasoners such as HermiT, which allow for higher expressivity, and thus more sophisticated queries.
These instructions will give you a copy of the project up and running on your local machine.
Requirements for the software and other tools to build, test, and push
- Python 3.10 or higher
- Java 23
This codebase was programmed using python 3.10.1. The requirements.txt file contains all the need packages to run the code succesfully.
Download this code base by running the following line in your terminal:
git clone https://github.com/mklblm/KR-EL-Reasoner
Install all required packages by running the following line in your terminal:
pip install -r requirements.txt
This project was creating using the dl4python library. The libary is created specifically for the Knowledge Representation course at the Vrije Universiteit Amsterdam, in order for students to work with OWL ontologies in python instead of Java. In order to use dl4python, a number of preparation steps are necessary:
-
Make sure recent versions of Python and Java are installed.
-
Make sure Py4J is installed. This library is included in the requirements.txt file, and should thus be installed if all previous installation steps were followed. Alternatively, type the following command in the terminal:
pip install py4j
-
In order to use the dl4python library and run the EL Reasoner, a gateway server between Python and Java needs to be running. Do so by typing the following command in the terminal:
java -jar dl4python-0.1.2-jar-with-dependencies.jar
-
This gateway should be opened in the same folder as the python files using the dl4python library you want to run. Keep the gateway running while you want to run the python files.
-
Open a new terminal to run the python files.
The EL reasoner can be run by calling the following command in the terminal:
python main.py ontology_file_path class_name
- ontology_file_path should contain the path to an OWL ontology file.
- class_name should contain the name of a class in the ontology file for which you want to find the subsumers.
Below is an example command that can be used to find the subsumers of the "MassamanCurry" class in the curry_ontology.rdf file.
python main.py ontologies/curry_ontology.rdf '"MassamanCurry"'
The output of this command will look like this:
NamedCurry
Food
MassamanCurry
CreamBasedCurry
Domain Thing
Curry
ChickenCurry
⊤
The printed classes are the found subsumers for the MassamanCurry class. This list can be compared to the curry ontology file itself.
Other examples can be run by replacting "MassamanCurry" with any other named class, e.g. "Coriander" or "ChickenCurry".
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.txt file for details
- Patrick Koopman, the lecturer of Knowledge Representation, who has provided us with the dl4python files and documentation.