Skip to content
AI.info

Research

Implementing Knowledge Representation and Reasoning with Object Oriented Design

Overview Research area: Knowledge Representation and Reasoning (KRR) applied to software engineering and cognitive robotics — specifically, unifying logic-based knowledge representation with object-or

arXiv
2601.14840
Published
2026-01-21
Authors
Abdelrhman Bassiouny, Tom Schierenbeck, Sorin Arion, Benjamin Alt, Naren Vasantakumaar, Giang Nguyen, Michael Beetz

AI summary

Overview

Research area: Knowledge Representation and Reasoning (KRR) applied to software engineering and cognitive robotics — specifically, unifying logic-based knowledge representation with object-oriented programming (OOP) in Python.

Technical level: Advanced. The paper assumes familiarity with description logics, OWL, conjunctive queries, rule-based reasoning, and object-relational mapping.

Scope: The paper presents KRROOD, an open-source Python framework that treats knowledge as a first-class programming abstraction, and evaluates it on the OWL2Bench benchmark and a human-robot interactive task-learning scenario.

What This Paper Is About

Developers building intelligent systems maintain two separate worlds: their application code, written in object-oriented languages like Python, and their knowledge bases, written in logic-based languages like OWL or Prolog. Keeping these two representations in sync is error-prone — the authors call this an "object-ontological equivalent of the Object-Relational Impedance Mismatch." KRROOD's goal is to eliminate that split by letting developers represent, query, reason over, and persist knowledge using ordinary Python classes and data structures.

Key Contributions

  1. A Python-native knowledge representation. Domain entities are modeled as Python classes, relations as class attributes and n-ary functions, and taxonomic relations through inheritance — with class methods able to express statements that hold generally for the class.

  2. EQL, a declarative querying language. A Select-Where-From style language over Python data structures that extends conjunctive queries with unions of conjunctive queries, negation as failure, and a restricted form of universal quantification over the active domain — remaining decidable and tractable.

  3. A Python-native RDR (Ripple Down Rules) implementation. Rule bases are built incrementally through expert interaction at runtime, with conflicts auto-detected and resolved by prompting the expert for a distinguishing condition. It extends traditional RDR with flexible case representation (arbitrary Python objects), rule conditions as executable Python code, auto-generated maintainable rule modules, and an interactive rule-writing prompt.

  4. ORMatic and Ontomatic. ORMatic is a persistence layer that auto-generates an SQLAlchemy interface mirroring existing Python dataclasses and converts domain objects to DAOs and back, aiming to keep the data model and domain model identical. Ontomatic converts OWL ontologies into object-oriented Python structures in two phases, handling non-disjoint sibling classes via a Role pattern and encoding OWL axioms as class-level EQL verification predicates.

Main Findings

  • Loading and reasoning performance is competitive: KRROOD took 8.32 s to reason over raw data and 127.89 s over previously materialized inferences, compared to 5.465 s / 22.032 s for Protégé with Pellet, 1820 s / 1606 s for GraphDB, 36.011 s / more than 10800 s for RDFLib, and 203.914 s raw / out-of-memory on reasoned data for owlready2. HermiT was excluded due to consistent memory failures, and RDFlib with owlrl failed to terminate within 180 minutes. The raw data contained 54,897 statements; the reasoned data contained 1,502,966 statements.

  • Protégé is fastest at reasoning but memory-hungry: It required approximately 5 GB for reasoning and 25 GB for RDF/XML export, which the authors say limits scalability.

  • GraphDB is the most reliable alternative: It showed consistent performance (1820 s raw, 1606 s reasoned) with stable memory usage across ontology scales.

  • SQLAlchemy offers the fastest querying: On the OWL2Bench RL profile queries, SQLAlchemy achieved the best geometric mean at 3.39 ms, followed by GraphDB (8.07), EQL (19.72), RDFLib (26.45), owlready2 (49.82), and Protégé (78.33). Times were averaged over 10 runs, and all frameworks returned the same set of entities.

  • EQL trades raw speed for usable domain objects: KRROOD with EQL is not always the fastest but provides fully capable domain objects, which the authors argue is necessary for native integration into cognitive system architectures.

  • Two queries were problematic across frameworks: Protégé failed to terminate on Query 20, and Q12 was omitted because it would require modeling ResearchGroup as a subclass of both Organization and Person, violating the Liskov Substitution Principle.

  • Eager reasoning over all properties is prohibitively slow: Handling transitive and symmetric properties eagerly increased reasoning time from about 15 seconds to around 100 minutes, which motivated the post-processing step that computes weakly connected components of induced subgraphs.

  • The robot experiment worked end to end: In a demonstration-feedback-generalization loop with a Montessori box, the human demonstrated a correct object insertion, the robot attempted the task, requested a corrective demonstration via audio after failure, inferred the object-hole matching constraint, and then completed the insertion task for the remaining objects.

  • Explanations come from two capabilities: The system can trace which rules contributed to a conclusion, and EQL can access domain knowledge represented as class data structures, including the inference rules themselves.

Methodology in Plain English

The authors start from the observation that KRR systems and application code live in different worlds, then build a framework that removes the boundary rather than papering over it.

First, they let ordinary Python classes and dataclasses stand in for knowledge-base concepts — a class is a concept, an attribute is a relation, and inheritance is a taxonomic link. Second, they design EQL so programs can ask structured questions of those objects without leaving Python, borrowing the familiar Select-Where-From pattern and deliberately limiting the logic so queries remain decidable and tractable. Third, for rules, they implement Ripple Down Rules, where an expert adds rules one at a time and the system detects conflicts and asks the expert what distinguishes the conflicting cases, then automatically inserts the answer as a refinement. Fourth, they build Ontomatic to translate OWL ontologies into Python classes, using a Role pattern to handle cases where sibling classes are not disjoint, and encoding OWL axioms as class methods that run EQL checks. Fifth, they build ORMatic to persist those classes in a relational database automatically.

For evaluation, they auto-generate an object-oriented model from the OWL2Bench ontology, derive an ORM interface, persist the data in PostgreSQL, and compare against other systems. They also run a human-robot experiment in which a person demonstrates pick-and-insert actions in VR (recorded in Multiverse, rendered in Unreal Engine 5, simulated with MuJoCo) while the Segmind framework — built on KRROOD — annotates actions and reasons about events.

Why This Matters

Impact on research. The paper argues that bridging the KRR/OOP gap requires treating knowledge as a first-class programming abstraction rather than an external resource. If that holds, it changes how knowledge-based systems are engineered: no separate ontology files, no batch export to an external reasoner, no parallel representations to synchronize. Notably, all other systems the authors compare against delegate inference externally or do not support rule-based reasoning at all.

Real-world applications (as described or motivated in the paper):

  • Interactive robot task learning — the demonstrated scenario, where a robot learns pick-and-insert tasks from human demonstration and corrects itself after failure.
  • Cognitive robot architectures — KRROOD is integrated into a robot cognitive architecture, providing what the authors call foundational capabilities for hybrid physical AI, including episodic memory components.
  • Machine learning pipelines — ORMatic was designed with ML compatibility in mind, since ML typically requires tabular data as input.
  • Ontology migration — Ontomatic automatically converts existing OWL ontologies into object-oriented Python data structures, relevant for groups with legacy knowledge bases.

Industry relevance. The work targets developers who already use Python for perception, planning, and learning and want reasoning without adopting a second paradigm, language, or tooling ecosystem. Because KRROOD is fully open source and uses standard Python, SQLAlchemy, and relational databases, it fits existing development workflows and IDE tooling. The cost is that object materialization adds loading overhead and can consume memory and latency at large scale, though reasoning with KRROOD is described as orders of magnitude more memory-efficient than OWL-based alternatives.

Future Directions

  • Defining stricter EQL fragments with explicit complexity bounds, so that practitioners can reason about worst-case runtime and termination guarantees.

  • Hybrid materialization strategies that instantiate only task-relevant subgraphs on demand, rather than materializing rich object graphs up front.

  • Large-scale, long-horizon evaluation of KRROOD on intelligent robot task planning and control.

  • Further work on human-robot task learning and explainable machine learning, plus addressing whether Ontomatic's OWL conversion can be made more lossless given modeling mismatches such as non-disjoint sibling classes.

Target Audience

Researchers and engineers working on knowledge representation, cognitive robotics, and neuro-symbolic or hybrid AI systems; Python developers who need reasoning or ontology support integrated with application code; and roboticists building systems that require runtime introspection, procedural reasoning, or tight coupling between knowledge and domain behavior. Readers without a background in description logics, conjunctive queries, or rule-based reasoning will find the technical sections challenging, though the motivation and results are accessible.

Authors’ abstract

This paper introduces KRROOD, a framework designed to bridge the integration gap between modern software engineering and Knowledge Representation & Reasoning (KR&R) systems. While Object-Oriented Programming (OOP) is the standard for developing complex applications, existing KR&R frameworks often rely on external ontologies and specialized languages that are difficult to integrate with imperative code. KRROOD addresses this by treating knowledge as a first-class programming abstraction using native class structures, bridging the gap between the logic programming and OOP paradigms. We evaluate the system on the OWL2Bench benchmark and a human-robot task learning scenario. Experimental results show that KRROOD achieves strong performance while supporting the expressive reasoning required for real-world autonomous systems.

Read the original paper