Skip to content

Python bindings for upgraded FaCT++ description logic reasoner

Notifications You must be signed in to change notification settings

tilde-lab/pyfactxx

Folders and files

NameName
Last commit message
Last commit date
Mar 30, 2024
Jan 21, 2021
Jan 22, 2021
Jun 20, 2022
Apr 1, 2024
Apr 6, 2022
Feb 5, 2024
Jan 21, 2021
Jun 20, 2022
Jun 10, 2022
Jun 17, 2022
Mar 3, 2023
Feb 4, 2021
Mar 2, 2023

Repository files navigation

Python bindings for FaCT++ reasoner

DOI PyPI FOSSA Status

FaCT++ is a well-optimized open-source reasoner for SROIQ(D) description logic with simple datatypes (OWL 2), written in C++. FaCT++ was created in 2003-2015 by Dmitry Tsarkov and Ian Horrocks in the University of Manchester, UK.

The pyfactxx links the FaCT++ reasoner to the Python's RDFLib package. The code is based on the works of Artur Wroblewski: factpp and coras interfaces.

Reasoner details

The FaCT++ implements the atomic decomposition algorithms (i.e. represents the ontologies as terse directed acyclic graphs). A tableaux decision procedure is applied for SROIQ(D) together with the set of optimisation heuristics, such as:

  • lexical normalisation and simplification,
  • synonym replacement,
  • rewriting absorption,
  • told cycle elimination,
  • dependency-directed backtracking (backjumping),
  • boolean constant propagation,
  • semantic branching,
  • ordering heuristics,
  • model merging,
  • completely defined concepts,
  • clustering for wide and shallow taxonomies.

To tackle the OWL 2 computational complexity (double exponential in time for the worst case), the FaCT++ presents persistent and incremental reasoning. In the persistent mode, FaCT++ saves the inferred information together with its internal state into a file, which can be reloaded later with much less computational effort than reasoning would require. In the incremental mode, FaCT++ determines which parts of the precomputed inferences may be affected by an incoming change and only recomputes a subset of the inferences.

The mentioned above allows to achieve a very good performance on such known ontologies as FHKB, SNOMED CT, and Thesaurus.

Apart of our present work, the FaCT++ supports Java OWL-API, Lisp API, and DIG interface. It can also be used in C. There is also a work of Levin and Cowell on C++ usage (unmaintained).

Reasoner optimizations for RDFLib

The pyfactxx presents the following updates to FaCT++:

  • drastically improved individuals support (precacheIndividuals)
  • unified access point allowing arbitrary SPARQL queries
  • exposing all the required C++ interfaces to RDFLib via the coras interface

Installation

pip install pyfactxx

NB the PyPI releases plus wheels are done via GitHub action.

Usage

See examples folder. In essense:

from pyfactxx import coras

crs = coras.Coras()
crs.load(ontology_file, format='turtle')

crs.parse()
crs.realise()

result = crs.query('SELECT ?a ?b ?c WHERE {?a ?b ?c}')

Authors of Python part

  • Artur Wroblewski
  • Evgeny Blokhin
  • Andrey Sobolev
  • Ivan Rygaev

Authors of C++ part

  • Dmitry Tsarkov
  • Ian Horrocks
  • Ivan Rygaev

License

  • Kernel reasoner code: GNU LGPL 2.1
  • Coras Python interface: GNU GPL 3.0

FOSSA Status