// simple services ontology serviceProfile[name => string, hasCategory => category, hasPrecondition => condition, hasPostcondition => condition]. goal[hasProfile => serviceProfile]. service[hasProfile => serviceProfile]. // description of conditions is very simple: just a name condition[name => string]. category[name => string]. //service categories sellingService:category. bookSellingService::sellingService. amazonBookSellingService::bookSellingService. computerSellingService::sellingService. //preconditions // address for delivery is supplied deliveryInfo:condition. //bank account information is supplied bankInfo:condition. //credit card information is supplied ccInfo:condition. bankAndDeliveryInfo::deliveryInfo. bankAndDeliveryInfo::bankInfo. ccAndDeliveryInfo::deliveryInfo. ccAndDeliveryInfo::ccInfo. //effects //article is delivered delivered:condition. //bank account has been charged bankCharged:condition. //credit card has been charged ccCharged:condition. bankChargedAndDelivered::delivered. bankChargedAndDelivered::bankCharged. ccChargedAndDelivered::delivered. ccChargedAndDelivered::ccCharged. //two example service profiles myBookSeller:serviceProfile[name -> "book seller", hasCategory -> amazonBookSellingService, hasPrecondition -> ccAndDeliveryInfo, hasEffect -> ccChargedAndDelivered]. myBookSeller2:serviceProfile[name -> "book seller", hasCategory -> bookSellingService, hasPrecondition -> bankAndDeliveryInfo, hasEffect -> bankChargedAndDelivered]. //example service and example goal myService:service[hasProfile -> myBookSeller]. myGoal:goal[hasProfile -> myBookSeller2]. // simple matching mechanism based on categories. There is a match if the category of // the service is a subclass of or the same as the category of the goal match(?x,?y) :- ?x:goal[hasProfile -> ?p1[hasCategory -> ?c1]], ?y:service[hasProfile -> ?p2[hasCategory -> ?c2]], ?c2::?c1. match(?x,?y) :- ?x:goal[hasProfile -> ?p1[hasCategory -> ?c1]], ?y:service[hasProfile -> ?p2[hasCategory -> ?c2]], ?c2=?c1. // query all matching goals/services with: // ?- match(?x,?y). // query all services matching my goal: // ?- match(myGoal,?y). // query whether a particular service matches my goal // ?- match(myGoal,myService).