1 / 12

Prolog

Prolog. CSE 473 – Autumn 2003. Today. First-order logic resolution proofs Answer extraction Resolution strategies Prolog The 5 th Generation Project. FOL Resolution Proofs. People who love happy people are happy. Rich people are happy. People love their spouse.

mura
Download Presentation

Prolog

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prolog CSE 473 – Autumn 2003

  2. Today • First-order logic resolution proofs • Answer extraction • Resolution strategies • Prolog • The 5th Generation Project

  3. FOL Resolution Proofs • People who love happy people are happy. • Rich people are happy. • People love their spouse. • Mothers love their children. • Prove: Bill Gate’s mother-in-law is happy. happy(x), rich(x), loves(x,y)spouse(Melinda,Bill)mother(MIL,Melinda)mother(Mary,Bill)

  4. Answer Extraction • Who is happy? • Who loves Bill Gates? • Who loves who?

  5. Prolog Interpreter binding_list disprove(literal neglit){ choose (clause c) such that (binding = unify(head(c),neglit)) if (no choice possible){ backtrackto last choice;} for (each lit in body(c)){ binding = binding U disprove(substitute(lit,binding)); } return binding; }

  6. Properties of Prolog Interpreter • Tree-shaped proofs • Efficient use of memory (just stack) • Builds tree depth-first – may enter infinite loop even on finite domains! • Free implementation: SWI Prolog http://www.swi-prolog.org/

  7. happy.pl happy(X) :- rich(X). happy(X) :- loves(X,Y),happy(Y). loves(X,Y) :- spouse(X,Y). loves(X,Y) :- mother(X,Y). rich(bill). spouse(melinda,bill). mother(mil,melinda). mother(mary,bill). rich(paul). mother(barbara,henry).

  8. toohappy.pl happy(X) :- rich(X). happy(X) :- loves(X,Y),happy(Y). loves(X,Y) :- spouse(X,Y). loves(X,Y) :- mother(X,Y). rich(bill). spouse(melinda,bill). mother(mil,melinda). mother(mary,bill). rich(paul). mother(barbara,henry). loves(bill,melinda). loves(henry,barbara).

  9. hanoi.pl move(1,X,Y,_) :- write('Move top disk from '), write(X), write(' to '), write(Y), nl. move(N,X,Y,Z) :- N>1, M is N-1, move(M,X,Z,Y), move(1,X,Y,_), move(M,Z,Y,X).

  10. nlp.pl % Try: s([a,man,loves,a,woman],[]). s(S0,S) :- np(S0,S1), vp(S1,S). np(S0,S) :- det(S0,S1), n(S1,S). vp(S0,S) :- tv(S0,S1), np(S1,S). vp(S0,S) :- v(S0,S). det(S0,S) :- S0=[the|S]. det(S0,S) :- S0=[a|S]. det(S0,S) :- S0=[every|S]. n(S0,S) :- S0=[man|S]. n(S0,S) :- S0=[woman|S]. n(S0,S) :- S0=[park|S]. tv(S0,S) :- S0=[loves|S]. tv(S0,S) :- S0=[likes|S]. v(S0,S) :- S0=[walks|S].

  11. Japanese 5th Generation Project • 1982 – 1992: $400M effort by Japanese corporate/government partnership to leapfrog the world in creating an “epoch-making computer” • Approach: hardware for parallel Prolog • In the end, few results • General purpose hardware evolved more rapidly • Most significant software R&D in Europe

  12. Prolog Today • Natural language processing • Datalog – database query and integrity constraints • Function-free definite clauses + bottom-up resolution strategy • Expert systems – diagnosis, classification, … • http://www.amzi.com/AdventureInProlog/

More Related