SWRL 2 SPIN A tool for transforming SWRL

  • Slides: 10
Download presentation
SWRL 2 SPIN A tool for transforming SWRL rule bases to object-oriented SPIN rules

SWRL 2 SPIN A tool for transforming SWRL rule bases to object-oriented SPIN rules Nick Bassiliades Dept. Informatics, Aristotle Univ of Thessaloniki, Greece

What? • SWRL 2 SPIN is a prototype tool built in SWI-Prolog • Takes

What? • SWRL 2 SPIN is a prototype tool built in SWI-Prolog • Takes as input an OWL ontology with a SWRL rule base • Converts SWRL rules into SPIN rules in the same ontology • Rule conditions are analyzed • SPIN rules are linked to classes (OO flavor of SPIN) • Condition elements could be re-ordered for optimized evaluation

Why? • To prolong the life of existing SWRL rule-based ontology applications by converting

Why? • To prolong the life of existing SWRL rule-based ontology applications by converting to SPIN • SWRL combines OWL with Horn Logic rules of the Rule. ML family • Supported by Protégé, rule engines (Jess, Drools) and ontology reasoners (Pellet) • Very popular choice for developing rule-based applications on top of OWL • Difficult to become a W 3 C standard; reach out to industrial world • SPIN has become a de-facto industry standard to represent SPARQL rules and constraints • Builds on acceptance of SPARQL • SHACL W 3 C standard is a legitimate successor of SPIN (strongly influenced)

How? • Conversion on the RDF vocabulary level • SWRL RDF representation → SPIN

How? • Conversion on the RDF vocabulary level • SWRL RDF representation → SPIN RDF vocabulary • Also textual SPIN representation is generated • This could be exploited for SWRL-to-SHACL-rules conversion Student(? s) ∧ attends(? s, ? c) ∧ is. Taught. By(? c, ? f) → knows(? s, ? f) CONSTRUCT { ? x : knows ? z. } WHERE { ? x rdf: type : Student. ? x : attends ? y : is. Taught. By ? z. }

Correspondence between SWRL and SPIN constructs SWRL swrl: Imp swrl: head swrl: body swrl:

Correspondence between SWRL and SPIN constructs SWRL swrl: Imp swrl: head swrl: body swrl: Class. Atom swrl: class. Predicate <Class> swrl: argument 1 <Arg> Optionally, to avoid expensive RDFS/OWL reasoning swrl: Individual. Property. Atom swrl: property. Predicate <Prop> swrl: argument 1 <Arg 1> swrl: argument 2 <Arg 2> swrl: Same. Individual. Atom swrl: argument 1 <Arg 1> swrl: argument 2 <Arg 2> SPIN sp: Construct sp: templates sp: where sp: subject <Arg> sp: predicate rdf: type sp: object <Class> sp: subject <Arg> sp: path <rdf: type/rdfs: sub. Class. Of*> sp: object <Class> sp: subject <Arg 1> sp: predicate <Prop> sp: object <Arg 2> sp: subject <Arg 1> sp: predicate owl: same. As sp: object <Arg 2> SWRL swrl: Different. Individuals. Atom swrl: argument 1 <Arg 1> swrl: argument 2 <Arg 2> swrl: Datavalued. Property. Atom swrl: property. Predicate <Prop> swrl: argument 1 <Arg 1> swrl: argument 2 <Arg 2> swrl: Builtin. Atom swrl: builtin <Fun> swrl: arguments <Args> swrl: Variable <Var> <Value> ^^ <Data. Type> <Individual> SPIN sp: subject <Arg 1> sp: predicate owl: different. From sp: object <Arg 2> sp: subject <Arg 1> sp: predicate <Prop> sp: object <Arg 2> Customized translation sp: var. Name “<Var>” <Value> ^^ <Data. Type> <Individual>

Embedding SPIN rules in Classes CONSTRUCT { ? x : knows ? z. }

Embedding SPIN rules in Classes CONSTRUCT { ? x : knows ? z. } WHERE { ? x rdf: type : Student. ? x : attends ? y : is. Taught. By ? z. } CONSTRUCT { # @Student ? this : knows ? z. } WHERE { ? this : attends ? y : is. Taught. By ? z. } CONSTRUCT { # @Course ? x : knows ? z. } WHERE { ? x rdf: type : Student. ? x : attends ? this : is. Taught. By ? z. }

Optimizing SPIN rules CONSTRUCT { # @Course ? x : knows ? z. }

Optimizing SPIN rules CONSTRUCT { # @Course ? x : knows ? z. } WHERE { ? x rdf: type : Student. ? x : attends ? this : is. Taught. By ? z. } CONSTRUCT { # @Course ? x : knows ? z. } WHERE { ? this : is. Taught. By ? z. ? x : attends ? this. ? x rdf: type : Student. }

Implementing SWRL builtins • 41 built-ins supported • Mostly: Comparisons, Mathematics, Strings and Lists

Implementing SWRL builtins • 41 built-ins supported • Mostly: Comparisons, Mathematics, Strings and Lists • Date, Time and Duration: only swrlb: date • Conversion of builtins falls into 10 categories: • binary filter, filter function, complex filter • associative infix assign, binary infix assign, unary assign, assign function, complex assign • magic property, complex expression

Built-in examples • Binary filter • greater. Than(? x, ? y) → FILTER (?

Built-in examples • Binary filter • greater. Than(? x, ? y) → FILTER (? x > ? y) • Associative infix assign • add(? y, ? x 1, ? x 2, …, ? xn) → BIND ((((? x 1 + ? x 2) +…) + ? xn) AS ? y) • Assign function • string. Length(? y, ? x) → BIND (STRLEN(? x) AS ? y) • Complex assign • integer. Divide(? z, ? x, ? y) → BIND (spif: cast(? x / ? y, xsd: integer) AS ? z) • Complex expression • member(? e, ? list) → ? list (rdf: rest)*/rdf: first ? e. • Magic property • tokenize(? x, ? y, ? z) → ? x spif: split ( ? y ? z ).

SWRL 2 SPIN • Initial evaluation shows promising results • Looking for large SWRL

SWRL 2 SPIN • Initial evaluation shows promising results • Looking for large SWRL rule bases for proper evaluation SWRL 2 SPIN Code: https: //github. com/nbassili/SWRL 2 SPIN Technical Report: https: //arxiv. org/abs/1801. 09061 Thank you!