CSc 327, Spring 2002

schoolmistInternet and Web Development

Oct 22, 2013 (3 years and 10 months ago)

68 views


1

CSE 327, Spring 2009

Lecture
21



FOL Inference Algorithms, Ontologies,
and KR Languages

2/
2
7
/200
9




backward chaining

o

problems with backward chaining



ordering of subgoals makes a big difference in efficiency



note, Prolog does backward
-
chaining



consider (
or
derex.pl
)

o

father(F,C) :
-

male(F), child(C,F).



for query: father(X,lisa).

o

due to Prolog’s search strategy



it will try every male in the DB, and then check if
that male has a child lisa



show demo with trace on



lots of backtracking



better

o

father2(F,C) :
-

chil
d(C,F), male(F).

o

because presumably, lisa has fewer parents than there are
males

o

show trace



however, it is impossible to completely avoid backtracking

o

depending on order of child(lisa,marge) and
child(lisa,homer) either father(X,lisa) or mother(X,lisa) wil
l
have to backtrack at least once



Prolog isn’t 100% declarative

o

recommendation: put most restrictive terms first!



programs with infinite loops



backward chaining is depth
-
first search

o

incomplete

o

infinite paths can be created by circular sentences



i.e., sent
ences in which the predicate in the head
also appears in the body

o

e.g., reachable files



QUERY: reachable(pa,va).



reachable.pl



ERROR: Out of local stack



keeps recursing on first rule until out of
memory



reachable
-
alt
.pl
(skip

this
)



in trying to find what’s
reachable from MD,
it applies the first rule again and tries to find
if VA is reachable from PA before
backtracking


2



reachable
-
best
.pl



we swap the two rules from reachable.pl



able to find a solution quickly

o

analysis



backward
-
chaining is a
depth
-
first

searc
h algorithm



modest memory requirements



can be very fast

o

goal
-
directed reasoning



what about correctness?



the job of an inference procedure is to
derive

sentences



how do we know an inference procedure is correct?
(
alternatively,
what
bugs can it have?)



consi
der propositional

KB= {P, P


Q



R}

o

ask for an example of a buggy derivation



KB |= P? System Incorrectly Answers: No



KB |= S? System Incorrectly Answers: Yes



KB |= R? System Incorrectly Answers: Yes



sound

o

only derives (generates) entailed sentences



it an
swers no every time the sentence in question is
not entailed



e.g
., it doesn’t infer R or

P or

Q (even S
)



in FOL, if we substitute
each

binding returned in the
query, we
always
get an entailed sentence



i.e., it doesn’t give wrong answers



complete

o

derives
all sentences that are entailed



it answers yes every time the sentence is entailed



e.g., it can infer P, Q,

R, etc.



note, technically P

Q, P

R, etc are also
entailed



in FOL, all of the bindings that generate an entailed
sentence are returned



i.e., it does
n’t miss right answers



backward
-
chaining is



sound



incomplete for FOL

o

it can’t use many of the complex axioms that can be
expressed in FOL



only works with Horn logic



i.e., sentences of the form




x B
1



B
2




B
n



H



even incomplete for Horn logic

o

it may get

stuck in infinite loop


3

o

some FOL axioms can be converted to Horn logic



P
1



P
2




P
n



Q
1



Q
2



P
1



P
2




P
n



Q
1



P
1



P
2




P
n



Q
2



P
1


P
2



Q



P
1



Q



P
2



Q



no existential quantification or negation



no disjunction in consequent



Other inference algorit
hms

o

why does backward
-
chaining have its name?



most people find it more natural to start with facts and then apply rules to
see what follows from these facts



in this sense, backward
-
chaining is “backward” from the natural way of
doing things

o

forward chainin
g
(see Spring 2004, Lect. 16 for more material)



data
-
driven reasoning



start with the KB



not directed toward solving any particular problem but calculates
all possible conclusions



analysis



inefficient

o

may make a number of conclusions that are irrelevant to
the
goal



sound

o

since it just applies Modus Ponens, a sound inference rule



complete (for Horn clause KBs)

o

will not terminate until it has found all entailments

o

resolution



an inference procedure for the entire FOL language



as opposed to just Horn clauses lik
e backward and forward
chaining



details are beyond the scope of this class



sound and complete



semidecidable



if a sentence is not entailed, then algorithm may get stuck in a loop

o

note: not entailing


and entailing



is different!

o

it is often the case that

a KB entails neither


nor





the truth of


can’t be determined from the given
information



similar to the halting problem



Knowledge Representation

o

one way to create an intelligent agent



represent enough facts about the world in logic



use an inference pro
cedure to reason about the world


4

o

ontology



a collection of axioms that define the vocabulary of some subject matter
(domain)



typically define categories that divide up the kinds of things in the world

o

categories (aka classes)



sets of things that have simila
r properties



e..g, Person, Laptop, Computer, etc.



show slide ch10
-
know
-
rep.ppt #2



unary predicate representation (seen before)



Laptop(DellD600)





x Laptop(x)


Computer(x)



reifying categories (an alternative to unary predicates)



advance slide animation



ca
tegories have objects that are members

o

e.g., Member(DellD600, Laptop) [or DellD600


Laptop]



categories can be grouped under more general categories

o

e..g, Subset(Laptop, Computer) [or Laptop


Computer]



Subset(Computer, Electronics)

o

the Subset relation is
used to define a
taxonomy



a.k.a.
taxonomic hierarchy

o

semantics





x,y,z Subset(x,y)


Subset(y,z)


Subset(x,z)





x,y,z Member(x,y)


Subset(y,z)


Member(x,z)



the Member/Subset form is more expressive than unary predicates

o

you can ask queries about the str
ucture of the taxonomy



general issues regarding categories



all members of a category may have some properties in common

o

e.g., Member(x, Laptop)


Portable(x)

o

Member(x,Computer)


Component(x,CPU)



objects inherit properties from categories

o

all computers hav
e a component that is a CPU

o

a laptop is a computer

o

therefore any individual laptop has a CPU

o

upper ontology



a general framework of concepts that can reused across domains



can be extended by domain specific ontologies

o

example: Cyc



attempt to represent all
common sense using logic



started in mid 1980’s, with goal of having a system that could learn on its
own by 2000



haven’t gotten to that state yet, but their KB has been used in some
intelligent systems



Cycorp (founded in 1990) is still in business

o

must be
doing something right!


5



OpenCyc (
www.opencyc.org
)



free to download



hundreds of thousands of terms



millions of assertions



Cyc Upper Ontology



show ch10
-
know
-
rep.ppt slide #
3



problems



very complex, unintuitive



difficult
even for many AI Ph.D.’s to understand

o

limitations of knowledge representation



can most things be represented in logic?



yes, there are theories of action, space, time, mental events, etc.



however, these are not necessarily easy for humans to create or
unde
rstand



first
-
order logic inference is slow



FOL can’t handle exceptions easily



all birds fly, except for penguins, emus, etc.



alternative knowledge representation languages

o

semantic networks



show slide ch10
-
know
-
rep.ppt #4



a kind of logic that uses a graphi
cal notation



graph with labeled nodes and arcs



influenced by early (and incorrect) thinking on how the brain worked



theory that every neuron represented a “concept”



similar to UML (and more generally data models)



but introduced much earlier (early 1960’s)



example




representation



nodes

o

individual objects

o

categories



arcs

o

relations among objects



inheritance



two special arcs

o

SubsetOf (aka “isa”, “subClassOf”)



same as Subset predicate for pairs of categories

Granny

Tweety

cage12

owner

livesIn


6

o

MemberOf (aka “instanceOf
”, “type”)



same as Member predicate



the properties of a category can be inherited by their members

o

single box these properties



since categories don’t have them, their members do

o

simple algorithm



to find the inherited properties of an object, just
follow th
e isa relation



example

o

show ch10
-
know
-
rep.ppt slide #
5


o

inference



from Birds
canFly

True

and Tweety MemberOf
Bird



infer Tweety canFlyTrue



exceptions

o

show ch10
-
know
-
rep.ppt slide #
6

o

However, some birds can’t fly



for example, Peng
uins

o

values of class’s relations are
defaults



more specific values override the default

o

example


Bird

Penguin

canFly

True

SubsetOf

Opus

MemberOf

canFly

False

Bird

Tweety

canFly

True

MemberOf


7



Opus MemberOf Bird => Opus canFly True



Opus MemberOf Penguin => Opus canFly False

o

nonmonotonic



new information can cause you to ch
ange your
conclusions



complex concepts



sometimes you might want to represent a relationship that involves
multiple entities



e.g., the fact that someone flew from one location to another at a
specific time

o

this can be modeled as an event

o

show slide ch10
-
kno
w
-
rep.ppt, #
7

o

create a class of the specific type of event

o

this has an instance, which is an arbitrarily named
individual (thus the “Fly
17
”)

o

relate this by different properties to its various components



compared to FOL



easier to communicate to other people



generally less expressive

o

e.g., cannot represent negation, disjunction, or existential
quantification

o

limited universal quantification



first
-
order logic does not support exceptions cleanly

o

otherwise FOL is more powerful



faster inference algorithms

o

inherit
ance is simple to implement

o

Description logic (DL)



DLs allow you to more precisely define categories than semantic nets do



recall how difficult it is to discuss exact numbers in FOL?



e.g., to say “String quartet consists of exactly four musicians”



examples



show slide ch10
-
know
-
rep.ppt, #
8



a father is a male parent

o

Father


And(Male,Parent)



a parent has at least one child

o

Parent


AtLeast(1, hasChild)

o

hasChild is a “role” (like a relation in a semantic net)



a trio is a band with three members

o

Trio


And(Band
, All(members, Musician), Exactly(3,
members))

o

note Exactly(x, y) is shorthand for AtLeast(x,y) and
AtMost(x,y)


8



inference tasks



show slide ch10
-
k
now
-
rep.ppt, #
9



classification

o

does an object belong to a category?

o

example



bob

Male, bob

Parent



bob

Father?



subsumption

o

is one category a subset of another?

o

given



a herbivore is an animal that only eats plants



Herbivore


And(Animal, All(eats, Plant))



“eats” is a role, “Plant” a concept



a giraffe is an animal that only eats leafs



Giraffe


And(Animal, All(eats,

Leaves))



leaves are plants



Leaves


Plant



technically, a leaf is a part of a plant, but
assume this to simplify the example



e.g., Giraffe


Herbivore?



yes!



analysis



often easier to write class descriptions in DL than in FOL



however, there are things you c
an say in FOL that you can’t say in
DL



DL reasoning is faster than resolution



Assignments

o

none


9

Backup



knowledge representation

o

Application: Semantic Web



consider doing some demos of Protégé, Hawkeye, and/or a Semantic Web
browser



show W3C Semantic Web pag
e



http://www.w3.org/2001/sw/



term coined by Tim Berners
-
Lee, inventor of the Web



The Semantic Web is not a separate Web but an extension of the
current one, in which information is given well
-
defined meaning,
better enabling computers and people to work in

cooperation.
(SciAm 2001)



OWL, the Web Ontology Language



W3C Recommendation since Feb. 10, 2004



W3C is Web standards body (HTML, XML, etc.)



recommendation is highest level of endorsement

o

commercial products are already being developed



by HP, IBM, Oracle,
others



OWL is essentially a description logic with an XML syntax

o

show some examples from the OWL Guide wine ontology

o

http://www.w3.org/TR/2004/REC
-
owl
-
guide
-
20040210/wine.rdf



ontology
(as used in Semantic Web)

o

a shared document that defines the terms used
in other web
pages



over 2 million Semantic Web documents are on the Web



many researchers believe this will take the Web to the next level



more accurate and complete search



intelligent agents that can

o

help plan your travel

o

on PDAs notify you of interesting
landmarks nearby

o

help you find the best online prices

o

simplify e
-
commerce



enable diverse household devices to communicate and coordinate

o

e.g. when you answer the phone, your stereo volume is
lowered



for more info, see



links from my homepage


10


Deep Backup

(for possible use in a future year)



semantic networks



multiple inheritance
(skip?)



can be the subset of more than one category

o

possible to find conflicting values through inheritance

o

this is why multiple inheritance is prohibited in some OO
programming lan
guages, like Java



Werewolf

o

Wolf hasLegs = 4

o

Person hasLegs = 2

o

Werewolf isa Wolf

o

Werewolf isa Person

o

how many legs does a Werewolf have?