PSOA2TPTP: A Reference Translator for Interoperating PSOA RuleML with TPTP Reasoners

Preview:

DESCRIPTION

 

Citation preview

BackgroundSystem Architecture

ImplementationSummary and Future Work

PSOA2TPTP: A Reference Translatorfor Interoperating PSOA RuleML

with TPTP Reasoners

Gen Zou1 Reuben Peter-Paul1 Harold Boley1,2

Alexandre Riazanov3

1Faculty of Computer Science,University of New Brunswick, Fredericton, Canada

2National Research Council Canada,Information and Communications Technologies

3Department of Computer Science & Applied StatisticsUniversity of New Brunswick, Saint John, Canada

1 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

2 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

3 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Interoperation Source – PSOA RuleML

Integrates relational and object-oriented modelingGeneralizes RIF-BLD, F-logic and POSLUses positional-slotted object-applicative (psoa) termsGeneral case:o#f([t1,1 ... t1,n1] ... [tm,1 ... tm,nm] p1->v1 ... pk->vk)

Special cases:o#f(t1 ... tn p1->v1 ... pk->vk)

o#f(t1 ... tn)

o#f( p1->v1 ... pk->vk)

o#f

4 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

PSOA Example in Presentation Syntax (PS)

Document(Group (

Forall ?Hu ?Wi ?Ch ?o ?1 (?o#_family(_child->?Ch) :-

And(?o#_family(_husb->?Hu _wife->?Wi)?1#_kid(?Wi ?Ch))

)_f1#_family(_husb->_Joe _wife->_Sue)_k1#_kid(_Sue _Pete)

))

5 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Interoperation Targets

TPTP’s full First-Order Form (TPTP-FOF)Allows arbitrary first-order formulasSyntax and semantics

Syntax Semantics Syntax Semantics~p ¬p v1 =v2 v1 =v2

p1 & p2 p1 ∧ p2 v1 !=v2 ¬(v1 =v2)p1 | p2 p1 ∨ p2 ?[v1,...,vn]:p ∃ v1,...,vn :pp1 => p2 p1→ p2 ![v1,...,vn]:p ∀ v1,...,vn :p

VampirePrimeOpen-source TPTP reasoner derived from thehigh-performance Vampire reasoner

6 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

7 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Components and Workflow of PSOA2TPTP

ANTLR: ANother Tool for Language RecognitionASO: Abstract Syntax Object

8 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Workflow of ANTLR-Generated Components

AST: Abstract Syntax Tree (condensedtree encoding of the input stream)

9 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

10 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

11 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Parser Grammar Rewriting

ANTLR-generated parser uses LL (Left-to-right scanning,Leftmost derivation) mechanismThe original EBNF grammar of PSOA/PS extended withsyntactic sugar is non-LL and cannot be directly used asthe ANTLR parser grammarWe rewrite it into an LL(1) grammar, so that it not only canbe accepted by ANTLR but is also more efficient

Elimination of left recursionLeft factoring

12 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Parser Grammar Rewriting

Elimination of left recursion – examplepsoa : term '#' term ('(' tuples_and_slots ')')?

| term '(' tuples_and_slots ')' ;term : const | var | psoa | external_term

is rewritten toterm : psoa | non_psoa_term ;non_psoa_term : const | var | external_term ;psoa : non_psoa_term psoa_rest+ ;

13 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Parser Grammar Rewriting

Left factoring – exampletuples_and_slots: tuple* (term '->' term)*

| term+ (term '->' term)* ;

is rewritten totuples_and_slots: tuple+ (term '->' term)*

| term+ ('->' term (term '->' term)*)?|;

14 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

15 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Normalization – Static Tupribution and Slotribution

Transform composite formulas into a conjunction of elementaryconstructs

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

& o#Top(p1->v1) &...& o#Top(pk->vk)

16 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Translation of Elementary Constructs – Terms

Constants τpsoa(_C) = lC (“low line” C)Variables τpsoa(?v) = Qv (“Question mark” v)Tuple termsτpsoa(o#Top(t1 . . .tk)) =

tupterm(τpsoa(o), τpsoa(t1) . . . τpsoa(tk))

Slot termsτpsoa(o#Top(p−> v)) =

sloterm(τpsoa(o), τpsoa(p), τpsoa(v))

Membership termsτpsoa(o#f()) = member(τpsoa(o), τpsoa(f))

17 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Translation of Elementary Constructs – Formulas

Conjunctionτpsoa(And(f1 . . . fn)) = (τpsoa(f1) & ... & τpsoa(fn))

Implication τpsoa(ϕ : − ψ) = (τpsoa(ψ)=> τpsoa(ϕ))

Existential Quantificationτpsoa(Exists ?v1 . . . ?vn f) =

(? [τpsoa(?v1)...τpsoa(?vn)] : τpsoa(f))

Universal Quantificationτpsoa(Forall ?v1 . . . ?vn f) =

(! [τpsoa(?v1)...τpsoa(?vn)] : τpsoa(f))

18 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Translation of Queries

Use reserved answer predicate ans to obtain the bindings forquery variable ?vi

! [τpsoa(?v1)...τpsoa(?vn)] : (τpsoa(q) =>ans("?v1 = ",τpsoa(?v1),

...,"?vn = ",τpsoa(?vn)))

19 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Example – Input

Input knowledge baseDocument(

Group (Forall ?Hu ?Wi ?Ch ?o ?1 (

?o#_family(_child->?Ch) :-And(?o#_family(_husb->?Hu _wife->?Wi)

?1#_kid(?Wi ?Ch)))_f1#_family(_husb->_Joe _wife->_Sue)_k1#_kid(_Sue _Pete)

))

QueryAnd(_f1#_family(_husb->_Joe _wife->_Sue _child->?Who)

_k1#_kid(_Sue ?Who))

20 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Example – Normalization

Normalized knowledge baseDocument(

Group (Forall ?Hu ?Wi ?Ch ?o ?1 (

And( ?o#_family()?o#Top(_child->?Ch)) :-

And( And( ?o#_family()?o#Top(_husb->?Hu)?o#Top(_wife->?Wi))

And( ?1#_kid()?1#Top(?Wi ?Ch)))

)_f1#_family() _f1#Top(_husb->_Joe)

_f1#Top(_wife->_Sue)_k1#_kid() _k1#Top(_Sue _Pete)

))

21 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Example – Translation

TPTP generated for knowledge basefof(ax01,axiom,(

! [Q1,Qo,QCh,QWi,QHu] :( ( member(Qo,lfamily)& sloterm(Qo,lwife,QWi)& sloterm(Qo,lhusb,QHu)& member(Q1,lkid)& tupterm(Q1,QWi,QCh) )

=> ( member(Qo,lfamily)& sloterm(Qo,lchild,QCh) ) ))).

fof(ax02,axiom,( member(f1,lfamily)& sloterm(f1,lwife,lSue)& sloterm(lf1,lhusb,lJoe) )).

fof(ax03,axiom,( member(lk1,lkid) & tupterm(k1,lSue,lPete) )).

22 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Example – Translation and Execution

TPTP generated for queryfof(query,theorem,(

! [QWho] :( ( member(f1,lfamily)& sloterm(f1,lwife,lSue)& sloterm(f1,lchild,QWho)& sloterm(f1,lhusb,lJoe)& member(lk1,lkid)& tupterm(lk1,lSue,QWho) )

=> ans("?Who = ",QWho) ) )).

VampirePrime outputProof found....

... | «ans»("?Who = ", lPete) ...

23 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

24 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

ANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

RESTful Web API

PSOATransRun wraps PSOA2TPTP and VampirePrimeinto two REST services

Translation: PSOA2TPTPExecution: VampirePrime

Requests are sent via HTTP POST methodInputs and outputs are JSON-encoded stringsAvailable online (documentation and system):http://wiki.ruleml.org/index.php/PSOA_RuleML#PSOATransRun

http://198.164.40.211:8082/psoa2tptp-trans/index.html

25 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Outline

1 Background

2 System Architecture

3 ImplementationANTLR GrammarsPSOA-to-TPTP TranslationRESTful Web API

4 Summary and Future Work

26 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Summary

We have implemented a first version of the PSOA2TPTPtranslator using the ANTLR v3 frameworkThus provide a semantics-preserving translation fromPSOA RuleML to TPTPPSOATransRun wraps PSOA2TPTP and VampirePrimeinto REST services for convenient access

27 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

Future Work

Extend PSOA2TPTP capability to handle all PSOA RuleMLconstructsImplement the fully-ASO-based translatorDevelop real-world Clinical Intelligence use case andothers employing PSOATransRun

28 / 29

BackgroundSystem Architecture

ImplementationSummary and Future Work

References

Boley, H.A RIF-Style Semantics for RuleML-Integrated Positional-Slotted,Object-Applicative RulesIn Bassiliades, N., Governatori, G., Paschke, A. (eds.)RuleML Europe, vol. 6826 of LNCS, pp. 194–211. Springer, 2011.

Zou, G., Peter-Paul, R., Boley, H. and Riazanov, A.PSOA2TPTP: A Reference Translator for Interoperating PSOA RuleML withTPTP ReasonersIn: Bikakis, A., Giurca, A. (eds.)RuleML 2012, vol. 7438 of LNCS, pp. 264–279. Springer, 2012.

Al Manir, M.S., Riazanov, A., Boley, H. and Baker, C.J.O.PSOA RuleML API: A Tool for Processing Abstract and Concrete SyntaxesIn: Bikakis, A., Giurca, A. (eds.)RuleML 2012, vol. 7438 of LNCS, pp. 280–288. Springer, 2012.

29 / 29

Recommended