330 likes | 516 Views
Rules and Ontologies in F-logic. Michael Kifer State University of New York at Stony Brook. Outline. Introduction Overview of F-logic (with examples using the FLORA-2 system ) F-logic / FLORA-2 and ontologies. What is F-Logic?. An object-oriented first-order logic
E N D
Rules and Ontologies in F-logic Michael Kifer State University of New York at Stony Brook Reasoning Web Summer School, Msida, Malta
Outline • Introduction • Overview of F-logic (with examples using the FLORA-2 system) • F-logic/ FLORA-2 and ontologies Reasoning Web Summer School, Msida, Malta
What is F-Logic? • An object-oriented first-order logic • Extends predicate logic with • Objects with complex internal structure • Class hierarchies and inheritance • Typing • Encapsulation • A basis for object-oriented logic programming and knowledge representation • Background: • Basic theory: [Kifer & Lausen SIGMOD-89], [Kifer,Lausen,Wu JACM-95] • Path expression syntax: [Frohn, Lausen, Uphoff VLDB-84] • Semantics for non-monotonic inheritance: [Yang & Kifer, ODBASE 2002] • Meta-programming + other extensions: [Yang & Kifer, Journal on Data Semantics 2003] O-O programming Relational programming = F-logic Predicate calculus Reasoning Web Summer School, Msida, Malta
F-logic and Logic Programming • The flavors of F-logic: • First-order flavor • Logic programming flavor F-logic programming Logic programming FO F-logic Predicate logic Reasoning Web Summer School, Msida, Malta
Relationship to Description Logic FO F-logic Description F-Logic Description Logic OWL Predicate logic - A description logic subset exists within the first-order variant of F-logic [Balaban 1995, The F-logic Approach for Description Languages] - But most known uses of F-logic are in the rule-based (F-logic programming) domain Reasoning Web Summer School, Msida, Malta
Relationship to Description Logic (cont’d) • F-logic (rule-based flavor) • Computationally complete • Object-oriented • Classes as object, reification of statements • Can query data and schema in the same language • Has useful tractable subsets (eg, function-free rules) • Based on non-monotonic (non-classical) logic • Description logic • Has its own decidable subsets (but practically questionable, since expressive versions are exponential) • Can reason by cases • Can represent existential information • Based on monotonic, classical logic Reasoning Web Summer School, Msida, Malta
Applications of F-logic • Semantic Web: • Ontology management • Semantic Web Services • Information integration • Software engineering • Intelligent agents • Anything that requires manipulation of complex structured or (especially) semi-structured data Reasoning Web Summer School, Msida, Malta
What is FLORA-2 ? • F-LOgic tRAnslator (to XSB) – a popular implementation of F-logic (and more) • Realizes the vision of logic-based KR with frames, meta-programming, and side-effects. Based on • F-logic • HiLog • Transaction Logic • Practical & usable KR and programming environment • Declarative • Object-oriented • Rule-based • Open source: http://flora.sourceforge.net/ Reasoning Web Summer School, Msida, Malta
Other Major F-logic Based Languages • Ontobroker – commercial system from Ontoprise.de • WSMO (Web Service Modeling Ontology) – a large EU project that developed an F-logic based language for Semantic Web Services, WSML-Rule • SWSI (Semantic Web Services Initiative) – an international group that proposed an F-logic based language SWSL-Rules (also for Semantic Web Services) • FORUM – a user group whose aim is to standardize/web-ize the various flavors of F-logic (FLORA-2, Ontobroker, WSML-Rule, SWSL-Rules) Reasoning Web Summer School, Msida, Malta
F-logic: Simple Examples Object Id Single-valued attribute Object description: john[name -> ‘John Doe’, phones ->> {6313214567, 6313214566}, children ->> {bob, mary}] mary[name->’Mary Doe’, phones ->> {2121234567, 2121237645}, children ->> {anne, alice}] Structure can be nested: sally[spouse->john[address-> ‘123 Main St.’] ] Set-valued attribute Reasoning Web Summer School, Msida, Malta
Examples (cont’d) ISA hierarchy: john : person // class membership mary : person alice : student student:: person // subclass relationship student: entityType person : entityType Class & instance in different contexts Reasoning Web Summer School, Msida, Malta
Examples (cont’d) • Methods: like attributes, but take arguments • P[ageAsOf(Year) -> Age] :- • P:person, P[born-> B] and Age is Year–B. • Attributes can be viewed as methods with no arguments Queries: ?–john[ageAsOf(Y) -> 30, children->> C] and C[born-> B] and B>Y. John’s children who were born when he was 30+ years old. Reasoning Web Summer School, Msida, Malta
Examples (contd.) Browsing IsA hierarchy: ?-john : X. // all superclasses of the object john ?- student ::Y. // all superclasses of class student Virtual class: X : redcar :-X:car and X[color -> red]. Meta-query about schema: O[attributesOf(Class) ->>A] :- O[A->V orA->>V] and V:Class. Rule that defines a virtual class of red cars Rule that defines a method that returns attributes whose range is class Class Reasoning Web Summer School, Msida, Malta
Type Signatures • Type info is specified using statements like this (called signatures): person[name *=> string, spouse *=> person, children *=>> person]. • *=> means inheritable instance attribute (like instance variable in Java) • Signatures are formulas in F-logic (just like the data-level statement john[name ->’John Doe’] is a formula) • The notion of well-typedness relates signatures to data Reasoning Web Summer School, Msida, Malta
Semantics • The FO F-logic semantics & proof theory are general, as in classical logic; sound & complete, and are not limited to rules • But FLORA-2 is a programming language based on F-logic. Hence it uses nonmonotonic, non-classical semantics. So … :-…, notP, … means “true if cannot proveP”– so called “negation as failure.” The exact semantics for negation used in FLORA-2 is derived from the Well-Founded Semantics [Van Gelder et al., JACM 1991, http://citeseer.nj.nec.com/gelder91wellfounded.html] Reasoning Web Summer School, Msida, Malta
Semantics (cont’d) • The Well-Founded semantics is 3-valued: p:-notq. r:- notr. pis true, qfalse, but r is undefined • And non-monotonic: P |= Q does not imply PP’ |= Q For instance: p:-notq implies ptrue. But q and p:-notq implies pfalse. • So, truth values don’t grow monotonically. In contrast, classical logic is both 2-valued and monotonic Reasoning Web Summer School, Msida, Malta
Inheritance in F-logic • Inheritance of structure vs. inheritance of behavior • Structuralinheritance = inheritance of type signatures of a method (will not discuss here) • Behavioralinheritance = inheritance of the definition of a method • Subtle problems arise when inference by inheritance interacts with inference by rules (illustrated next) Reasoning Web Summer School, Msida, Malta
Behavioral Inheritance: Non-monotonicity Elephant[color *->grey] Means default value royalElephant[color *->white] fred clyde Overriding Inherited: fred[color ->grey] clyde[color ->grey] white ? Reasoning Web Summer School, Msida, Malta
inherited derived [ m*-> w ] defeated?? [ m-> v ] Behavioral Inheritance: Problem with Rules • Inheritance is hard to even define properly in the presence of rules. a [ m*-> v ] c[m*-> w]:- b[m-> v] c b Reasoning Web Summer School, Msida, Malta
Behavioural Inheritance: Solutions • Hard to define semantics for multiple inheritance + overriding + rules • Several semantics might appear to look “reasonable” • The original semantics in [Kifer,Lausen,Wu: JACM-95] was one of the problematic “reasonable” semantics • A number of other problematic semantics of various degrees of “reasonableness” were proposed over time • Problem solved in [Yang&Kifer: ODBASE 2002, 2003] • Based on semantic postulates • An extension of Van Gelder’s Well-Founded Semantics for negation Reasoning Web Summer School, Msida, Malta
HiLog • Allows certain forms of logically clean, yet tractable, meta-programming • Syntactically appears to be higher-order, but semantically is first-order and tractable • [Chen,Kifer,Warren, HiLog: A Foundation for Higher-Order Logic Programming, J. of Logic Programming, 1993] Reasoning Web Summer School, Msida, Malta
Examples of HiLog Variables over predicates and function symbols: p(X,Y):-X(a,Z), Y(Z(b)). Variables over atomic formulas (reification): p(q(a)). r(X) :- p(X) and X. A use of HiLoginFLORA-2 (e.g.,querying of schema): O[unaryMethods(Class)->>M] :- O[M(Arg) -> V or M(Arg) ->> V] and V:Class. Meta-variable: ranges over method names Reasoning Web Summer School, Msida, Malta
Reification (AnotherApplication of HiLog to F-logic) • Reification: making an object out of a formula: • john[believes->> ${mary[likes ->> bob]} ] • Introduced in [Yang & Kifer, ODBASE 2002] • Rules can be reified, too! Object made out of the formula mary[likes->> bob] Reasoning Web Summer School, Msida, Malta
HiLog in FLORA-2 • Allows high degree of meta-programming purely in logic • Variables can be bound to predicate and function symbols and thus queried • Formulas can be represented as terms and manipulated in flexible ways • Can mix frame syntax (F-logic) and predicate syntax (HiLog) in the same query/program: a[b -> c, g(X,e) ->> d] and p(f(X),a). Reasoning Web Summer School, Msida, Malta
Ontologies • A typical ontology has three components: • A taxonomy (class hierarchy) No-brainer in F-logic: Use : and :: • Concept definitions Use type signatures. For instance person[name *=> string, children *=> person]. • Definitions of instances This is just specification of data that populates ontologies. Specified using rules and facts. For instance: john:student. john[name -> ’John Doe’, address -> ’1 Main St.’]. X:grandfather :- X:person[children -> C[children -> GC]]. Reasoning Web Summer School, Msida, Malta
Example of Ontology Domain: Semantic Web Services Scenario: Finding travel services according to various criteria (the Web service discovery problem) Reasoning Web Summer School, Msida, Malta
Taxonomy • germany, europe, etc. – classes of cities • newyork, vienna, etc. – cities germany :: europe. austria :: europe. usa : region. europe : region. newyork : usa. vienna : austria. bonn : germany. frankfurt : germany. R:region :- R1:region and R::R1. // every subclass of a region is a region L:location :- L:R and R:region. // every member of a region is also a location Reasoning Web Summer School, Msida, Malta
User Goals and Related Concepts • Concepts: goal[requestId *=> request, request *=> travelSearchQuery, result *=>> service]. search(From,To,Date) : travelSearchQuery :- From : (region or location) and To : (region or location). • Instance: g123[ requestId -> 12345, request -> search (bonn,vienna,’7/7/2005’), result ->> serv123 ]. Reasoning Web Summer School, Msida, Malta
Service Concept & Instance • Concept: service[name *=> string, effect(travelSearchQuery) *=> formula, mediators *=>> mediator ]. • Instance: serv123[ name -> ’Fly High Travel’, effects(Input) -> ${ (itinerary(Req)[from ->From, to ->To, date ->Date] :- Input = search(From:germany, To:austria, Date)) }, usedMediators -> med1 ]. Reasoning Web Summer School, Msida, Malta
Having Fun with F-logic • Working with F-logic is fun! FLORA-2 is a full-fledged knowledge representation/logic programming system. Has a range of other interesting features: • Module system with encapsulation • Control flow constructs • Aggregates • Non-logical constructs for procedural diehards • Debugging support • Integration with databases, Web, Java, etc. Reasoning Web Summer School, Msida, Malta
Conclusion • F-logic is an object-oriented extension of predicate logic, which is particularly suitable for representing ontologies on the Semantic Web • Based on the proven paradigm of rule-based logic languages • Has a number of popular implementations, including commercial ones • A basis for two W3C proposals in the semantic Web services domain • Also proposed to W3C as the basis rule-based languages for the Semantic Web • WRL • SWSL-Rules • In fact, the N3 language is also nothing but a slightly altered syntax of F-logic, but with no semantics Reasoning Web Summer School, Msida, Malta