Thoughts on reasoning about IoT devices using OWL/Thea, Pengines, MQTT, and NodeRed?

I’m using: SWI-Prolog version 8.2.4

I’m trying to design a system takes IoT sensor data (via MQTT) and an OWL ontology and reasons based on changes to from the sensors. I’ve been experimenting with using NodeRed to model the sensor flows and pengines nodes to assert changes from the sensors and other pengines nodes to introduce inferences derived from the sensor changes via the ontology back into NodeRed and MQTT. I’m just starting to to use Thea library to read the ontology (designed by someone else). I may eventually use CLP, but haven’t seen the need for it yet. I don’t yet know exactly what the queries over the ontology will be, so I don’t know if I will have a mismatch between closed (Prolog) and open (OWL) world reasoning.

  1. My highest level question is just whether anyone has advice on this approach.

I’m still slowly connecting things, but some more specific questions I have are

  1. When I load pengines, I get
ERROR:    source_sink `library(uuid)' does not exist

It seems that this library is no longer included in SWI. Pengines still seems to work for my simple tests. Where can I get that library and how do I install it (on a Mac)?

  1. When I import the ontology with Thea, the names of classes have long IRI prefixes. I’d like to abbreviate them. I was able to use rdf_prefixes:rdf_register_prefix/2 to register abbreviations for the prefixes and I’ve confirmed that my abbreviations are correctly expanded with rdf_prefixes:rdf_global_term/2. However, when I write a clause using the abbreviation, it does not get expanded correctly. The manual pages for rdf_register_prefix/2 are not making sense to me. Is this even the right approach for handling IRI prefixes?

Thanks for any hints!

I think that the overall approach is fine. What exactly is required and how to connect it depends on the exact reasoning needs. There are some options for OWL reasoning with various advantages and disadvantages. Roughly using naive Prolog approximations, through Thea, translate to tabled Prolog and using "trill" pack for SWI-Prolog. May have missed some …

The library exists, but depends on the ossp-uuid C library. There are many ways to get hold of SWI-Prolog on the Mac and the one you used doesn’t seem to have this dependency.

There are some possible causes. Can you provide an example?

Thanks for the feedback and ideas on the approach.

With respect to the uuid library, I installed in a different way (https://www.swi-prolog.org/download/stable/bin/swipl-8.2.4-1.x86_64.dmg) and that solved the error.

With respect to the abbreviations not being expanded, I figured out my problem was that since I want subClassOf/2 to use prefixes, I needed to add the module name to the rdf_meta directive like this:

:- rdf_meta
   owl2_model:subClassOf(r,r).

If you start fresh it is better to use the 8.3.x development versions. Many people can confirm they are almost always reliable, they provide a lot of new functionality, in particular for dealing with a changing world and the dev version sill become the next stable soon.

Good to know. I will try it. Thanks!