PSOA RuleML

From RuleML Wiki
Jump to: navigation, search

Authors: Gen Zou, Harold Boley


Positional-Slotted, Object-Applicative RuleML (PSOA RuleML) permits an atom, i.e. a predicate application, to be [in an oidless/oidful dimension] without or with an Object IDentifier (OID) -- typed by the predicate (acting as a class) -- and the arguments of the predicate (acting as a relation) to be [in an orthogonal dimension] positional, slotted, or combined. The resulting positional-slotted, object-applicative (psoa) atoms can be used as (oidless, positional) classical facts without an OID and with an -- ordered -- sequence of arguments, as (oidful, slotted) frame facts with an OID and with an -- unordered -- multi-set of slots (each being a pair of a name and a filler), as well as in various other ways. For example, a simple purchase predicate with three arguments, John, Mary, and "Foundations of Logic Programming", can be represented as a classical fact:

_purchase(_John  _Mary  "Foundations of Logic Programming")

Or, as a frame fact, adding an OID, transaction123, and slot names, buyer, seller, and item:

_transaction123#_purchase(_buyer->_John
                          _seller->_Mary
                          _item->"Foundations of Logic Programming")

Such psoa facts and rules over them were given a first-order model-theoretic foundation (original paper and slides, refined paper and slides), bringing together (OID-over-)slot distribution, as in RIF, with blended psoa atoms, as in RuleML. In order to support reasoning in PSOA RuleML, the PSOATransRun 1.1 system has been developed, including a combination of a translator PSOA2Prolog, from PSOA RuleML to a subset of the logic programming language ISO Prolog, with the well-known efficient XSB Prolog engine.

1 Introduction

In AI, the Semantic Web, and IT at large, data can be modeled in the contrasting paradigms of relationships having a relation applied to an ordered tuple of positional arguments (e.g., in relational databases and Datalog) or frames having a globally unique Object IDentifier (OID), usually typed by a class, and an unordered multiset of slotted arguments (e.g., in graph databases and RDF). On top of such data atoms, rules may use only relationship atoms (e.g., SQL views -- i.e., Datalog rules -- and Prolog rules -- i.e., Horn rules) or only frame atoms (e.g., SPARQL/SPIN and N3 rules). In PSOA RuleML, rules may also blend both relationship atoms and frame atoms within their conditions as well as across their conditions and conclusions (e.g., PSOA rules translating between relational and graph atoms). Further blending the paradigms of relationships (oidless, positional) and frames (oidful, slotted), the orthogonal dimensions characterizing PSOA RuleML atoms also allow for the complementary shelf atoms (oidful, positional), pairship atoms (oidless, slotted), as well as oidful/oidless atoms having both positional and slotted arguments. As a final extension of atoms, more than a single tuple of positional arguments is allowed. Any combination of these atoms may be used in rule conditions and conclusions.

The PSOA RuleML language thus introduces the integrated notion of a positional-slotted, object-applicative (psoa) term as a generalization of: (1) the positional-slotted term in POSL and (2) the frame term and the class membership term in RIF-BLD. In PSOA RuleML Presentation Syntax (PSOA/PS), a psoa term s has the following general right-slot normal form:

   o#f([t1,1 ... t1,n1] . . . [tm,1 ... tm,nm] p1->v1 . . . pk->vk)

Here, o is the object identifier (OID) described by three kinds of information: (1) The class membership o # f makes o an instance of type f; (2) each tupled argument [ti,1 ... ti,ni] represents a sequence of terms associated with o; (3) each slotted argument pi -> vi represents a pair of an attribute pi and its value vi associated with o.

An atomic formula having the form of a psoa term is called a psoa atom. Psoa atoms can be asserted as psoa facts and retrieved by look-up psoa queries. Such atoms can also be combined into more complex formulas using constructs from the Horn-like subset of first-order logic: conjunction, disjunction in negative positions, as well as existential and universal quantifiers in certain positions. Implication (written 'backward' as a ":-" infix) can be used for rules, e.g. of this conjunctive-condition form, where each si is a psoa atom:

   Forall ... ( s0 :- And(s1 . . . sz) )

Generally, psoa rules can be used to derive psoa atoms on demand, through inferential psoa queries.

The page for the PSOATransRun Demo gives introductory examples. The papers and slides in the References provide details. These include the two award-winning papers 1. and 3. as well as the invited tutorial paper 7.

Since PSOA RuleML allows for both object-centered and relational knowledge/data modeling, it can support the specification of all kinds of object-relational transformations between the global and local schemas in Ontology/Rule-Based Data Access (OBDA/RBDA).

A visualization for PSOA RuleML has been developed in Grailog, permitting integrated object-relational knowledge (InteropGraphRel and PSOAObjRelDataRules).

2 Specification

The original specification of the PSOA RuleML presentation syntax and semantics is given in Ref 1. An explanation of the PSOA RuleML serialization syntax in XML, mapped from the presentation syntax, and of the semantics are given in Ref 7. The newest versions of PSOA syntax and semantics are given in the following subsections.

2.1 Syntax

The PSOA RuleML/XML serialization extends the one of Hornlog RuleML/XML. In particular, for (multi-)tupled and/or (multi-)slotted psoa terms, (multiple occurrences of) <Tuple> node elements and/or (multiple) <slot> edge elements are allowed.

A psoa term used as an atomic formula has the following pure PSOA right-slot normal form. Here, the primed meta-variables t'i,j etc. indicate recursive XML serializations of their above presentation-syntax versions (the style attribute uses the value "http://ruleml.org/1.02/profiles/HornPSOA-Tarski" to specify PSOA semantics with built-in slotribution and tupribution):

   <Atom style="http://ruleml.org/1.02/profiles/HornPSOA-Tarski">
     <oid><Ind>o</Ind></oid><op><Rel>f</Rel></op>
     <Tuple>t'1,1 ... t'1,n1</Tuple> . . . <Tuple>t'm,1 ... t'm,nm</Tuple>
     <slot>p'1 v'1</slot> . . . <slot>p'k v'k</slot>
   </Atom>

For details and for an extended PSOA version see Ref 7, Section 6, where the right-slot normal form is replaced with a left-slot normal form.

The complete XML Schema for PSOA RuleML, the PSOA RuleML API, and their use for generating the PSOA RuleML presentation syntax from the PSOA RuleML/XML serialization are described in PSOA RuleML API.

The mapping between the PSOA RuleML presentation syntax and the PSOA RuleML/XML syntax is given in Ref 7, Section 6.

2.2 Semantics

The specification of the PSOA RuleML semantics is given in Ref 1, Section 3. An explanation of the semantics, also in comparison to RIF-BLD, is given in Ref 7, Section 7.

3 Implementation

3.1 PSOATransRun

In order to support reasoning in PSOA RuleML, we have implemented the PSOATransRun system, which composes two parts. The first, PSOA2i, for translation from PSOA presentation syntax to an intermediate language i. The second, r, for some runtime environment executing the language i. The system can have multiple instantiations using different intermediate languages, where different combinations of a translator PSOA2i and a runtime environment r are employed. Two PSOATransRun[PSOA2i,r] instantiations are available: the initial PSOATransRun[PSOA2TPTP,VampirePrime], for online use, and the current PSOATransRun[PSOA2Prolog,XSBProlog], for local use.

Initial Release (Web-based): http://psoa-ruleml.rhcloud.com/

Current Release (download): http://psoa.ruleml.org/transrun/1.0/local/

Project Repository: https://github.com/ZOUG/psoa2tptp

Invited Demo Examples on RuleML 2012: PSOATransRunInvitedDemoRuleML2012


3.1.1 TPTP Instantiation

The TPTP instantiation employs the popular TPTP format, supported by many first-order logic reasoners, as the intermediate language. This PSOATransRun[PSOA2TPTP,VampirePrime] composes PSOA2TPTP and VampirePrime into a RESTful API.

Semantic Web Techniques Course Project (Fall 2011) Version: http://scaryponens.github.io/PSOA-to-TPTP/build/html/index.html

Workflow of using PSOATransRun (sample KBs & queries can be obtained from the Test Case section):

1) load the PSOATransRun page;

2) enter a KB into the rulebase textbox (ignore this step if you use the sample KB provided by the system);

3) click "Translate Rulebase" (takes you to the "TPTP Rulebase" pane and the translated KB in the TPTP format is shown);

4) enter a query into the query textbox (for example, _k1#_kid(_Sue _Pete));

5) click "Translate Query" (leaves you on the "TPTP Rulebase" pane, and the translated query in the TPTP format is appended to the end of the translated KB);

6) click "Execute" (takes you to the "VampirePrime Reasoner" pane and the result is shown. If the query is successful, the proof procedure for each answer will be shown in the TPTP format).

3.1.1.1 PSOA2TPTP

PSOA2TPTP is our reference translator mapping knowledge bases and queries in the PSOA RuleML presentation syntax to TPTP. The translator, currently composed of a lexer, a parser, and tree walkers, is generated by the ANTLR v3 parser generator tool from the grammars we developed. Details can be found in the paper [3].

3.1.1.2 VampirePrime

VampirePrime is Alexandre Riazanov's first-order logic reasoner. Since VampirePrime is written in C++, linking some libraries that are not on current Linux distributions, a compiled version, called vkernel, had to be used. For maintenance and portability, once compatible versions of the C++ libraries are identified, the VampirePrime C++ sources from the Software by Alexandre Riazanov, "VampirePrime reasoner", need to be recompiled.

3.1.1.3 Implemented feature list and restrictions
  • Terms
    • Constants
      • Local constants: constant names that has only digits with a prefix '_', such as _1, _21, are disallowed since they are reserved for objectification
      • Integers
    • Variables: variable name ?obj is disallowed since it is reserved for objectification
    • Psoa terms: any form of psoa terms acting as atomic formulas are supported while psoa terms acting as function applications are not
      • Syntactic sugar supported: (1) omission of '[' and ']' for single tuple psoa terms; (2) omission of '(' and ')' for psoa term with only type information
      • Objectification for OID-less psoa terms are supported
  • Formulas
    • Conjunction
    • Existential quantification
    • Universal quantification

3.1.2 Prolog Instantiation

The Prolog instantiation employs the widely used logic programming language Prolog as the intermediate language, supported by many engines. This PSOATransRun[PSOA2Prolog,XSBProlog] composes PSOA2Prolog and XSB Prolog.

Releases:

http://psoa.ruleml.org/transrun/0.7/local/

http://psoa.ruleml.org/transrun/0.8/local/

http://psoa.ruleml.org/transrun/1.0/local/

http://psoa.ruleml.org/transrun/1.1/local/

3.1.2.1 PSOA2Prolog

PSOA2Prolog is a translator mapping knowledge bases and queries in the PSOA RuleML presentation syntax to Prolog. The translator, currently composed of a lexer, a parser, and tree walkers, is generated by the ANTLR v3 parser generator tool from the grammars we developed. The tree walkers first normalize the input knowledge base or query within PSOA RuleML and then do a syntactic transformation from PSOA RuleML to Prolog.

3.1.2.2 XSB Prolog

XSB Prolog is a Prolog engine that allows tabling of facts to improve reasoning efficiency and avoid infinite loops of the traditional top-down Prolog execution model.

4 Test Cases

The following examples serve to test the PSOA2TPTP implementation, which is currently being finalized.

4.1 Single-tuple psoa term

  • Knowledge Base
Document(
  Group(
    _o1#_p(_a1 _a2)
  )
)
  • Queries
_o1#_p(?1 _a2)

4.2 Multi-slot psoa term

  • Knowledge Base
Document(
  Group(
    _o1#_p(_a->1 _b->2)
  )
)
  • Queries
_o1#_p(_a->1)
_o1#_p(?1->1)
_o1#_p(?2->?3)

4.3 Multi-valued Slot

  • Knowledge Base
Document(
  Group(
    _Adam#_Person(_father->_John)
    _Jack#_Person(_father->_John)
    _Tom#_Person(_father->_John)

    Forall ?Ch ?M
    (
       ?M#_Male(_child->?Ch) :- ?Ch#_Person(_father->?M)
    )
  )
)
  • Queries
_John#_Male(_child->?c1)
_John#_Male(_child->?c1 _child->?c2)
_John#_Male(_child->?c1 _child->?c2 _child->?c3)

4.4 Psoa terms with slots and tuples

  • Knowledge Base
Document(
  Group(
    _f1#_family(_John _Mary _child->_Tom)
    _f2#_family([_Tom _Jane] _income->100000)
    _f3#_family([_Mike _Jessie] [1951] _child->_Fred _child->_Jane)
    _Jane#_Person([_female] [_bcs _mcs _phd] _job->_engineer)
  )
)
  • Queries
_f1#Top(_John _Mary)
_f2#_family(?1->?2)
_f3#_family(_Mike _Jessie _child->?c)
_Jane#_Person([_bcs _mcs _phd] _job->_engineer)

4.5 Class Membership (TBD)

From http://www.w3.org/2005/rules/wiki/Class_Membership

  • Knowledge Base
Document(
  Prefix(fam <http://example.org/family#>)

  Group ( 
    Forall ?X ?Y ( 
      fam:isFatherOf(?Y ?X) :- And (fam:isChildOf(?X ?Y) ?Y#fam:Male  )
    )

    fam:isChildOf(fam:Adrian fam:Uwe)
    fam:Adrian#fam:Male
    fam:Uwe#fam:Male 
  )
)
  • Queries
fam:isFatherOf(fam:Uwe fam:Adrian)

4.6 Family (TBD)

  • Knowledge Base (Non-objectified version)
Document(
  Group(
    Forall ?Hu ?Wi ?Ch (
      _family(_husb->?Hu _wife->?Wi _child->?Ch) :-
        And(_married(?Hu ?Wi) _kid(?Hu ?Ch))
    )
    Forall ?Hu ?Wi ?Ch (
      _family(_husb->?Hu _wife->?Wi _child->?Ch) :-
        And(_married(?Hu ?Wi) _kid(?Wi ?Ch))
    )
    _married(_Joe _Sue)
    _kid(_Sue _Pete)
  )
)
  • Knowledge Base (Objectified version)
Document(
  Group(
    Forall ?Hu ?Wi ?Ch (
      Exists ?obj1 (?obj1#_family(_husb->?Hu _wife->?Wi _child->?Ch)) :-
        And(Exists ?obj2 (?obj2#_married(?Hu ?Wi))
            Exists ?obj3 (?obj3#_kid(?Hu ?Ch)) )
    )
    Forall ?Hu ?Wi ?Ch (
      Exists ?obj1 (?obj1#_family(_husb->?Hu _wife->?Wi _child->?Ch)) :-
        And(Exists ?obj2 (?obj2#_married(?Hu ?Wi))
            Exists ?obj3 (?obj3#_kid(?Wi ?Ch)) )
    )
    _1#_married(_Joe _Sue)
    _2#_kid(_Sue _Pete)
  )
)
  • Queries
_married(_Joe _Sue)
_family(_husb->_Joe _wife->_Sue _child->?Ch)

4.7 Family (Variation)

  • Knowledge Base (Non-objectified version)
Document(
  Group (
    Forall ?Hu ?Wi (
      _family(_husb->?Hu _wife->?Wi) :-
              _married(?Hu ?Wi)
    )
    Forall ?Hu ?Ch ?o (
      ?o#_family(_child->?Ch) :-
        And(?o#_family(_husb->?Hu)
            _kid(?Hu ?Ch))
    )
    Forall ?Wi ?Ch ?o (
      ?o#_family(_child->?Ch) :-
        And(?o#_family(_wife->?Wi)
            _kid(?Wi ?Ch))
    )
    _married(_Joe _Sue)
    _kid(_Sue _Pete)
    _kid(_Joe _Tom)
  )
)
  • Knowledge Base (Objectified version)
Document(
  Group(
    Forall ?Hu ?Wi (
      Exists ?obj1 (?obj1#_family(_husb->?Hu _wife->?Wi)) :-
             Exists ?obj2 (?obj2#_married(?Hu ?Wi))
    )
    Forall ?Hu ?Wi ?Ch ?o (
      ?o#_family(_child->?Ch) :-
        And(?o#_family(_husb->?Hu _wife->?Wi)
            Exists ?obj3 (?obj3#_kid(?Hu ?Ch)) )
    )
    Forall ?Hu ?Wi ?Ch ?o (
      ?o#_family(_child->?Ch) :-
        And(?o#_family(_husb->?Hu _wife->?Wi)
            Exists ?obj4 (?obj4#_kid(?Wi ?Ch)) )
    )
    _m1#_married(_Joe _Sue)
    _k1#_kid(_Sue _Pete)
    _k2#_kid(_Joe _Tom)
  )
)
  • Queries
?1#_family(?p->?v)
?1#_family(_husb->_Joe _child->?Ch)
?1#_family(_husb->?Hu _wife->?Wi _child->?Ch)
And(?1#_family(_husb->_Joe _wife->_Sue _child->?Who) _kid(_Sue ?Who))

4.8 Rule Test - Psoa Terms

  • Knowledge Base
Document(
  Group(
    Forall ?X ?Y ?1 (
      ?1#_R4(?X ?Y) :- ?1#_R3(?X ?Y _p2->_v2)
    )
    Forall ?X ?Y ?1 (
      ?1#_R3(?X ?Y) :- And (?X#_C2(_p3->_v3) ?1#_R2(?X ?Y))
    )
    Forall ?1 ?X ?Y (
      ?1#_R2(?X ?Y _p1->_v1 _p2->_v2) :- ?1#_R1(?X ?Y)
    )
    Forall ?1 (
      ?1#_C2() :- ?1#_C1()
    )

    _a1#_C1()
    _o1#_R1(_a1 _b1)
    _a2#_C1(_p3->_v3 _p4->_v4)
    _o2#_R1(_a2 _b2)
    _a3#_C1()
    _o3#_R1(_a3 _b3 _c3)
  )
)
  • Queries
_a1#_C2()
_o1#_R1(_p1->_v1)
_o2#_R3(_a2 _b2)
_o2#_R4(_a2 _b2 _p1->_v1 _p2->_v2)
?1#_R3(_a2 ?Y)
?2#_R4(?X ?Y)
_o2#_R1(_a2 _b2 ?p->?v)
?3#_R4(?X ?Y ?p->?v)
_o2#?r(_a2 _b2)
  • Negative Queries
_o3#_R1(_p1->_v1)

4.9 Rule Test - Psoa Facts

  • Knowledge Base
Document(
  Group(
    _a#_C(_o _b _p3->_v3) :- _o#_R4(_a _b)
    _o#_R4(_a _b) :- _o#_R3(_a _b _p1->_v1)
    Forall ?X ?1 (
      ?1#Top(_p1->_v1) :- And(?1#_R3(?X _b) ?1#_R2())
    )
    _o#_R3() :- And(_o#_R2() _o#_R1(_p2->_v2))

    _o#_R2(_a _b _p2->_v2)
    _o#_R1()
  )
)
  • Queries
_a#_C(_o _b)
_o#?r(_a _b)
_o#Top(?p->?v)

4.10 Entail Everything (TBD)

From http://www.w3.org/2005/rules/wiki/EntailEverything

  • Knowledge Base
Document(
  Prefix(ex <http://example.org/example#>)  
  Group(
    Forall ?x ( ex:A(?x) )
  ) 
)
  • Queries
And(
  ex:A(2)
  ex:A("any string")
  ex:A(<http://some.example.org>)
)

4.11 Multiple Entailment

  • Knowledge Base
Document(
  Group(
    Forall ?x (_o1#_p(_a ?x))
    Forall ?x (_o1#_p(?x _b))
  )
)
  • Queries
_o1#_p(_a _b)
_o1#_p(?1 ?2)

4.12 Arbitrary Entailment (TBD)

From http://www.w3.org/2005/rules/wiki/Arbitrary_Entailment

  • Knowledge Base
Document(
  Group(
    "a" = "b"
  )
)
  • Queries
<http://example.org/#p>(<http://example.org/#e>)

4.13 Objectification

  • Knowledge Base
Document(
  Group(
    Forall ?x ?y (
      _g(?y ?x) :- _f(?x ?y)
    )
    _f(_a _b)
  )
)
  • Queries
_g(_b _a)
And (_f(_a _b) _g(_b _a))
  • Translated TPTP document for the second query
fof(ax01,axiom,(
   ! [Qy,Qx] : 
     ( ? [Qobj] : 
         ( member(Qobj,lf)
         & tupterm(Qobj,Qx,Qy) )
    => ? [Qobj] : 
         ( member(Qobj,lg)
         & tupterm(Qobj,Qy,Qx) ) ) )).
fof(ax02,axiom,
   ( member(l1,lf)
   & tupterm(l1,la,lb) )).
fof(query,theorem,
   ( ( ? [Qobj] : 
         ( member(Qobj,lf)
         & tupterm(Qobj,la,lb) )
     & ? [Qobj] : 
         ( member(Qobj,lg)
         & tupterm(Qobj,lb,la) ) )
   => ans )).
  • Post-edited TPTP for VP
fof(ax01,axiom,(
   ! [Qy,Qx] : 
     ( ? [Qobj] : 
         ( member(Qobj,lf)
         & tupterm(Qobj,Qx,Qy) )
    => ? [Qobj] : 
         ( member(Qobj,lg)
         & tupterm(Qobj,Qy,Qx) ) ) )).
fof(ax02,axiom,
   ( member(l1,lf)
   & tupterm(l1,la,lb) )).
fof(query,theorem,
   ( ( ? [Qobj1] : 
         ( member(Qobj1,lf)
         & tupterm(Qobj1,la,lb) )
     & ? [Qobj2] : 
         ( member(Qobj2,lg)
         & tupterm(Qobj2,lb,la) ) )
   => ans )).

4.14 Recursion

  • Knowledge Base
Document(
  Group(
    Forall ?anc ?par ?des (
      _isDescendentOf(?des ?anc) :- And (_isChildOf(?des ?par) _isDescendentOf(?par ?anc))
    )
    Forall ?par ?ch (
      _isDescendentOf(?ch ?par) :- _isChildOf(?ch ?par)
    )
    _isChildOf(_Pete _Sue)
    _isChildOf(_Sue _John)
    _isChildOf(_John _Tom)
    _Pete#_Person(_sex->_Male _age->24)
    _Sue#_Person(_sex->_Female _age->47)
    _John#_Person(_sex->_Male _age->77)
  )
)
  • Queries
_isDescendentOf(_Sue _Tom)
And(_isDescendentOf(?Who _Tom) ?Who#_Person(_sex->_Male _age->?Age))

4.15 Subclass 1

  • Knowledge Base
Document(
  Group(
    _o1#_c1(_a1 _a2)
    _o2#_c1(_p->_v)
    _c1##_c2
  )
)
  • Queries
_o1#_c2(_a1 _a2)
_o2#_c2(_p->_v)
?1#_c2(_a1 ?3)
?1#_c2(_p->?2)

4.16 Subclass 2

  • Knowledge Base
Document(
  Group(
    _o1#_c1(_p->_v1)
    _o2#_c3(_p->_v2)
    _o3#_c5(_p->_v3 _q->_w0)
    _c1##_c2
    _c1##_c3
    _c2##_c4
    _c3##_c4
    _c4##_c6
    _c5##_c6
  )
)
  • Queries
_o1#?c
?o#_c4
?o#_c6(_p->?v)
?o#_c6(_p->?v _q->?w)

4.17 Constant and String Equality (TBD)

  • Knowledge Base
Document(
  Group(
    _a = _b
    _b = "c"
  )
)
  • Queries
_a = "c"

4.18 Factorial 1

  • Knowledge Base
Document(
  Group(
    Forall ?x ?y ?fx ?fy (
      _factorial(?y ?fy) :- 
         And(_factorial(?x ?fx) _multiply(?fx ?y ?fy) _sum(?x 1 ?y))
    )
    _factorial(0 1)
    _sum(0 1 1)
    _multiply(1 1 1)
    _sum(1 1 2)
    _multiply(1 2 2)
    _sum(2 1 3)
    _multiply(2 3 6)
    _sum(3 1 4)
    _multiply(6 4 24)
  )
)
  • Queries
_factorial(4 24)
_factorial(?x ?fx)

4.19 Factorial 2

  • Knowledge Base
Document(
  Group(
    Forall ?x ?y ?fx ?fy (
      _eq(?fy _factorial(?y)) :- 
         And(_eq(?fx _factorial(?x)) _eq(?fy _multiply(?fx ?y)) _eq(?y _sum(?x 1)))
    )
    _eq(1 _factorial(0))
    _eq(1 _sum(0 1))
    _eq(1 _multiply(1 1))
    _eq(2 _sum(1 1))
    _eq(2 _multiply(1 2))
    _eq(3 _sum(2 1))
    _eq(6 _multiply(2 3))
    _eq(4 _sum(3 1))
    _eq(24 _multiply(6 4))
  )
)
  • Queries
_eq(24 _factorial(4))
_eq(?fx _factorial(?x))

4.20 Factorial 3

  • Knowledge Base
Document(
  Group(
    _factorial(0 1)
    Forall ?N ?F ?N1 ?F1 (
      _factorial(?N ?F) :-  
         And(External(pred:numeric-greater-than(?N 0)) 
             ?N1 = External(func:numeric-subtract(?N 1)) 
             _factorial(?N1 ?F1) 
             ?F = External(func:numeric-multiply(?N ?F1)) )
    )
  )
)
  • Queries
_factorial(5 120)
_factorial(5 ?X)

4.21 Function 1

  • Knowledge Base
Document(
  Group(
    Forall ?x ( _identity(?x) = ?x)
  )
)
  • Queries
_identity(2) = 2
_identity(_a) = _a
_identity(_g(_b)) = _g(_b)

4.22 Function 2 (TBD)

  • Knowledge Base
Document(
  Group(
    Forall ?x ?y ( _f(?x ?y) = External(func:numeric-subtract(?x ?y)) )
  )
)

4.23 Concatenation

  • Knowledge Base (Original)
Document(
  Group(
    Forall ?first ?rest ?x ?y (
      _concat(_cns(?first ?rest) ?x _cns(?first ?y)) :- _concat(?rest ?x ?y)
    )
    Forall ?x ( _concat(_nil ?x ?x) )
  )
)
  • Knowledge Base (Objectified)
Document(
  Group(
    Forall ?first ?rest ?x ?y ?2 (
      Exists ?1 (?1#_concat(_cns(?first ?rest) ?x _cns(?first ?y)))
        :- ?2#_concat(?rest ?x ?y)
    )
    Forall ?x ( Exists ?1 (?1#_concat(_nil ?x ?x)) )
  )
)
  • Queries
_concat(_cns(1 _cns(3 _nil)) _cns(1 _nil) ?x)
_concat(_cns(1 _cns(3 _nil)) ?x _cns(1 _cns(3 _cns(2 _nil))))

4.24 Addition and Multiplication (TBD)

  • Knowledge Base
Document(
  Group(
    Forall ?x ?y ( 
      _sum(_suc(?x) ?y) = _suc(_sum(?x ?y))
    )
    Forall ?x ( ?x = _sum(0 ?x) )
    Forall ?x ?y (
      _multiply(_suc(?x) ?y) = _sum(?x _multiply(?x ?y))
    )
    Forall ?x ( 0 = _multiply(0 ?x) )
  )
)
  • Queries

4.25 Music Album

  • Knowledge Base

A fragment of http://www.cs.unb.ca/~boley/papers/MusicAlbumKB.txt (Executable http://www.cs.unb.ca/~boley/papers/MusicAlbumKB.psoa)

Document(
  Group(
    :o1#:albsplitObj( :artist->"Van Morrison"   :title->"Astral Weeks"              :favorite->"Madame George"     )
    :o2#:albsplitObj( :artist->"Beatles"        :title->"Sgt. Pepper's"             :favorite->"A Day in the Life" )
    :o3#:albsplitObj( :artist->"Beatles"        :title->"Abbey Road"                :favorite->"Something"         )
    :o4#:albsplitObj( :artist->"Rolling Stones" :title->"Sticky Fingers"            :favorite->"Brown Sugar"       )
    :o5#:albmergeObj( :artist->"Eagles"                :tivorite->"Hotel California"                               )
    :o6#:albmergeObj( :artist->"Elton John"            :tivorite->"Goodbye Yellow Brick Road"                      )
    :albmergeObj##:albsplitObj
    Forall ?OID ?Tivorite
    (
      ?OID#:albsplitObj(:title->?Tivorite :favorite->?Tivorite)  :-  ?OID#:albmergeObj(:tivorite->?Tivorite)
    )
  )
)
  • Queries
?OID#:albsplitObj(:artist->?Artist :title->?Title)
?OID#:albsplitObj(:title->?Title :artist->?Artist)
?OID#:albsplitObj(:favorite->?Favorite )
?OID#:albsplitObj(:artist->?Artist :title->?Title :favorite->?Favorite )
?OID#:albmergeObj(:artist->"Elton John" :favorite->?Favorite )
:o6#:albsplitObj(:artist->"Elton John" :favorite->?Favorite)

4.26 Slotribution

  • Knowledge Base
Document(
  Group(
    Forall ?X ( ?X#_block(_color->_blue _size->_big) )
    _b1#_book
    _b2#_book(_title->"Java Programming")
    _o#_albmergeObj( _artist->"Elton John" _tivorite->"Goodbye Yellow Brick Road" )
    Forall ?OID ?Tivorite
    (
      ?OID#_albsplitObj(_title->?Tivorite _favorite->?Tivorite) :- ?OID#_albmergeObj(_tivorite->?Tivorite)
    )
  )
)
  • Queries
_a#_block(_color->_blue)
_b1#_block(_color->_blue)
?B#_book(_title->?T)

4.27 Slotribution 2

  • Knowledge Base
Document(
  Group(
    Forall ?C ?X (
      ?C#:Country(_capital->?X) :-
                  :geo-in(:government(?C) ?X)
    )

    Forall ?S ?X ?F ?V (
      ?S#:Startup(_capital->?X) :-
                  And(:founder-capital(?S ?F)
                      :venture-capital(?S ?V)
                      ?X = External(func:numeric-add(?F ?V)))
    )
    
    :geo-in(:government(:Canada) :Ottawa)
    :founder-capital("XYZ Inc." 100000)
    :venture-capital("XYZ Inc." 200000)
  )
)
  • Queries
?C#:Country(_capital->?X)
?S#:Startup(_capital->?X)

4.28 Mixed Use of Psoa terms with and without OID

  • Knowledge Base
Document(
  Group (
    Forall ?X ?Y ( 
      :isFatherOf(?Y ?X) :- And ( :isChildOf(?X ?Y) ?Y#:Male )
    )

    :c1#:isChildOf(:Adrian :Uwe)
    :Adrian#:Male
    :Uwe#:Male

    Forall ?X ?Y ?C ( 
      :isMotherOf(?Y ?X) :- And ( ?C#:isChildOf(?X ?Y) ?Y#:Female )
    )
    :isChildOf(:Adrian :Emily)
    :Jane#:Female
  )
)


  • Queries
:isFatherOf(?Y ?X)
:isMotherOf(?Y ?X)

4.29 Subclass Axiomatization

  • Knowledge Base
Document (
  Group (
    Forall ?X
    (
      ?X#:c1 :- ?X#:c2
    )
    Forall ?X
    (
      ?X#:c1(:p1->:v1) :- ?X#:c2(:p2->:v1)
    )
    :o1#:c2
    :o2#:c2(:p2->:v1)

    Forall ?X
    (
      ?X#:c1 :- ?X#:c3
    )
    Forall ?X
    (
      ?X#Top(:p1->:v1) :- ?X#:c3(:p2->:v1)
    )
    :o3#:c3(:p2->:v1)
  )
)
  • Queries
:o1#:c1
:o2#:c1
:o1#:c1(:p1->:v1)
:o2#:c1(:p1->:v1)
:o3#:c1(:p1->:v1)

5 Use Case

We are developing a use case, Geospatial Rules, with rules for enhancing geospatial data in a geographic information system (GIS) or a GIS combination.

6 Changes

  • PSOA2TPTP
    • Change translation of o#f() from member(o,f) to memterm(o,f), employed by both PSOA2Prolog and PSOA2TPTP, because member is a built-in predicate in some Prolog engines, e.g. SWI Prolog

7 PSOA RuleML vs. RIF RuleML

Comparison of Syntax and Semantics between PSOA RuleML and RIF RuleML
PSOA KB RIF KB Notes
Document(
  Group(
    _Tim#Top(_job->_engineer)
  )
)
Document(
  Group(
    _Tim[_job->_engineer]
  )
)
Document(
  Group(
    _1#_married(_Joe _Sue)
  )
)
Document(
  Group(
    _married(_Joe _Sue)
  )
)
Document(
  Group(
    _Joe#_male()
  )
)
Document(
  Group(
    _Joe#_male
  )
)
Document(
  Group(
    _Tim#_person(_job->engineer _child->_jack)
  )
)

Document(
  Group(
    _Tim[_job->engineer _child->_jack]
    _Tim#_person
  )
)
Document(
  Group(
    _1#_larger(_first->2 _last->1)
  )
)
Document(
  Group(
    _larger(_first->2 _last->1)
  )
)

8 References

1. Harold Boley, A RIF-Style Semantics for RuleML-Integrated Positional-Slotted, Object-Applicative Rules. In Nick Bassiliades, Guido Governatori, and Adrian Paschke, editors, RuleML Europe, volume 6826 of LNCS, pp. 94–211. Springer, 2011. Preprint: http://www.cs.unb.ca/~boley/papers/SemanticsPsoaRules.pdf. Slides for IJCAI 2011 Best Papers from Sister Conferences Track: http://www.cs.unb.ca/~boley/talks/SemanticsPsoaRules-talk-IJCAI2011.pdf. Slides with maximum details from paper: http://www.cs.unb.ca/~boley/talks/SemanticsPsoaRules-talk-UNB2011.pdf

2. Zou, G., Peter-Paul, R., Boley, H., Riazanov, A.: PSOA2TPTP: A Reference Translator for Interoperating PSOA RuleML with TPTP Reasoners. In: Bikakis, A., Giurca, A. (eds.) RuleML 2012. LNCS, vol. 7438, pp. 264–279. Springer, Heidelberg (2012). Preprint: http://www.cs.unb.ca/~boley/papers/DirectPSOA2TPTP.pdf. Slides: http://www.cs.unb.ca/~boley/talks/DirectPSOA2TPTP-talk.pdf

3. Zou, G., Peter-Paul, R., Boley, H., Riazanov, A.: PSOATransRun: Translating and Running PSOA RuleML via the TPTP Interchange Language for Theorem Provers. 6th International Rule Challenge, RuleML 2012. Preprint: http://www.cs.unb.ca/~boley/papers/PSOATransRun.pdf. Slides for Invited Demo: http://www.cs.unb.ca/~boley/talks/PSOATransRun-talk.pdf

4. Al Manir, M.S., Riazanov, A., Boley, H., Baker, C.J.O.: PSOA RuleML API: A Tool for Processing Abstract and Concrete Syntaxes. In: Bikakis, A., Giurca, A. (eds.) RuleML 2012. LNCS, vol. 7438, pp. 280–288. Springer, Heidelberg (2012). Preprint: http://www.cs.unb.ca/~boley/papers/PSOA_RuleML_API.pdf. Slides: http://www.cs.unb.ca/~boley/talks/PSOA_RuleML_API-talk.pdf

5. Zou, G., Boley, H.: A Translator Framework for the Interoperation of Graph plus Relational Data and Rules on the Web. 5th Atlantic Workshop on Semantics and Services, February 2014, Slides: http://www.cs.unb.ca/~boley/talks/InteropGraphRel-AWoSS2014-talk.pdf

6. Boley, H.: A Music Album Knowledge Base in the Relational and Object-Centered Paradigms of the PSOA RuleML Language. RuleML Memo, 25 October 2014, http://www.cs.unb.ca/~boley/papers/MusicAlbumKB.txt

7. Boley, H.: PSOA RuleML: Integrated Object-Relational Data and Rules. In Wolfgang Faber and Adrian Paschke, editors, Reasoning Web. Web Logic Rules (RW2015) - 11th International Summer School 2015, Berlin, Germany, July 31-August 4, 2015, Tutorial Lectures, volume 9203 of Lecture Notes in Computer Science, pp. 114-150. Springer, 2015. SpringerLink: Abstract. Postprint: http://www.cs.unb.ca/~boley/papers/PSOAObjRelDataRules.pdf. Presented in the Computational Logic Seminar – MUGS, 27 May 2015, the SRI AIC Seminar Series, 9 June 2015, plus RW2015, 31 July - 4 August 2015. Slides for RW2015: http://www.cs.unb.ca/~boley/talks/PSOAObjRelDataRules-talk-RW2015.pdf. Slides with maximum details from paper: http://www.cs.unb.ca/~boley/talks/PSOAObjRelDataRules-talk.pdf. PSOARuleMLSQLSPARQL (pdf, docx) subset of slides for AWoSS 2015: http://www.cs.unb.ca/~boley/talks/PSOAObjRelDataRules-AWoSS2015-talk.pdf

8. Zou, G., Boley, H.: PSOA2Prolog: Object-Relational Rule Interoperation and Implementation by Translation from PSOA RuleML to ISO Prolog. In Bassiliades, N. and Gottlob, G. and Sadri, F. and Paschke, A. and Roman, D. (eds.) RuleML 2015. LNCS, vol. 9202, pp. 176-192. Springer, 2015. SpringerLink: Abstract. Preprint: http://www.cs.unb.ca/~boley/papers/PSOA2Prolog.pdf. Slides: http://www.cs.unb.ca/~boley/talks/PSOA2Prolog-talk.pdf

9. Zou, G.: PSOA RuleML Integration of Relational and Object-Centered Geospatial Data, In Bassiliades, N., Fodor, P., Giurca, A., Gottlob, G., Kliegr, T., Nalepa, G. J., Palmirani, M., Paschke, A., Proctor, M., Roman, D., Sadri, F. and Stojanovic, N. (eds.) Joint Proceedings of the 9th International Rule Challenge, the Special Track on Rule-based Recommender Systems for the Web of Data, RuleML2015 Industry Track and the 5th RuleML Doctoral Consortium. Paper: http://ceur-ws.org/Vol-1417/paper14.pdf. Slides: http://www.cs.unb.ca/~boley/talks/GeoIntegration-talk.pdf

10. Zou, G.: The PSOATransRun 1.0 System for Object-Relational Reasoning in RuleML. 6th Atlantic Workshop on Semantics and Services, December 2015, Abstract: http://ruleml.org/talks/AWoSS2015/PSOATransRun1.0-AWoSS2015.pdf, Slides: http://ruleml.org/talks/AWoSS2015/PSOATransRun1.0-AWoSS2015-talk.pdf.

11. Boley, H.: The RuleML Knowledge-Interoperation Hub. In volume 9718 of Lecture Notes in Computer Science, pp. 19-33. Springer, 2016. SpringerLink: Abstract. Preprint: http://www.cs.unb.ca/~boley/papers/RuleMLKnowleropHub.pdf. Slides: http://www.cs.unb.ca/~boley/talks/RuleMLKnowleropHub-talk.pdf.

12. Zou, G., Boley, H.: Minimal Objectification and Maximal Unnesting in PSOA RuleML. In volume 9718 of Lecture Notes in Computer Science, pp. 130-147. Springer, 2016. SpringerLink: Abstract. Preprint: http://www.cs.unb.ca/~boley/papers/MinObjMaxUnnPSOARuleML.pdf. Slides: http://www.cs.unb.ca/~boley/talks/MinObjMaxUnnPSOARuleML-talk.pdf.