PPT - Summer School Reasoning Web 2005

advertisement
Rules and Ontologies in F-logic
Michael Kifer
State University of New York
at Stony Brook
July 2005
Reasoning Web Summer School, Msida, Malta
1
Outline
•
•
•
Introduction
Overview of F-logic (with examples using the
FLORA-2 system)
F-logic/ FLORA-2 and ontologies
July 2005
Reasoning Web Summer School, Msida, Malta
2
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
O-O programming
F-logic
Relational programming
=
Predicate calculus
• 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]
July 2005
Reasoning Web Summer School, Msida, Malta
3
F-logic and Logic Programming
The flavors of F-logic:
• First-order flavor
• Logic programming flavor
July 2005
Predicate
logic
FO F-logic
F-logic programming
Logic
programming
Reasoning Web Summer School, Msida, Malta
4
Relationship to Description Logic
Description F-Logic
FO F-logic
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
July 2005
Reasoning Web Summer School, Msida, Malta
5
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
July 2005
Reasoning Web Summer School, Msida, Malta
6
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
July 2005
Reasoning Web Summer School, Msida, Malta
7
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/
July 2005
Reasoning Web Summer School, Msida, Malta
8
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)
July 2005
Reasoning Web Summer School, Msida, Malta
9
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:
Set-valued attribute
sally[spouse -> john[address -> ‘123 Main St.’] ]
July 2005
Reasoning Web Summer School, Msida, Malta
10
Examples (cont’d)
ISA hierarchy:
john : person
mary : person
alice : student
// class membership
student :: person
// subclass relationship
Class & instance in
different contexts
student : entityType
person : entityType
July 2005
Reasoning Web Summer School, Msida, Malta
11
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.
July 2005
Reasoning Web Summer School, Msida, Malta
12
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 or A ->>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
July 2005
Reasoning Web Summer School, Msida, Malta
13
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
July 2005
Reasoning Web Summer School, Msida, Malta
14
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]
July 2005
Reasoning Web Summer School, Msida, Malta
15
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 PP’ |= 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
July 2005
Reasoning Web Summer School, Msida, Malta
16
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)
July 2005
Reasoning Web Summer School, Msida, Malta
17
Behavioral Inheritance:
Non-monotonicity
Elephant[color *-> grey]
royalElephant[color *-> white]
Means default value
fred
clyde
Inherited:
fred[color -> grey]
clyde[color -> grey]
July 2005
Overriding
white
?
Reasoning Web Summer School, Msida, Malta
18
Behavioral Inheritance:
Problem with Rules
• Inheritance is hard to even define properly in the
presence of rules.
inherited
a [ m *-> v ]
derived
c[m *-> w] :- b[m -> v]
c [ m *-> w ]
b [ m -> v ]
July 2005
defeated??
Reasoning Web Summer School, Msida, Malta
19
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
July 2005
Reasoning Web Summer School, Msida, Malta
20
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 HigherOrder Logic Programming, J. of Logic Programming,
1993]
July 2005
Reasoning Web Summer School, Msida, Malta
21
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
July 2005
Reasoning Web Summer School, Msida, Malta
22
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!
July 2005
Reasoning Web Summer School, Msida, Malta
Object made out of
the formula
mary[likes ->> bob]
23
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).
July 2005
Reasoning Web Summer School, Msida, Malta
24
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]].
July 2005
Reasoning Web Summer School, Msida, Malta
25
Example of Ontology
Domain:
Semantic Web Services
Scenario:
Finding travel services according to various
criteria (the Web service discovery problem)
July 2005
Reasoning Web Summer School, Msida, Malta
26
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
July 2005
Reasoning Web Summer School, Msida, Malta
27
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
].
July 2005
Reasoning Web Summer School, Msida, Malta
28
Service Concept & Instance
• Concept:
service[name
*=> string,
effect(travelSearchQuery) *=> formula,
mediators
*=>> mediator
].
• Instance:
serv123[ name
effects(Input)
->
->
’Fly High Travel’,
${
(itinerary(Req)[from ->From, to ->To, date ->Date] :Input = search(From:germany, To:austria, Date))
},
usedMediators
->
med1
].
July 2005
Reasoning Web Summer School, Msida, Malta
29
Having Fun with F-logic
• Working with F-logic is fun! FLORA-2 is a fullfledged 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.
July 2005
Reasoning Web Summer School, Msida, Malta
30
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
July 2005
Reasoning Web Summer School, Msida, Malta
31
Download