Yapay Zeka`ya giris

advertisement
Yapay Zeka’ya giris
Prolog
Uzay CETIN
Université Pierre Marie Curie (Paris VI),
Master 2 Recherche, Agents Intelligents, Apprentissage et Décision (AIAD)
November 18, 2008
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
1 / 17
Prolog
Icindekiler
1
Prolog
ornekler
CUT, FAIL, ASSERTA
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
2 / 17
Prolog
SWI prolog kurulduktan sonra Gerekler ve kurallar .pl uzantl bir dosyaya
kaydedilir.
GERCEKLER
q(Ali).
r(Ali).
KURALLAR
p(X):-q(X), r(X).
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
3 / 17
Prolog
Listeler
(*)
Liste yapisi :
[BAS|KUYRUK ]
...
...
(*) Bir dizinin eleman sayisini bulmak
...
size([ ],0).
(*)
size([H|T ], N):- size(T,N1),N is N1 + 1.
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
4 / 17
Prolog
ornekler
Icindekiler
1
Prolog
ornekler
CUT, FAIL, ASSERTA
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
5 / 17
Prolog
ornekler
Uyelik
member(H,[H| ]).
member(H,[ |Tail]
Uzay CETIN ()
,N):member(H,Tail).
Yapay Zeka’ya giris
November 18, 2008
6 / 17
Prolog
ornekler
Alt kume
subset([ ], ).
subset([H|Tail]
Uzay CETIN ()
,L):member(H,L),subset(Tail,L).
Yapay Zeka’ya giris
November 18, 2008
7 / 17
Prolog
CUT, FAIL, ASSERTA
Icindekiler
1
Prolog
ornekler
CUT, FAIL, ASSERTA
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
8 / 17
Prolog
CUT, FAIL, ASSERTA
CUT
(*)
p:- a,b.
p:- c,d.
(a ∧ b) ∨ (c ∧ d) ⇒ p
(*)
p:- a,!,b.
p:- c,d.
(a ∧ b) ∨ (NOT (a) ∧ c ∧ d) ⇒p
(*)
NOT(p):- p,!,FAIL.
NOT(p).
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
9 / 17
Prolog
CUT, FAIL, ASSERTA
MAX
(*)
max(X,Y,M):- X >= Y ,!,M is X.
max(X,Y,M):-M is Y.
ya da
(*)
max(X,Y,X):- X >= Y ,!.
max(X,Y,Y).
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
10 / 17
Prolog
CUT, FAIL, ASSERTA
ornek
(*) Ayse yilan haricindeki butun hayvanlari sever.
Bu cumleyi likes(Ayse,X), snake(X),animal(X) yuklemleri ile
yazin. (likes(Ayse,X):- animal(X). gibi)
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
11 / 17
Prolog
CUT, FAIL, ASSERTA
ornek
(*) Ayse yilan haricindeki butun hayvanlari sever.
Bu cumleyi likes(Ayse,X), snake(X),animal(X) yuklemleri ile
yazin. (likes(Ayse,X):- animal(X). gibi)
(*)
likes(Ayse,X):-snake(X),!,fail.
likes(Ayse,X):- animal(X).
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
11 / 17
Prolog
CUT, FAIL, ASSERTA
ornek
(*) Ayse yilan haricindeki butun hayvanlari sever.
Bu cumleyi likes(Ayse,X), snake(X),animal(X) yuklemleri ile
yazin. (likes(Ayse,X):- animal(X). gibi)
(*)
likes(Ayse,X):-snake(X),!,fail.
likes(Ayse,X):- animal(X).
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
11 / 17
Prolog
CUT, FAIL, ASSERTA
fibonacci
1,1,2,3,5,8,13,...
fib(1,1).
fib(2,1).
fib(N,F):- ???
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
12 / 17
Prolog
CUT, FAIL, ASSERTA
fibonacci
1,1,2,3,5,8,13,...
fib(1,1).
fib(2,1).
fib(N,F):- ???
F, N. fibonacci sayisidir!!!
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
12 / 17
Prolog
CUT, FAIL, ASSERTA
fibonacci
1,1,2,3,5,8,13,...
fib(1,1).
fib(2,1).
fib(N,F):- ???
F, N. fibonacci sayisidir!!!
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
12 / 17
Prolog
CUT, FAIL, ASSERTA
fibonacci
1,1,2,3,5,8,13,...
fib(1,1).
fib(2,1).
fib(N,F):N1 is N-1, fib(N1,F1),
N2 is N-2, fib(N2,F2),
F is F1+F2,
asserta(fib(N,F)).
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
13 / 17
Prolog
CUT, FAIL, ASSERTA
fibonacci
1,1,2,3,5,8,13,...
fib(1,1).
fib(2,1).
fib(N,F):N1 is N-1, fib(N1,F1),
N2 is N-2, fib(N2,F2),
F is F1+F2,
asserta(fib(N,F)).
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
13 / 17
Prolog
CUT, FAIL, ASSERTA
Figure: fib
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
14 / 17
Prolog
CUT, FAIL, ASSERTA
dynamic fibonaci
asserta ile bulunan degerler kaydediliyor.
Figure: fib
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
15 / 17
Prolog
CUT, FAIL, ASSERTA
son
Tesekkurler...
bir sonraki derste, Bulanik mantik ve yapay sinir aglarini uygulamalarina
giricez. takip edecegimiz kitap : C++ Neural Networks and Fuzzy Logic Valluru B. Rao
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
16 / 17
Appendix
Referanslar
Referanslar I
YTU - PROLOG
http://www.ce.yildiz.edu.tr/
Uzay CETIN ()
Yapay Zeka’ya giris
November 18, 2008
17 / 17
Download