On the Modeling of Context-Rules with WSML Reto Krummenacher and Holger Lausen and Thomas Strang 1 Abstract. Modeling context information based on formal descrip- Finally we conclude with Section 5 and provide a short outlook at tions is a core aspect of service integration and interoperability, in where and how the ideas of this paper will be further explored. particular in pervasive computing environments. In this paper we present an improved and simplified version of the Context Ontol- ogy Language modeled in WSML-Rule to show the potential use of 2 WSML-RULE LANGUAGE context rules in pervasive computing applications and in particular as The Web Service Modeling Language WSML [1] provides a frame- part of Semantic Web service descriptions. work for the modeling of ontologies and Semantic Web services based on the conceptual model of the Web Service Modeling On- 1 INTRODUCTION tology WSMO [5]. WSML defines two rule-based language variants that are of interest to the issues of this paper. The first rule-based The trend towards pervasive computing is driving a need for services variant, WSML-Flight, semantically corresponds to the Datalog frag- and service architectures that are aware of the context of the differ- ment of F-Logic, extended with inequality in the body and locally ent actors (users, service providers, or third parties and their envi- stratified negation under the perfect model semantics [6]. The sec- ronments) involved in a service interaction: vicinity, location, QoS, ond, WSML-Rule, extends WSML-Flight to the logic programming ownership, time. For instance, context information can be used to re- subset of F-Logic which allows the use of function symbols and un- duce the amount of required user or service-service interactions, as safe rules (i.e., there may be variables in the rule head which do not well as to improve the user experience. A key accessor to context in- occur in the body). formation in any context-aware system is a well designed model to A WSML rule has the common form of head :- body. We illustrate describe contextual facts and contextual interrelationships. The con- this with the following example which states that every woman (rule text modeling approach applied in this paper is derived from the Con- body) is a human being (rule head): text Ontology Language (CoOL, [7]). CoOL is based on the Aspect- ?x memberOf Human :− ?x memberOf Woman. Scale-Context (ASC) model also introduced in [7]. ASC defines a very simple context model in form of an extendable umbrella vo- Further technical details about the language are available in [1]. cabulary that is shown to increase interoperability on the contextual level. In this paper we improve and simplify the context modeling lan- 3 CoOL: CONTEXT ONTOLOGY LANGUAGE guage by evolving its definitions based on recent advances in the The context description language applied in this paper was described field of Web-rule languages. We look in particular at the application in [7] and is based on the Aspect-Scale-Context model introduced in of CoOL in combination with rule-based WSML variants [1]. This the same dissertation. On an generic level an aspect is a dimension allows us to update the well designed context model and to bind it of the situation space that is used as a collective term for informa- to a language family that is part of a large framework of Seman- tion objects having the same semantic type. A scale is then seen as tic Web languages. The WSML family of languages is a member an unordered set of objects defining the range of valid context infor- submission to the W3C, and although it does not have the status of mation instances. In other words, a valid context information with an official standards recommendation, we expect to be able to eas- respect to an aspect is one of the elements of the aspect’s scales. This ily map our results into the ongoing work of the Rule Interchange results in a number of aspects that aggregate one or more scales, Format working group [3], which will eventually endorse an official where each scale aggregates one or more pieces of context informa- standard. Furthermore the application of rule languages allows for tion. The three concepts that constitute the CoOL-core ontology are a simplified Context Ontology Language through the use of meta- interrelated by use of the attributes hasAspect, hasScale, hasMember modeling, where a concept itself can have attribute values just like and usedByScale (cf. Figure 1). any particular instance (cf. Section 4). Through the combination of meta-data instances, CoOL allows the The paper is organized as follows. In Section 2 a short introduc- provision of higher order context information or the binding of qual- tion to WSML is given. Section 3 provides more information about ity measures. In [7] meanError, timestamp and hasQuality were pro- the Aspect-Scale-Conext model and the derived Context Ontology posed for any context information instance. Language (CoOL). In Section 4 we show how CoOL can be modeled A particular strength of the presented context model not yet men- using WSML-Rule and how to define context-rules. We also look at tioned is the infrastructure defined to map semantically related scales possible application areas of context-rules, in particular in the area of one aspect or to combine and interlink different scales to new of Semantic Web services, where the WSML family resulted from. scales of hybrid aspects. There are two types of operations in CoOL: 1 Digital Enterprise Research Institute, University of Innsbruck, Austria, (1) IntraOperations that provide translations from one scale to an- email: firstname.lastname@deri.org other, e.g. from Kilometer to Miles of a DistanceAspect, and (2) all. For more complex value constraints it is always possible to bind an external operation to the model, as will be described later in this section. Listing 2. An example of CoOL-WSML for distance information instance DistanceAspect memberOf Aspect hasDefaultScale hasValue KilometerScale instance KilometerScale memberOf Scale hasAspect hasValue DistanceAspect Figure 1. The ASC ontology from [7] instance MilesScale memberOf Scale hasAspect hasValue DistanceAspect InterOperations that allow for example the definition of a Kilome- axiom defaultScaleKmCI definedBy terPerHourScale of the SpeedAspect as a combination of a Kilome- ?kci [ inScale hasValue KilometerScale , value ofType float ] terScale and an HourScale. :− ?kci memberOf KmCI . More details about the ASC model are provided in the next section axiom defaultScaleMiCI definedBy where we first of all discuss some simplifications and improvements. ?mci[inScale hasValue MilesScale , value ofType float ] :− ?mci memberOf MilesCI . 4 CONTEXT RULE MODELLING IN WSML For a better understanding we first elaborate on the example in Listing 2. There is one aspect, the DistanceAspect, defined in the do- In this section we present CoOL written in WSML-Rule2 (Listing main ontology that represents one possible context dimension: spa- 1). Note first of all a minor change in the model with respect to the tial distance. The default scale for distance measurements is defined original ontology (Figure 1): we feel that a context information is not to be the KilometerScale. A second possible scale would be the Mi- used by a scale, but rather that the context information is encoded lesScale. The aspects and scales are modeled as instances of the as given by a scale. Hence, we suggest to use the attribute inScale CoOL-core Aspect respectively Scale concepts, while the context in- instead. formation objects are implicitly defined as concepts (KmCI, respec- Listing 1. CoOL-core written in WSML-Flight. tively MilesCI) to provide containers for all collected instances, i.e. pieces of information. concept Aspect hasDefaultScale ofType (0 1) Scale As shown in Listing 3, it is possible to directly axiomatize simple hasScale ofType Scale intra operations within WSML, they can be modeled by rules, which axiom DefaultScaleSubScale definedBy transparently make values of context information available in differ- ?a[ hasScale hasValue ?s] ent scales (e.g. Miles and Kilometer). The axiom km2miOperation :− ?a[ hasDefaultScale hasValue ?s] memberOf Aspect. infers for example the context information in the MilesScale from concept Scale some in the KilometerScale. We use a function symbol to generate hasAspect inverseOf(hasScale ) ofType (1 *) Aspect hasMember ofType ContextInformation an identifier for inferred context information to distinguish between hasUnit ofType Unit inferred and measured information. The rule states that every mea- memberCheck ofType iri surement that is taken using the KilometerScale is equivalent to a hasIntraOperation iri hasInterOperation ofType iri value in the MilesScale divided by 1.609. hasDefaultMetric ofType (0 1) iri Listing 3. Axiomatic IntraOperations. concept ContextInformation characterizes impliesType (1) Entity inScale inverseOf(hasMember) ofType (1 *) Scale axiom km2miOperation definedBy meanError ofType ContextInformation km2mi(?info)[inScale hasValue MilesScale , value hasValue ?mi, timestamp ofType (1) ContextInformation characterizes hasValue ?entity ] memberOf MilesCI hasQuality ofType ContextInformation :− ?info [ inScale hasValue KilometerScale , value hasValue ?km, characterizes hasValue ?entity ] memberOf KmCI and wsml#numericDivide(?mi,?km,1.609) and naf ?info = mi2km(?i) . Based on the core concepts of CoOL it is now possible to define particular aspects, scales and pieces of context information. Listing In order to provide the same information for intra-scale operations 2 shows the necessary concepts and instances to gather information as in [7] we suggest to use non-functional properties to annotate about distances in either kilometer or miles. Using the WSML lan- the mapping axioms. The fromScale property indicates the source guage constructs like inverseOf keeps the definition of a domain on- scale, while toScale provides a link to the target scale. Most intra- tology for distance measurements short and simple without loosing operations demand a simple value transformation to cope with dif- e.g., the aspect-scale or scale-aspect bindings. The context informa- ferent units. Similar mappings exist for a TemperatureAspect where tion containers are explicitly given by the axioms that bind them to a Kelvin, ◦C and ◦F would have to be interlinked to make the infor- given distance scale (Listing 2). mation compatible even though it results from heterogeneous data CoOL has so-called memberCheck operations (Figure 1) that en- sources. sure correctly scaled values for context information (i.e. that they Before looking at the definition of context rules we shortly add obey the type of the scale). In WSML such constraints can in simple some distance measurements to our knowledge base. The distance cases directly be expressed within the conceptual syntax. In our ex- is either given by an explicit measured instance or by an inferred ample the values are constrained to the datatype float directly in the instance generated on-the-fly by an appropriate axiom: axiomatic definition of KmCI or MilesCI. The semantics of WSML axiom measurements definedBy ensures that if instances exist in a model that do not obey these con- # memberOf KmCI[value hasValue ?d, characterizes hasValue DistAB] and distKM(?d,A,B) . straints, such a model is inconsistent and in fact no valid model at # memberOf KmCI[value hasValue 14, characterizes hasValue DistAC] . # memberOf MilesCI[value hasValue 8.5, 2 The complete listings are at http://members.deri.org/∼retok/cool/ characterizes hasValue DistAD] . By now the reader should be familiar with the context modeling 5 CONCLUSION ontology and with the way context domains and context information are defined using WSML-Rule. Context-awareness, and as a crucial intermediate step the provision A context rule is an axiom that is defined by an implication where of concise context models, is a core research area of pervasive com- the body is a set of conditions using the context information in the puting. Encoding context information by use of ontologies allows for knowledge base. Rules either infer new knowledge or return infor- formal descriptions of characteristics and states of entities. The ASC mation if posted in form of queries. The following example queries model and the derived Context Ontology Language CoOL provide a distance entities that represent nearby locations. The resulting dis- simple and extensible model based on aspect-scale-context interrela- tance value shall be provided by an MilesCI instance of a scale that tions. belongs to the aspect DistanceAspect and shall be smaller than 10 In this paper we used the rule-based languages of the WSML lan- miles: guage family to improve and simplify the language bindings pro- ? − ? c[ characterizes hasValue ?entity , value hasValue ?distMiles , posed in [7]. The use of meta-modeling and the fact that WSML pro- hasScale hasValue ?s] memberOf MilesCI vides a set of languages that can be mapped to various types of logi- and ? s [hasAspect hasValue DistanceAspect] and ?distMiles < 10 . cal formalisms which are already well integrated into the rule efforts The query returns for the given measurements the following of the Semantic Web allows for an even more concise, yet simulta- matches3 : neously extensible and globally applicable, umbrella framework for ?entity ?distMiles the modeling of context information. DistA2C 8.7 This is exactly the convergence of technologies that is envisioned DistA2D 8.5 to be necessary to fully explore the use of context information in the field of service interoperability and information exchange on the In WSMO [5] the vocabularies, constraints and logical expressions context level. The generic character of the ASC model and the well- that are defined in ontologies are used to describe the functionality integratedness of WSML into the Semantic Web standardization ac- (capability) and interfaces of Web services. The just defined query tivities allows this combined approach to become a context-modeling could be used to include restrictions on the spatial distance between framework that could provide the backbone for large-scale context- the service provider and requester. It could for example be envisioned aware applications on the Web. The requested and provided context that a pizza delivery service only accepts orders from clients that call information of various heterogenous information sources, sinks and from at most ten miles from the pizza store. Hence, a precondition of services can hence be combined, processed and mapped on the ma- such a pizza ordering service would include a constraint that uses the chine level. In that sense, the ideas presented are expected to also context rule to ensure the desired maximal spatial distances. improve Semantic Web services frameworks like WSMX [2] or ser- This leads us to another interesting feature that the WSML frame- vice coordination infrastructures like Triple Spaces [4] by allowing work provides. WSMO and in consequence WSML were developed their components to become context-aware. The upcoming work is to annotate Web service descriptions. In [7] the various operations thus concerned with enhancing the functionality-centered static de- are offered by external services that are linked into the model by use scriptions of Web services to additionally consider dynamic charac- of operation bindings (Figure 1). We have already shown that many teristics like location, connectivity or quality to provide improved IntraOperations and member checks can be modeled by axiomatic discovery, selection and coordination of services — a requirement expressions, while for the more complex ones, as well as for InterOp- for the access and composition of services in ubiquitous computing erations and MetricOperations WSML provides us with the means of environments. Web service descriptions within the same framework and thus based on the same notations and vocabularies. ACKNOWLEDGEMENTS Listing 4. A Web service description to link InterOperations The work is funded by the European Commission under the projects webService ” http :// www.example.org/interOpService” DIP, Knowledge Web, SEKT, and ASG; by the Austrian Federal capability Ministry for Transport, Innovation, and Technology under the FIT- precondition definedBy IT projects RW2 and TSC. ?i1 memberOf KilometerScale and ?i2 memberOf HourScale . postcondition definedBy ?o memberOf KmPerHourScale . REFERENCES The shown service description (Listing 4) contains a capability de- [1] J. de Bruijn, H. Lausen, A. Polleres, and D. Fensel: The web service scription that uniquely indicates the constraints on the input and out- modeling language: An overview, Proc. 3rd European Semantic Web Conf., June 2006. put parameters of the service that computes the kilometer per hour [2] E. Cimpian, and M. Zaremba (eds.): Web Service Execution Environ- scale (Listing 5). The description of the grounding and interaction ment (WSMX), W3C Member Submission, June 2005. patterns with the Web service are assumed to be given in an external [3] S. Hawke (ed.): Rule Interchange Format Working Group Charter, W3C file, as this would exceed the scope of this paper. The goal is to recon- Semantic Web Activity, 2005. sider the strength of CoOL and to show the advantages of modeling [4] R. Krummenacher, M. Hepp, A. Polleres, Ch. Bussler, and Dieter Fensel: WWW or What is Wrong is with Web Services, Proc. 3rd Eu- it with WSML, in particular with WSML-Rule. ropean Conf. on Web Services, 2005. [5] H. Lausen, A. Polleres, and D. Roman (eds.): Web Service Modeling Listing 5. A scale definition with IntraOperation binding Ontology (WSMO), W3C Member Submission, June 2005. [6] T. C. Przymusinski. On the declarative and procedural semantics of instance KilometerPerHourScale memberOf Scale hasAspect hasValue SpeedScale logic programs. Journal of Automated Reasoning, 5(2), 1989. hasInterOperation hasValue ” http :// www.example.org/interOpService” [7] Th. Strang: Service interoperability in ubiquitous computing environ- ments. PhD dissertation, LMU Munich, 2003. 3 WSML-Rule reasoner: http://tools.deri.org/wsml/rule-reasoner