\n<<<\n* Dr. [[DONG Jin-Song|http://www.comp.nus.edu.sg/~dongjs/]], Associated Professor, School of Computing, National University of Singapore.\n* Mr. [[FENG Yu-Zhang|http://www.comp.nus.edu.sg/~fengy]], PhD Candidate, School of Computing, National University of Singapore.\n* Mr. [[LIU Yang|http://www.comp.nus.edu.sg/~liuyang]], PhD Candidate, School of Computing, National University of Singapore.\n* Dr. [[LI Yuan-Fang|http://www.comp.nus.edu.sg/~liyf]], Research Fellow, School of ITEE, University of Queensland.\n* Dr. ZHANG Da-Qing, Institut National des Télécommunications.\n<<<\n
<HTML>\n<!--CUT DEF section 1 --><P>\nIn this section, we present a case study of a context-aware home\nontology based on a home-domain extension of CONON. This ontology is about a smart\nhome environment equipped with various networked sensors/actuator\ndevices such as cameras, microphones, based location sensors, etc.\nIn this environment, sensors&#X2019; reading can help to determine the\nuser&#X2019;s location, which may trigger actuators to perform certain\nactivities if needed. For example, when a user moves into the\nbathroom to take a shower, his/her personal communication agent\nshould forward all phone calls to voice mail box. The testing\nontology contains around 4000 RDF triples and 23 user defined rules. </P><P>Firstly, we performed standard Semantic Web reasoning tasks on the\ngiven ontology. Successful reasoning confirmed the ontology\ndefinition. Unsuccessful reasoning reported missing or wrong\npredictions. Furthermore, three inconsistencies were reported by our\nCLP programs. </P><P>Secondly, we checked consistencies in the 23 rules. Three kinds of\ninconsistencies are detected and explained as follows.\n</P><DL CLASS="description"><DT CLASS="dt-description">\n<B>Antecedent redundancy</B></DT><DD CLASS="dd-description"> The first kind of anomaly detected\nis of type antecedent redundancy resulted by the following two\nrules.<P>\n\n<TT>User</TT>(?u) &#X2227;<TT>BedRoom</TT>(?br) &#X2227;<TT>locatedIn</TT>(?u, ?br) &#X2227;<TT>isSleepingTime</TT>(?u, ?t)\n&#X2227;<TT>SleepingTime</TT>(?t) &#X2227;<TT>Service</TT>(?lightService) &#X2227;<TT>status</TT>(?lightService,OFF)<BR>\n &#X2192;<TT>situation</TT>(?u, SLEEPING)\n<br>\n<br>\n<TT>SleepingTime</TT>(?t) &#X2192;<TT>Service</TT>(?lightService) &#X2227;<TT>status</TT>(?lightService,OFF)\n\n</P><P>The first rule says that if the time is a user&#X2019;s sleeping time, the\nuser is in bedroom, and the light is off, then the conclusion is\nthat the user is sleeping. The second rule says that if the time is\nsleeping time, the light should be off. But since the sleeping time\ncan imply the light is off, the first rule above has the\nredundancies in its antecedent. Actually, we can remove the light\noff condition in the first rule.</P></DD><DT CLASS="dt-description"><B>Subsumption of Rules</B></DT><DD CLASS="dd-description">\nThe second kind of anomaly detected is of type subsumption of rules\nresulted by the following two rules.<P>\n\n<TT>User</TT>(?u) &#X2227;<TT>LivingRoom</TT>(?lr) &#X2227;<TT>locatedIn</TT>(?u, ?lr) &#X2227;<TT>TV</TT>(?tv) &#X2227;<TT>status</TT>(?tv, ON)<BR>\n &#X2192;<TT>situation</TT>(?u, WATCHINGTV)\n\n<br>\n<br>\n<TT>User</TT>(?u) &#X2227;<TT>LivingRoom</TT>(?lr) &#X2227;<TT>locatedIn</TT>(?u, ?lr) &#X2227;<TT>TV</TT>(?tv) &#X2227;<TT>status</TT>(?tv,\nON) &#X2227;<TT>GamePlayer</TT>(?gp) &#X2227;<TT>status</TT>(?gp, ON)<BR>\n&#X2192;<TT>situation</TT>(?u, ENTERTAINING)\n\n</P><P>The first rule says that if a user is in living room and the TV is\non, then he/she is watching TV. The second rule says that if a user\nis in living room and both TV and game player are on, then he/she is\nentertaining.</P><P>The first rule has less conditions (more general antecedent), but\nstronger conclusion (Watching TV is a kind of entertainment).\nAccording to the definition of rule subsumption, the first rule\nsubsumes the second rule. Therefore we can remove the second rule\nsafely. Actually, both of the rules are needed. The conclusion of\nthe second rule needs to be strengthened to <I>PLAYINGGAME</I>.\n&#XA0;<BR>\n</P></DD><DT CLASS="dt-description"><B>Chained Inconsistency</B></DT><DD CLASS="dd-description">\nThe third kind of anomaly detected is of type chained inconsistency\nresulted by the following three rules.<P>\n\n<TT>Amblyopia</TT>(?u) &#X2227;<TT>status</TT>(?lightService,ON) &#X2227;<TT>Service</TT>(?lightService)<BR>\n &#X2192;<TT>condition</TT>(?u, AWAKE)\n\n<br>\n<br>\n<TT>User</TT>(?u) &#X2227;<TT>condition</TT>(?u, AWAKE) &#X2192;<TT>DayTime</TT>(?t)\n\n\n<br>\n<br>\n\n<TT>DayTime</TT>(?t) &#X2192;<TT>Service</TT>(?lightService)\n&#X2227;<TT>status</TT>(?lightService,OFF)\n\n</P><P>The first rule says that if a user has vision defects and the light\nis on, then the user is awake. The second rule says that if a user\nis awake, then it means now it is day time. The third rule says that\nin the day time, the light should be off.</P><P>According to the three rules above, we have train conditions from\nthe first rule the third rule. It gives a contradiction that light\non implies light off. After re-analysis the rules, we found the\nsecond rule is wrong and needs to be removed from the system.\n</P></DD></DL><P>When the ontology and rule set are big and developed by several\ndevelopers, it is very likely to have inconsistencies. From the\nabove examples, it shows that our approach can successfully identify\nthe inconsistencies in the system, and hence help the ontology\ndesigners to validate and verify the ontology and rule set.</P><!--CUT END -->\n</HTML>
In this section, we discuss the Reasoning context rules in CLP. The complete CLP reasoning program is available [[here|RuleConsistency.clpr]].\n\nIn a pervasive environment, context rules are usually constructed and maintained by multiple parties such as system designers, developers or even users, who may have different or contradicting views of the system being developed. Hence anomalies among rules are more likely to exist in a pervasive computing system than in a usual rule-based system. These anomalies can exist as not only OWL ontology inconsistencies, which can be checked by the rules described in [[OWL Reasoning]], but also anomalies among SWRL rules. We are able to detect three types of anomalies related to a\nset of rules, namely inconsistency, redundancy and circularity, as identified in previous work. Each of these anomalies are caused by different reasons and rule relations.\n\nThese anomalies have severe consequences to the correctness and the efficiency of the system. For example, inconsistent rules may lead to contradicting inference results which may cause the system to behave undesirably. Redundancy results in more rules in the rule base than necessary. In many cases the complexity of the system is polynomial or even exponential to the size of the rule set. Yet in a pervasive environment response and execution time are critical to the success of the application. Hence it is important to reduce rule set redundancy as much as possible.\n\nBased on the CLP reasoning support for SWRL-enabled OWL ontologies described in [[OWL Reasoning]], we can further develop mechanisms for detecting anomalies among a set of SWRL rules conveniently. The core of this section is a discussion on different anomalies as well as the CLP implementation for detecting these rules.\n
To reason about the consistencies of context rules, you need to encode the ontology and rules in the CLP format. \n\nThe CLP(R) definitions of the context rule is as follows:\n''rule(r3, instance(vegetarian, mc), [subClassOf(cow, vegetarian), subClassOf(madcow, cow), disjointWith(meat, vegetable), instance(madcow, mc), instance(cow, c)])''.\n\nThe structure of the predicate is ''rule(name, concequent,[antecedent list])''.\n\nAfter done that, the reasoning can be performed as follows:\n\n1 Create a CLPR file and put the encoded ontology and rule set in it. You need to declare the dynamic atoms in the beginning of the CLPR file. Please refer to the [[test case|TestCases.clpr]] file.\n\n2 put the following two lines in the end of your encoding\n'':- consult('[[RuleConsistency.clpr|RuleConsistency.clpr]]').''\n'':- output(cc).''\n\n3 open a cmd window, go to the working directory. Call the following command, the result will be output to out.txt.\n''clpr.exe XXXX.clpr''\n
Table 1 below lists the CLP syntax for OWL class axioms, property axioms and OWL DL assertions. Class descriptions and restrictions are basically functions. To ease the translation and reasoning processes, we represent them using anonymous classes. For example in OWL, ''complementOf(C)'' represents a class whose set of instances is complement of that of ''C''. In CLP, we use the predicate ''complementOf(C,AC)'' to represent the relationship between ''C'' and the anonymous class ''AC''. Table 2 and 3 below show the CLP syntax of class descriptions and restrictions.\n\n[img[Encoding|encoding.JPG]]
To reason about the ontology and SWLR rule, you need to encode the ontology first in the CLP format. After done that, the reasoning can be performed as follows:\n\n1 Create a CLPR file and put the encoded ontology in it. You need to declare the dynamic atoms in the beginning of the CLPR file. Please refer to the [[test case|TestCases.clpr]] file.\n\n2 put the following two lines in the end of your encoding\n'':- consult('[[SWRL.clpr|SWRL.clpr]]').''\n'':- output(---QUERY---).''\n\nNote: ---QUERY--- here is the thing you want to check, for example, it can be ''instance(c, x)'', ''sub_val(conflictTasks, t1, t2)''. If you want to check consistency of the ontology, just use ''cc''.\n\n3 open a cmd window, go to the working directory. Call the following command, the result will be output to out.txt.\n''clpr.exe XXXX.clpr''\n
One of the current trends for modern computing is towards pervasive, ubiquitous environment which envisions a seamless integration and cooperation of devices, software agents and services. Pervasive systems distinguish themselves from other general software applications by the following three characteristics. Firstly pervasive systems are highly heterogeneous due to its use of a diversity of hardware and software. Secondly as the system behaviours are highly dependent on the physical locations, orientation of system users and devices with respect to other system entities, pervasive systems usually have a highly dynamic nature. Thirdly, pervasive systems should be user centered rather than system centered; the services and applications should be adaptive to user context and thus are context-aware in nature.\n\nConsequently there are three key issues in building the heterogeneous, dynamic, context-aware systems. The first one is how to represent raw context data, which is obtained from various sources in different formats, in a form that can be easily interpreted by independently developed applications. The second issue involves being able to answer expressive queries. Thirdly, higher-level context information not present in the system should be inferred from the lower-level context data.\n\nIn light of these, the Semantic Web has emerged as a promising technology to support successful development of pervasive systems. The Semantic Web, as envisioned by Tim Berners-Lee, is the next generation of Web, in which information is semantically marked up. One key feature of the Semantic Web that makes it a suitable candidate for the infrastructure of pervasive environment is its high degree of interoperability. Using the Semantic Web languages, ontology concepts are defined independently from any agent implementations. The semantics of the concepts are described using standard knowledge representation vocabularies. Therefore Semantic Web ontologies provide a platform on which independently developed applications can share common context knowledge without having to pre-define agreements on how they should interoperate. Furthermore the Semantic Web also provides a set of relatively expressive languages and decidable reasoning algorithm. These make Semantic Web languages suitable for specifying and querying complex context information. In our previous work we have successfully deployed context ontology and rule set in smart environments.\n\nResearchers have recently proposed Semantic Web Rules Language (SWRL) by extending the Web Ontology Language (OWL) with Horn-style rules for more expressiveness. In pervasive environment, SWRL provides a syntactically and semantically coherent way to describe context reasoning rules which can be represented in application level syntax like Jena. For example the inference of high-level context from low-level context information can be conveniently specified in SWRL rules. \n\nIn a pervasive environment, context ontologies and rules are usually constructed and maintained by multiple parties such as system designers, device developers or even users, who may have different or contradicting views of the system. Hence anomalies such as inconsistency and redundancy within the ontology and among the rules are more likely to exist in a pervasive computing system than in a usual rule-based knowledge system. Yet such anomalies may greatly jeopardize the correctness and efficiency of the system, and hence should be discovered as early as possible. This paper intends to cope with the inconsistency issue that might arise from a large context rule set.\n\nWell known Semantic Web ontology tools such as [[RACER|http://www.racer-systems.com/index.phtml]], [[FaCT++|http://owl.man.ac.uk/factplusplus]] and Pellet have focused on reasoning about ontologies rather than rules. Hence we propose in this paper to use the constraint logic programming (CLP) technique to reason about ontologies and rules, so that not only standard ontology reasoning tasks can be accomplished, detecting inconsistency, redundancy and circularity among rules can also be achieved under one umbrella.
[[Introduction]]\n[[Overview]]\n[[OWL Reasoning]]\n[[Context Rules Analyzing]]\n[[Case Studies]]\n[[Program & Download]]\n----\n[[About Us]]\n[img[email us|09.jpg][mailto:liuyang@comp.nus.edu.sg]]\n<html>\n<a href="/cgi-bin/pagecount?/~liuyang/veri/index.html">stats</a>\n</html>\n
In this section, we discuss the Modelling & Reasoning about OWL ontologies in CLP. The complete CLP reasoning program is available [[here|SWRL.clpr]].\n\n\n!''Defining CLP syntax for OWL language constructs''\nIn order to reason about OWL and SWRL ontologies in CLP, we need to embed OWL semantics in CLP rules, so that the CLP reasoning engine can be used as a Semantic Web reasoning engine according to the OWL language semantics. The first step is to define the CLP syntax for OWL language constructs. This also forms the basis for an automated translator from OWL ontologies to CLP programs. The details of the defintions are available in the paper submitted to Pervasive Computing 2008.\n\n!''Embedding OWL semantics in CLP rules''\n<HTML>\n<!--CUT DEF section 1 --><P>\nHaving defined the corresponding CLP syntax for OWL language\nconstructs, we devote this section to describing how OWL language\nsemantics can be embedded in CLP rules for the purpose of performing\nstandard Semantic Web reasoning tasks. Recall that SWRL rules allow\nonly a fixed set of atoms to appear in the rule, namely the OWL\nassertions. Therefore we restrict the queries in our system to the\nfollowing four types: (1)<CODE>instance(C,X)</CODE> which succeeds\nif <CODE>X</CODE> is an instance of <CODE>C</CODE>;\n(2)<CODE>sub_val(P,X1,X2)</CODE> which succeeds if\n<CODE>X1</CODE> is related to <CODE>X2</CODE> by\n<CODE>P</CODE>; (3)<CODE>sameAs(X1,X2)</CODE>: succeeds if\n<CODE>X1</CODE> is the same as <CODE>X2</CODE>; and\n(4)<CODE>differentFrom(X1,X2)</CODE>: succeeds if\n<CODE>X1</CODE> is different from <CODE>X2</CODE>.</P><!--CUT END -->\n</HTML>\n\n!''Reasoning Tasks''\n<HTML>\n<!--CUT DEF section 1 --><P>\nThere are three types of standard Semantic Web reasoning tasks,\nnamely instantiation reasoning, subsumption reasoning and\nconsistency checking.\nInstantiation reasoning asserts that one resource is or is not an\ninstance of a class. This type of queries can be easily supported by\ndirectly querying <CODE>instance</CODE> and\n<CODE>not_instance</CODE>.\nThe task of subsumption reasoning is to infer that an OWL class is a\nsub-class of another. This type of reasoning tasks can be\naccomplished by adding the rule</P><PRE CLASS="verbatim"> subsume(A, B) :- assert(instance(A, x)), instance(B, x).\n</PRE><P>where <CODE>x</CODE> is a fresh constant. So a class\n<CODE>A</CODE> is a subclass of another class <CODE>B</CODE> if\nan arbitrary individual <CODE>x</CODE> which is asserted to be an\ninstance of <CODE>A</CODE> is reasoned to be an instance of\n<CODE>b</CODE>.</P><P>Ensuring the consistency of ontologies is an important task in\nvarious stages of ontology development, as inconsistent ontologies\nmay lead agents to reason erroneously and make wrong conclusions. To\nbe precise, knowledge base consistency amounts to verifying whether\nevery concept in the knowledge base admits at least one individual.\nThus the consistency of a class and of an ontology boils down to the\ninstance level. We define 5 rules to check for ontology\ninconsistency. We show only one here.</P><PRE CLASS="verbatim"> cc_maxCardinality :-\n not (maxCardinality(C1, P, N), instance(C1, X),\n predCount(P, X, V), V &gt; N).\n</PRE><P>The ontology is consistent with respect to\n<CODE>maxCardinality</CODE> if there does not exist an individual,\nwhich is an instance of a class whose instances have at most\n<CODE>N</CODE> images under property <CODE>P</CODE>, has more\nthan <CODE>N</CODE> images under <CODE>P</CODE>.</P><!--CUT END -->\n</HTML>\n\n!''Supporting SWRL Reasoning''\n<HTML>\n<!--CUT DEF section 1 --><P>\nOne of the main purposes of SWRL rules is to infer new knowledge not\npresent in the ontology. A SWRL rule is of the form <I>A</I><SUB>1</SUB>, <I>A</I><SUB>2</SUB>,\n&#X2026;, <I>A</I><SUB><I>n</I></SUB> &#X2192; <I>C</I><SUB>1</SUB>, <I>C</I><SUB>2</SUB>, &#X2026;, <I>C</I><SUB><I>m</I></SUB> where <I>A</I><SUB><I>i</I></SUB> and <I>C</I><SUB><I>j</I></SUB>\nare either SWRL atoms or SWRL builtins. <I>A</I><SUB><I>i</I></SUB> are conjuncted and\n<I>C</I><SUB><I>j</I></SUB> are conjuncted. As CLP allows only single atom in head, a SWRL\nrule like the one above is translated to <I>m</I> CLP rules each of the\nform <CODE>Ci :- A1, A2, ... , An.</CODE>\n</P><P>CLP(<FONT COLOR=red> <I>R</I></FONT>) provides strong support for the concrete domain such\nas real numbers. We also define SWRL builtins such as comparison,\nmathematical operations, boolean operations and list operations. For\nexample the integer division builtin in SWRL is defined in the\nfollowing rule where <CODE>X1</CODE> is the integer result of\ndividing <CODE>X2</CODE> by <CODE>X3</CODE>.</P><PRE CLASS="verbatim"> integerDivide(X1, X2, X3) :- floor(R, X1), R = (X2 / X3).\n</PRE><!--CUT END -->\n</HTML>
!''Ontology Languages''\nData in the Semantic Web are represented by ontologies, which define concepts and relationships. Ontology languages provide vocabularies for expressing ontologies. Built on top of XML, Resource Description Framework (RDF) is a model of metadata defining a mechanism for describing\nresources in a simple triplet format. DARPA Agent Markup Language (DAML) is built on RDF Schema and based on description logics. DAML\npooled effort with the Ontology Inference Layer project to produce the ontology language DAML+OIL. It provides a richer set of language primitives to describe classes and properties than RDF Schema and allows only structured data. Based on DAML+OIL, Web Ontology Language (OWL) has been the W3C Recommendation for ontology language since 2004. It has three sub-languages: OWL Lite, DL and Full with increasing expressiveness. OWL Lite and DL are decidable while OWL Full is generally not. Recently, a rules extension to OWL DL has been proposed. The new language is called Semantic Web Rules Language (SWRL) and is syntactically and semantically coherent to OWL. The major extension of SWRL with respect to OWL includes Horn-style rules and (universally quantified) variable declaration. The rules are in the form of "''antecedent'' &rarr; ''consequent''" where both antecedent and consequent are conjunctions of atoms. Informally, a rule means that if the antecedent holds, the consequent must also hold. An example rule below states that if a user is in bathroom, the bathroom's door is closed, and the water heater is on, then the user is showering.\n\n\n!''Constraint Logic Programming''\nConstraint Logic Programming (CLP) began as a natural merger of two declarative paradigms: constraint solving and logic programming. This combination helps make CLP programs both expressive and flexible, and in some cases, more efficient than other kinds of programs. CLP has been successfully applied to model programs and transition systems for the purpose of verification, showing that their approach outperforms the well-know state-of-art systems with higher efficiency. The CLP scheme defines a class of languages based upon the paradigm of rule-based constraint programming, where CLP(R) is an instance of this class.
In this page, we demostrate how to write a CLP program from an ontology and how to reason about it. Currently, the auto-translation from ontology to CLP definition is in-progress. We are building a Protégé plugin, which will translate the ontology directly to CLP programs. After that, our reasoning engine will be invoked in the background to check the consistencies.\n\nSome test cases are available at [[here|TestCases.clpr]].\n\n*[[How to define the ontology in the CLP?]]\n*[[How to reason about the ontology and SWRL Rule?]]\n*[[How to check the consistencies of the Context Rules?]]\n\n!''Download''\nThe complete reasoning program and CLP(R) running library can be downloaded at [[here|Program.zip]].\nThe programs can run in both Unix and Windows platform.
Checking Ontology-based Pervasive Environment and Rules using CLP