5

predicates nondeterm isa(symbol,symbol) nondeterm hasprop(symbol,symbol,symbol)

  • Upload
    tabib

  • View
    76

  • Download
    9

Embed Size (px)

DESCRIPTION

predicates nondeterm isa(symbol,symbol) nondeterm hasprop(symbol,symbol,symbol). nondeterm hasproperty(symbol,symbol,symbol). clauses isa(canary,bird). isa(robin,bird). isa(ostrich,bird). isa(bird,animal). isa(opus,penguin). isa(penguin,bird). isa(fish,animal). isa(tweety,canary). - PowerPoint PPT Presentation

Citation preview

Page 1: predicates nondeterm isa(symbol,symbol) nondeterm hasprop(symbol,symbol,symbol)
Page 2: predicates nondeterm isa(symbol,symbol) nondeterm hasprop(symbol,symbol,symbol)

predicatesnondeterm isa(symbol,symbol)nondeterm hasprop(symbol,symbol,symbol).nondeterm hasproperty(symbol,symbol,symbol).

clausesisa(canary,bird).isa(robin,bird).isa(ostrich,bird).isa(bird,animal).isa(opus,penguin).isa(penguin,bird).isa(fish,animal).isa(tweety,canary).

hasprop(tweety,color,white).hasprop(robin,color,red).hasprop(canary,color,yellow).hasprop(penguin,color,brown).hasprop(bird,travel,fly).

hasprop(fish,travel,swim).hasprop(ostrich,travel,walk).hasprop(penguin,travel,walk).hasprop(robin,sound,sing).hasprop(canary,sound,sing).hasprop(bird,cover,feather).hasprop(animal,cover,skin).

hasproperty(Obj,Pr,Val):-hasprop(Obj,Pr,Val).hasproperty(Obj,Pr,Val):-isa(Obj,Parent),hasproperty(Parent,Pr,Val).goalhasproperty(Obj,Pr,fly).

Implementing inference using inheretance

Page 3: predicates nondeterm isa(symbol,symbol) nondeterm hasprop(symbol,symbol,symbol)

Name:bird

Isa: animal

Prop:flies,feather

Default:

Name:animal

Isa: animate

Prop:eats,skin

Default:

Name:canary

Isa: bird

Prop:

color(yellow),sound(sing)

Default:size(small)

Name:tweety

Isa: canary

Prop:

color(yellow),sound(sing)

Default:color(white)

Frames from a knowledge base of birds

Page 4: predicates nondeterm isa(symbol,symbol) nondeterm hasprop(symbol,symbol,symbol)

domainsobj=symbolprop=travel(symbol);color(symbol);call(symbol);size(symbol);cover(symbol);action(symbol)listp=prop*name=name(obj)isa=isa(obj)predicatesnondeterm frame(name,isa,listp,listp)nondeterm get(prop,obj)nondeterm member(prop,listp)nondeterm memberf(prop,listp)nondeterm uget(obj,listp)nondeterm equal(prop,prop)print(listp)clausesframe(name(bird),isa(animal),[travel(flies),cover(feathers)],[]).frame(name(penguin),isa(bird),[color(brown)],[travel(walks)]).frame(name(canary),isa(bird),[color(yellow),call(sing)],[size(small)]).frame(name(tweety),isa(canary),[],[color(white)]).equal(travel(_),travel(_)). equal(color(_),color(_)). equal(call(_),call(_)). equal(size(_),size(_)). equal(cover(_),cover(_)). equal(action(_),action(_)).

Page 5: predicates nondeterm isa(symbol,symbol) nondeterm hasprop(symbol,symbol,symbol)

memberf(P,[H|_]):-equal(P,H).memberf(Pro,[_|T]):-memberf(Pro,T).

member(P,[H|_]):-P=H.member(Pro,[_|T]):-member(Pro,T).

get(Pro,Obj):-frame(name(Obj),_,LP,_),member(Pro,LP).get(Pro,Obj):-frame(name(Obj),_,_,LD),member(Pro,LD).

get(Pro,Obj):-frame(name(Obj),isa(Parent),_,_),get(Pro,Parent).

uget(Obj,L):-get(H,Obj),NOT(memberf(H,L)),uget(Obj,[H|L]).uget(Obj,L):-write(Obj),write(":"),print(L).

print([]).print([H|T]):-write(H),print(T).goaluget(tweety,[]).

tweety:cover("feathers")travel("flies")size("small")call("sing")color("white")yes