Ontology based Software Development

user interactions: user actions: create/update/delete, query/view, user goals/intentions - still sketchy; not yet used. ○ abstract convergence platform; software ...
234KB taille 49 téléchargements 330 vues
Ontology based Software Development

J.M. Vanel - 2009-06 Apply Artificiel Intelligence to software engineering http://jmvanel.free.fr/

The tools ●



EulerGUI, a light-weight IDE for the N3 language Déductions, a set of N3 models and rules to: –

Generate forms from OWL



Transforms models (e.g. UML to OWL)

Strong points and avantages ●



● ●

« Model once, run everywhere » « sustainable software » Infrastructures are just commodities; they must be interchangeable Open Source Based on standards : RDF, OWL, N3, Drools –

UML, eCore, SQL inputs

Information flux (seen by designer) Reuse existing technology Abstract Application Déductions

Business Model POJO SQL RDFS, OWL

Swing

PHP

eclipse

.Net

JDBC Sesame

Rules UML

Concrete Plateform

Web Services N3

SWRL

Prolog

Rewerse Drools

Embedded C

Coherence and reuse of existing models Application 1 Extraction, particularisation

Business Model Règles

Déductions

Application 2

Java Swing MySQL

PHP MySQL

Application 3 Exposes / calls Web Services

Top level sequence diagram Designer              Rule             JVM         Runtime     End       GUI   |                   Engine           Runtime     Storage     User   |                   |                |            |          .         .   ­­­add bizz class­­>|                |            |          .         .   ­­­add property  ­­>|                |            |          .         .   |                   |­­new object ­­>|            |          .         .   |                   |­­assign prop­­>|            |          .         .   |                   |­­method call­­>|            |          .         .   |                   |                |// GUI      |          .         .   |                   |                |// running  |          |         |   ­­­add bizz rule ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­>|          |         |   |                   |                |            |          ­­event­­>|   |                   |                |            ||

Notes: ● Runtime Storage is also a Rule Engine ● generated GUI possibly includes multi-view for the underlying bizz objects, including the update logic

Design time Rule Engine ●



Designer enters/imports: ●

a domain model (classes and properties)



Business rules



A small application specification

The rest is background knowledge (supporting ontologies and rules)

Current rules data flow N3 application spec.

Domain Model (OWL as N3)

Rule engine

Swing GUI

N3 result Instantiator.java

GUIHelper.java

TripleStoreDrools

Supporting ontologies stack ●

software applications



business applications TODO













generic GUI: widget/component, callback/action; this is a high-level model describing the GUI from the user point of view user interactions: user actions: create/update/delete, query/view, user goals/intentions - still sketchy; not yet used abstract convergence platform; software application, generic GUI, etc, are to be translated in terms of it - TODO concrete platforms (Java SE, Java J2EE, SWI Prolog + XPCE, Python, PHP, Ruby on Rails, ...); this is the low level layer software purposes ( point to most human activities being kind of management or viewing/search/navigation) ; for now 2 properties in software applications software project (software development) : classes(ontology), rules, purpose, platform, libraries, deployment, human roles, team, version, realease, test, specification, documentation, plus notions covered by UML 1 and 2 - TODO

Application-->GUI rules

#                       editedClass            * # SoftwareApplication­­­­­­­­­­­owl:Class­­­rdf:Property #      |                            |             | #      |       1                 1  |*            |* # DefaultPane­­­­­­­­­­­­­­­­­­­Form­­­­­InputWidget                                              ^ ^                                              | |                                              | ObjectInputWidget #                                            DatatypeInputWidget                                                  |     |                                                 Label  |                                                        |                                                     TextField

Current rules flow software_applications.n3

Domain Model (OWL as N3)

app_gui-rules.n3 gui_generic.n3

java_projection-rules.n3 java_library.n3

The blue rectangles bear the name of the ontology, the arrows the transform rules.

N3 language ●

Compatible with RDF



Expresses facts, models, rules and queries



Created by W3C for its own use, not yet a W3C recommandation



Readable by Protégé



Syntax colored editor exists (Vim)





We use the same rule language for infrastructure (form generation) and for business rules three N3 rules engines: Euler(Prolog), CWM (Python) , Drools – RETE (Java)

N3 : data and model @prefix rdfs: . @prefix owl: . :p1 a :Person ; :size 1.79 . :Person a owl:Class . :size

a owl:DatatypeProperty ; rdfs:domain :Person ; rdfs:range

xsd:double ;

Rule example 0 # when C has a parent P, then C is the child of P : { ?C :hasParent ?P . } => { ?P :hasChild ?C . }.

?C, ?P are universally qualified

Rule example 1 # add a field in the form for each property of a class: { ?CLASS gui:hasForm ?FORM . ?PROP rdfs:domain ?CLASS .

?CLASS, ?FORM, ?PROP are universally qualified

} => { ?FORM gui:hasField ?FIELD .

FIELD is existentially qualified

?FIELD gui:inputWidgetSpecification ?PROP . }.

Rule example 2 # the type of the field depends on the type of the # property: ObjectProperty or DatatypeProperty { ?FIELD gui:inputWidgetSpecification ?PROP . ?PROP a owl:DatatypeProperty . } => { ?FIELD a gui:DatatypeInputWidget . }.

OWL implemented with N3 logic ●



as part of the Euler project, a library of N3 rules implements the logic of OWL and RDF Schema (transitive property, inheritance, etc), and other goodies, see:

http://eulersharp.svn.sourceforge.net/viewvc/eulersha

{ ?P a owl:TransitiveProperty. ?S ?P ?X. ?X ?P ?O. } => { ?S ?P ?O }.

Business rules example For an order, there an associated payment : { ?C a Order } => { ?C hasPaymentRequest ?PR }. If the holder had a payment incident, then the order is cancelled : { ?C hasHolder ?H . ?H hasPaymentIncident ?PI } => { ?C hasStatus cancelled }.

Rules example 2 If one customer has already ordered items in same Domain but different Category than the last items, propose this different Category to customer: { ?CUSTOMER :hasOrderedItem ?ITEM . ?ITEM :domain ?DOMAIN . ?ITEM :category ?CATEGORY . ?ITEM2 :belongsTo :lastItems . ?ITEM2 :domain ?DOMAIN . ?ITEM2 :category ?CATEGORY2 . ?CATEGORY2 log:notEqualTo ?CATEGORY . } => {

:proposal :category ?CATEGORY2 } .

Modelization made easy: textual UML Person