rules and ontologies in f-logic

31
July 2005 Reasoning Web Summer School, Msida, Malta 1 Rules and Ontologies in F-logic Michael Kifer State University of New York at Stony Brook

Upload: addo

Post on 07-Jan-2016

51 views

Category:

Documents


1 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 1

Rules and Ontologies in F-logic

Michael Kifer

State University of New Yorkat Stony Brook

Page 2: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 2

Outline

• Introduction• Overview of F-logic (with examples using the

FLORA-2 system)

• F-logic/ FLORA-2 and ontologies

Page 3: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 3

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

Page 4: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 4

F-logic and Logic Programming

FO

F-l

og

ic

F-logic programmingP

red

icat

elo

gic

Logicprogramming

The flavors of F-logic:• First-order flavor• Logic programming flavor

Page 5: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 5

Relationship to Description Logic

Predicatelogic

Description F-LogicFO F-logic

Descriptio

n Logic

OW

L

- 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

Page 6: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 6

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

Page 7: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 7

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

Page 8: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 8

What is FLORA-2 ?

• FF-LLOgic tRARAnslator (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/

Page 9: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 9

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-RuleWSML-Rule

• SWSI (Semantic Web Services Initiative) – an international group that proposed an F-logic based language SWSL-Rules SWSL-Rules (also for Semantic Web (also for Semantic Web Services)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)

Page 10: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 10

F-logic: Simple Examples

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.’] ]

Single-valued attribute

Set-valued attribute

Object Id

Page 11: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 11

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

Page 12: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 12

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.

Page 13: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 13

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 andand X[color -> red].

Meta-query about schema: O[attributesOf(Class) ->>A] :-

O[A ->V oror A ->>V] and V:Class.

Rule that defines a method that returns attributes

whose range is class Class

Rule that defines a virtual class of red cars

Page 14: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 14

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

Page 15: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 15

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 … :-…, not P, …

means “true if cannot prove P” – 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]

Page 16: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 16

Semantics (cont’d)

• The Well-Founded semantics is 3-valued: p :- not q.

r :- not r.

p is true, q false, but r is undefined

• And non-monotonic: P |= Q does not imply PP’ |= Q

For instance:

p :- not q implies p true.

But q and p :- not q implies p false.

• So, truth values don’t grow monotonically. In contrast, classical logic is both 2-valued and monotonic

Page 17: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 17

Inheritance in F-logic

• Inheritance of structure vs. inheritance of behavior– Structural inheritance = inheritance of type signatures of a

method (will not discuss here)

– Behavioral inheritance = inheritance of the definition of a method

• Subtle problems arise when inference by inheritance interacts with inference by rules (illustrated next)

Page 18: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 18

Behavioral Inheritance: Non-monotonicity

Elephant[color *->grey]

fred

royalElephant[color *-> white]

clyde

Inherited:Inherited: fred[color -> grey]

clyde[color -> grey]

Overriding

white

?

Means default value

Page 19: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 19

Behavioral Inheritance: Problem with Rules

• Inheritance is hard to even define properly in the presence of rules.

a

b

[ m *-> v ]

c[m *-> w] :- b[m v]c

[ m v ]

inherited

defeated??

[ m *-> w ]

derived

Page 20: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 20

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

Page 21: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 21

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]

Page 22: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 22

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 HiLog in FLORA-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

Page 23: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 23

Reification (Another Application 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]

Page 24: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 24

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).

Page 25: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 25

Ontologies

• A typical ontology has three components:– A taxonomy (class hierarchy)

No-brainer in F-logic: Use : and ::

– Concept definitionsUse type signatures. For instance

person[name *=> string, children *=> person].

– Definitions of instancesThis 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]].

Page 26: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 26

Example of Ontology

Domain:Semantic Web Services

Scenario: Finding travel services according to various criteria (the Web service discovery problem)

Page 27: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 27

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 regionL:location :- L:R and R:region. // every member of a region is also a location

Page 28: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 28

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 ].

Page 29: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 29

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

].

Page 30: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 30

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.

Page 31: Rules and Ontologies in F-logic

July 2005 Reasoning Web Summer School, Msida, Malta 31

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