Skip to content
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

HyLAR-Reasoner HyLAR icon

A rule-based incremental reasoner for the Web.

To cite HyLAR: HyLAR+: improving Hybrid Location-Agnostic Reasoning with Incremental Rule-based Update

Build status on node 8, 7, 6, 5

Table of contents


HyLAR is a Hybrid Location-Agnostic incremental Reasoner that uses known rdf-based librairies such as rdfstore.js, sparqljs and rdf-ext while providing an additional incremental reasoning engine. HyLAR can be either used locally as a npm module or globally as a server, and comes with a browserified version.

HyLAR relies on the rdfstore.js triplestore and therefore supports JSON-LD, N3 and Turtle serializations. SPARQL support is detailed here. The inferences initially supported by HyLAR are described at the bottom of this page. HyLAR supports custom business rules.

Use HyLAR locally


To use HyLAR locally, just launch npm install --save hylar

Loading an ontology

Import HyLAR, then classify your ontology and query it using load(), which takes three parameters:

  • rawOntology: A string, the raw ontology.
  • mimeType: A string, either text/turtle, text/n3 or application/ld+json.
  • keepOldValues: A boolean: true to keep old values while classfying, false to overwrite the KB. Default is false.
var Hylar = require('hylar'),
    h = new Hylar();
h.load(rawOntology, mimeType, keepOldValues)
    .then(function(reponse) {
        console.log(response) // outputs true if succeeded

Querying an ontology

Once loaded, HyLAR is able to process SPARQL queries using query(), with the following parameters:

  • query: A string, the SPARQL query
    .then(function(results) {
        console.log(results) // is a JSON object

Create your own rules

HyLAR supports insertion of custom forward-chaining conjunctive rules in the form:

triple_head_1 ^ ... ^ triple_head_n -> triple_body_3

Where triple_head_x and triple_body_x are respectively "cause" triples (i.e. the input) and "consequence" triples (i.e. the inferred output) in the form:

(subject predicate object)

Each subject/predicate/object can be one of the following:

  • A variable, e.g. ?x
  • An URI, e.g.
  • A literal, e.g. "0.5", "Hello world!"

A predicate can also be any of these comparison operators: <, >, =, <=, =>.

Rule add example (first param: the 'raw' rule, second param: the rule name)

h.parseAndAddRule('(?p1 ?p2) ^ (?x ?p1 ?y) -> (?y ?p2 ?x)', 'inverse-1');

Rule removal example (first and only param: either the rule name or the raw rule)

// Outputs "[HyLAR] Removed rule (?p1 inverseOf ?p2) ^ (?x ?p1 ?y) -> (?y ?p2 ?x)" if succeeded.

Use HyLAR in a browser

HyLAR comes with a browserified version, available using bower: bower install hylar. Include the file hylar-client.js as a script in your page with this line:

<script src="path-to/hylar-client.js"></script>

As in the node module version, you can instantiate HyLAR with var h = new Hylar(); and call the same methods query(), load() and parseAndAddRule().

Use HyLAR as a server


npm install -g hylar

Run the server

hylar --port 3000 -od /usr/local/share/ontologies/

Note: --port <port_number> or -p <port_number> is optional. HyLAR runs at port 3000 by default.

--ontology-directory </your/base/ontology/directory/> or -od </your/base/ontology/directory/> is also optional. This parameter specifies the directory in which ontologies are located, in order to classify them. By default, HyLAR uses its module path, i.e. {path_to_hylar}/server/ontologies/.

Load and query your ontology

GET /classify/{FILE_NAME}

Loads, parses and classify the file {FILE_NAME} from the ontology directory.

Note: You don't have to specify the ontology file's mimetype as it is detected automatically using its extension.

GET /classify/

Allows classifying an ontology as a string, which requires its original serialization type.

Body parameters filename the absolute path of the ontology file to be processed. mimetype the serialization of the ontology (mimetype, one of text/turtle, text/n3 or application/ld+json).

GET /query

SPARQL queries your loaded ontology as does Hylar.query().

Body parameters query the SPARQL query string.

PUT /rule

Puts an list of custom rules and adds it to the reasoner.

Body parameters rules the array of conjunctive rules.

Supported inferences

The following OWL 2 rules are currently supported by HyLAR, based on the semantics detailed here:

  • (?c1 ?c2) ^ (?c2 ?c3) -> (?c1 ?c3)

  • (?c1 ?c2) ^ (?x ?c1) -> (?x ?c2)

  • (?p1 ?p2) ^ (?p2 ?p3) -> (?p1 ?p3)

  • (?p1 ?p2) ^ (?x ?p1 ?y) -> (?x ?p2 ?y)

  • (?x ?p ?y) ^ (?p ^ (?y ?p ?z) -> (?x ?p ?z)

  • (?p1 ?p2) ^ (?x ?p1 ?y) -> (?y ?p2 ?x)

  • (?p1 ?p2) ^ (?x ?p2 ?y) -> (?y ?p1 ?x)

  • (?c1 ?c2) ^ (?x ?c1) -> (?x ?c2)

  • (?c1 ?c2) ^ (?x ?c2) -> (?x ?c1)

  • (?p1 ?p2) ^ (?x ?p1 y) -> (?x ?p2 ?y)

  • (?p1 ?p2) ^ (?x ?p2 y) -> (?x ?p1 ?y)

  • (?s1 ?s2) ^ (?s1 ?p ?o) -> (?s2 ?p ?o)

  • (?p1 ?p2) ^ (?s ?p1 ?o) -> (?s ?p2 ?o)

  • (?o1 ?o2) ^ (?s ?p ?o1) -> (?s ?p ?o2)

  • (?x ?y) ^ (?y ?z) -> (?x ?z)


Location-agnostic mechanism

Terdjimi, M., Médini, L., & Mrissa, M. (2015, May). Hylar: Hybrid location-agnostic reasoning 📚 In ESWC Developers Workshop 2015 (p. 1).

Incremental reasoning on the Web with HyLAR

Terdjimi, M., Médini, L., & Mrissa, M. (2016, April). HyLAR+: improving hybrid location-agnostic reasoning with incremental rule-based update 📚 In Proceedings of the 25th International Conference Companion on World Wide Web (pp. 259-262). International World Wide Web Conferences Steering Committee.

Tag-based maintenance

Terdjimi, M., Médini, L., & Mrissa, M. (2018, April). Web Reasoning Using Fact Tagging 📚 In Companion of the The Web Conference 2018 on The Web Conference 2018 (pp. 1587-1594). International World Wide Web Conferences Steering Committee.

You can’t perform that action at this time.