1 / 7

pred1(X,Z):-parent(X,Z). pred1(X,Z):-parent(X,Y), pred1( Y, Z).

pred 1 (tom, pat). by rule. pr1. by rule. pr2. parent(tom, Y). parent(tom, pat). pred 1 (Y, pat). no. Y = bob. parent(tom, bob). by fact. pred 1 (bob, pat). by rule. pr1. parent(bob, pat). yes. parent(pam, bob). parent(tom, bob). parent(tom, liz). parent(bob, ann).

barbie
Download Presentation

pred1(X,Z):-parent(X,Z). pred1(X,Z):-parent(X,Y), pred1( Y, Z).

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. pred1(tom, pat) by rule pr1 by rule pr2 parent(tom, Y) parent(tom, pat) pred1(Y, pat) no Y = bob parent(tom, bob) by fact pred1(bob, pat) by rule pr1 parent(bob, pat) yes • parent(pam, bob). • parent(tom, bob). • parent(tom, liz). • parent(bob, ann). • parent(bob, pat). • parent(pat,jim). pred1(X,Z):-parent(X,Z). pred1(X,Z):-parent(X,Y), pred1( Y, Z).

  2. parent(pam, bob). • parent(tom, bob). • parent(tom, liz). • parent(bob, ann). • parent(bob, pat). • parent(pat,jim). pr1 tom ile başlayan 2 parent ilişkisi (bob ve liz) bulunduğundan ikisini de dene bob ile başlayan 2 parent ilişkisi (ann ve pat) bulunduğundan ikisini de dene pr2 pr1 pr1 pr1 pr1 pr2 parent(ann,Y’’) pred2(Y’’,pat) pr2 pr1 parent(pat,Y’’’) pred2(Y’’’,pat) ann ile başlayan parent ilişkisi bulamadığından No pr1 pr2 jim ile başlayan parent ilişkisi bulamadığından No

  3. parent(pam, bob). • parent(tom, bob). • parent(tom, liz). • parent(bob, ann). • parent(bob, pat). • parent(pat,jim). pred3(tom,Y’) parent(Y’,pat) pred3(X, Z) :- parent(X, Z). pred3(X, Z) :- pred3( X, Y), parent(Y, Z).

  4. parent(pam, bob). • parent(tom, bob). • parent(tom, liz). • parent(bob, ann). • parent(bob, pat). • parent(pat,jim).

  5. Backtracking Control • Backtracking’i kontrol etmek için iki operatör: CUT -!, argüman almaz, her zaman true, backtracking’i durdurur. FAIL – her zaman false, backtracking’e devam ettirir. loop :- goal, fail. loop. Loop çağrıldığında goal her seferinde farklı değerler için tekrarlı olarak tüm olası alternatifler bitene kadar çalıştırılır, En sonunda Loop true olarak tamamlanır.

  6. Cut p :- a,b. p :- c,d. (a  b)  (c  d) p :- a, !, b. p :- c,d. (a  b)  (not(a)  c  d) p :- a, b, !. p :- c,d. (a  b)  ((not(a) not(b)) c  d) p :- !,a, b. p :- c,d. ? (a  b)

  7. fail • father(leonard,katherine). father(carl,jason). father(carl,marilyn). everybody:- father(X,Y), write(X),nl, fail. everybody. • fail bir sonuç bulunsa bile arama işlemine devam edilmesini sağlar.

More Related