Constraint satisfaction problems (CSPs) define states as assignments of variables to values from their domains, with constraints specifying allowable combinations. Backtracking search assigns one variable at a time using depth-first search. Improved heuristics like most-constrained variable selection and least-constraining value choice help. Forward checking and constraint propagation techniques like arc consistency detect inconsistencies earlier than backtracking alone. Local search methods like min-conflicts hill-climbing can also solve CSPs by allowing constraint violations and minimizing them.
This document provides an overview of Linux history and features. It discusses that Unix was developed in 1969 at Bell Labs and led to various variants. Linux was developed in 1991 by Linus Torvalds as an open source clone of Unix. It discusses some popular Linux distributions like Red Hat, Ubuntu, Debian etc. It then covers basic Linux commands, text editors like Vi and Emacs, available software packages, user management and how to setup a basic web server. It encourages computer engineers to learn Linux as most professional applications and tools are available on Linux platforms.
Waltz algorithm in artificial intelligenceMinakshi Atre
The document discusses the Waltz algorithm for constraint satisfaction problems. It presents the algorithm in three parts. Part 1 discusses constraints in search and knowledge representation, and how constraint propagation allows reaching a global solution using local search. It provides an example of line labeling in computer vision. Part 2 discusses how constraints can reduce complexity in perceptual tasks like line drawings. It explains Waltz's labeling scheme and valid junction configurations. Part 3 works through an example of applying Waltz labeling to a pyramid drawing, showing how constraints successively eliminate possible labelings until a unique solution is reached.
This document summarizes Go-Back-N ARQ and Selective Repeat ARQ protocols. It discusses the key aspects of each protocol including how they handle sequence numbers, sliding windows, control variables, timers, acknowledgements, and dealing with damaged or lost frames. Selective Repeat ARQ is more efficient for noisy links as it only resends the damaged frame rather than multiple frames like Go-Back-N ARQ. The document provides details on the operation of each protocol and differences in how they handle the receiver window size and control variables.
Branch and bound is a general optimization technique that uses bounding and pruning to efficiently search the solution space of a problem. It works by recursively dividing the solution space into subproblems, computing lower bounds for each subproblem, and comparing these bounds to the best known solution to determine if subproblems can be pruned or need further exploration. This process continues until all subproblems are solved or pruned to find the optimal solution.
This file contains the slides for the topic "Representing Knowledge using Rules". The slides focus mainly on difference b/w declarative and procedural knowledge, and forward & backward reasoning. In addition, the role of control knowledge in problem solving is depicted.
The inference engine applies logical rules to facts in the knowledge base to infer new information. It uses two approaches:
- Forward chaining starts with known facts and fires rules until reaching the goal, applying rules in a bottom-up manner.
- Backward chaining starts with the goal and works backwards through rules to find supporting facts, taking a top-down approach.
Both are illustrated using examples of determining an animal's color. Forward chaining applies rules to known facts about an animal to conclude its color, while backward chaining starts with the color goal and applies rules in reverse to find facts proving the goal.
Constraint satisfaction problems (CSPs) define states as assignments of variables to values from their domains, with constraints specifying allowable combinations. Backtracking search assigns one variable at a time using depth-first search. Improved heuristics like most-constrained variable selection and least-constraining value choice help. Forward checking and constraint propagation techniques like arc consistency detect inconsistencies earlier than backtracking alone. Local search methods like min-conflicts hill-climbing can also solve CSPs by allowing constraint violations and minimizing them.
This document provides an overview of Linux history and features. It discusses that Unix was developed in 1969 at Bell Labs and led to various variants. Linux was developed in 1991 by Linus Torvalds as an open source clone of Unix. It discusses some popular Linux distributions like Red Hat, Ubuntu, Debian etc. It then covers basic Linux commands, text editors like Vi and Emacs, available software packages, user management and how to setup a basic web server. It encourages computer engineers to learn Linux as most professional applications and tools are available on Linux platforms.
Waltz algorithm in artificial intelligenceMinakshi Atre
The document discusses the Waltz algorithm for constraint satisfaction problems. It presents the algorithm in three parts. Part 1 discusses constraints in search and knowledge representation, and how constraint propagation allows reaching a global solution using local search. It provides an example of line labeling in computer vision. Part 2 discusses how constraints can reduce complexity in perceptual tasks like line drawings. It explains Waltz's labeling scheme and valid junction configurations. Part 3 works through an example of applying Waltz labeling to a pyramid drawing, showing how constraints successively eliminate possible labelings until a unique solution is reached.
This document summarizes Go-Back-N ARQ and Selective Repeat ARQ protocols. It discusses the key aspects of each protocol including how they handle sequence numbers, sliding windows, control variables, timers, acknowledgements, and dealing with damaged or lost frames. Selective Repeat ARQ is more efficient for noisy links as it only resends the damaged frame rather than multiple frames like Go-Back-N ARQ. The document provides details on the operation of each protocol and differences in how they handle the receiver window size and control variables.
Branch and bound is a general optimization technique that uses bounding and pruning to efficiently search the solution space of a problem. It works by recursively dividing the solution space into subproblems, computing lower bounds for each subproblem, and comparing these bounds to the best known solution to determine if subproblems can be pruned or need further exploration. This process continues until all subproblems are solved or pruned to find the optimal solution.
This file contains the slides for the topic "Representing Knowledge using Rules". The slides focus mainly on difference b/w declarative and procedural knowledge, and forward & backward reasoning. In addition, the role of control knowledge in problem solving is depicted.
The inference engine applies logical rules to facts in the knowledge base to infer new information. It uses two approaches:
- Forward chaining starts with known facts and fires rules until reaching the goal, applying rules in a bottom-up manner.
- Backward chaining starts with the goal and works backwards through rules to find supporting facts, taking a top-down approach.
Both are illustrated using examples of determining an animal's color. Forward chaining applies rules to known facts about an animal to conclude its color, while backward chaining starts with the color goal and applies rules in reverse to find facts proving the goal.
Gereksinim analizi çalışmaları yazılım projelerinin başarıya ulaşabilmesi için yapılması gereken en önemli iştir. Doğru şekilde ihtiyaçları ortaya konmuş projeler ancak başarılı olabilirler.Gereksinim analiz çalışmaları iki aşamadan meydana gelir; Gereksinimlerin ortaya çıkarılması
Gereksinimlerin öncelik durumuna göre analiz edilmesi. Bu sunumda iyi bir proje için gerekli olan gereksinim analiz dokümanı hazırlama yöntemi verilmiştir.
The document discusses the ALGOL family of programming languages, including their history and goals. It describes the three versions of ALGOL: ALGOL 58, which introduced features like types and control structures; ALGOL 60, which refined the syntax and added block structures and recursion; and ALGOL 68, which had a more advanced type system but was difficult to adopt. While ALGOL did not achieve wide commercial success, it was influential in establishing concepts like block structures, recursion, and formal syntax specification that became standard in later languages.
Gereksinim analizi çalışmaları yazılım projelerinin başarıya ulaşabilmesi için yapılması gereken en önemli iştir. Doğru şekilde ihtiyaçları ortaya konmuş projeler ancak başarılı olabilirler.Gereksinim analiz çalışmaları iki aşamadan meydana gelir; Gereksinimlerin ortaya çıkarılması
Gereksinimlerin öncelik durumuna göre analiz edilmesi. Bu sunumda iyi bir proje için gerekli olan gereksinim analiz dokümanı hazırlama yöntemi verilmiştir.
The document discusses the ALGOL family of programming languages, including their history and goals. It describes the three versions of ALGOL: ALGOL 58, which introduced features like types and control structures; ALGOL 60, which refined the syntax and added block structures and recursion; and ALGOL 68, which had a more advanced type system but was difficult to adopt. While ALGOL did not achieve wide commercial success, it was influential in establishing concepts like block structures, recursion, and formal syntax specification that became standard in later languages.
2. Giriş & Tarihçe
Bilgisayar, 'simgeleri işlemek için kullanılan bir makine‘ olarak tanımlanmaktadır.
Görünüşte yalın olan bu terim, gerçekte çağdaş bir sayısal bilgisayarın yapabileceği
bütün görevleri kapsayan genişliktedir. Bu tanıma göre, bilgisayara girdi denilen bir
simgeler dizisi verilir; bunlar önceden makineye yerleştirilen
ve değişmez kurallar bütünü olan “programa” göre işlenir ve sonunda çıktı denilen başka
simgeler dizisi üretilir.
PROLOG-Program dili de bu tür simgelerle işleyen bir sistemdir.
PROLOG, "PROgramming in LOGic“ sözünün kısaltılmış bilçmidir ve ilk olarak 70 li yılların
başında
Marsilya Üniversitesi’nde ve Edinburg kentlerinde ortaya çıkmıştır. Daha sonraları ise
Londra’da
Imperial College’da geliştirilmiş ve geniş kitleler tarafından tanınması bu yolla sağlanmıştır.
2
3. Prolog Dilinin Özellikleri
PROgrammig in LOGic
Semboller üzerinde çalışma
Problemlerin çözümünü tanımlama yerine çıkarım yapma
Doğal dille düşünülen şeylerin kodlanmasının kolaylığı
Gerçekler ve kurallardan oluşma
Büyük küçük harfe duyarlı
Sabitler için Küçük harfler
Değişkenler için Büyük harfler
3
4. Prolog Dilinin Özellikleri
Prolog’la nesneler arası ilişkiler kolaylıkla ifade edilebilir.
Kullanıcı bilgi tabanındaki verileri kolaylıkla sorgulanabilir.
Program çıktıları çok sadedir.
Prolog Bildirgesel (Dekleratif) bir dildir.
4
5. Prolog Bildirgesel Bir Dildir
PROLOG doğrudan mantığa dayalı bildirgesel (deklerativ) bir program dilidir.
Burada kullanılan deklerativ terimi, surepel (prosedural) terimine karşılık olarak
kullanılmaktadır.
Hem sıradan bir bilgisayar dili hem de gelişmiş bütün üst düzeydeki bilgisayar
program dilleri bir süreçle ilgili dillerdir.
Süreçsel bir dilde, verilen bir problemi
çözmek için (bir yemek tarifinde olduğu gibi) aşama aşama çalışılır. Program
bitirilip çalıştırılmaya başlandığında ise önceden yazılan öngörülere uygun olan
sıraya göre çalışır. (Örnek: C, Pascal, Java vs.)
Bildirgesel bir program dilinde ise, olgular
ve kurallardan yola çıkılır.Yazılan programı çalıştırmak
için bir öngörü (Hipotez) oluşturulur ve bilgisayar bu öngörüyü kendisine daha
Önceden verilmiş olan olgu ve kurallar yardımıyla sınar.
5
6. Bildirgesel (Deklerativ)
Programlama
Prolog
bir cümlenin doğru / yanlış olduğunu
cümle içinde değişken(ler) varsa cümlenin
doğru olması için o değişken(ler)in
değer(ler)inin ne olması gerektiğini söyler.
6
7. Diğer Dillerle Karşılaştırma
Prolog’da olmayanlar
For döngüleri
Repeat While döngüleri
IF..THEN yapısı
Goto komutu
Diziler
Yukarıdakiler öz yinelemeli fonksiyonlarla sağlanır
Süreçsel (Prosedürel) programlamada bilgisayara adım adım ne
yapması gerektiğini kodlarız. Bildirgesel (Dekleratif) programlamada
bir durum tanımlanır. Bu tanıma göre yorumlayıcı yada derleyici bir
çözüm üretir.
7
8. Örnek : Aile Ağacı
pam to m
bob li z
ann pat
j im
8
9. İlişkileri gerçek(fact)lerle tanımlama
“Tom, Bob’un ebeveynidir” gerçeğinin
prolog’da ifadesi :
parent(tom, bob).
parent: ilişkinin ismi
tom ve bob: ilişkinin argümanları
9
10. Tüm aile ağacını aşağıdaki Prolog
ifadeleriyle tanımlarız:
parent(pam, bob).
parent(tom, bob).
parent(tom, liz).
parent(bob, ann).
parent(bob, pat).
parent(pat,jim).
10
12. İlişkileri sorgulamak-2
Liz’in ebeveyni kimdir?
?- ebeveyn(Kim, liz).
Prolog’un cevabı :
Kim = tom
Bob’un çocukları kimlerdir?
?- ebeveyn(bob, Cocuk).
Prolog’un cevabı :
Cocuk = ann ;
Cocuk = pat ;
no
12
13. İlişkileri sorgulamak-3
Kimler kimlerin çocuğudur?
?- ebeveyn (Ebeveyn, Cocuk).
Ebeveyn = pam
Cocuk = bob;
Ebeveyn = tom
Cocuk = bob;
Ebeveyn = tom
Cocuk = liz;
…
Çözümler listesini yarıda kesmek için enter
13
14. İlişkileri sorgulamak-4
Jim’in büyük ebeveyni (grandparent)
kimdir? X
Bilgi tabanımızda büyük ebeveyn diye
bir ilişki tanımlı değil. pare n t
Büyük ebeveyn ilişkisi iki ebeveyn
ilişkisinin ‘ve’ lenmesiyle elde edilebilir. gran dpare n t
Y
?- parent(Y, jim), parent(X, Y). pare n t
X=bob
Y=pat jim
jim’in ebeveynine Y dersek,
Y’nin ebeveyni jim’in büyük ebeveyni (X) dir. 14
15. İlişkileri sorgulamak-5
Torun ilişkisi de benzer
biçimde tanımlanabilir.
to m
tom, X’in ebeveyni,
X, Y’nin ebeveyni ise pare n t
Y, tom’un torunudur.
g r a n d c h ild r e n
?- parent(tom,X), parent(X, Y). X
X=bob
pare n t
Y=ann;
X=bob
Y=pat; Y
no
15
16. İlişkileri sorgulamak-6
Ann ve pat’in ortak ebeveyni var mı?
?- parent(Ebeveyn, ann), parent(Ebeveyn, pat).
Ebeveyn=bob
16
17. SWI-Prolog
Gerçek ve kurallar
prolog’a
yüklenir.Sorgular komut
satırından girilerek
çalıştırılabilir.
17
18. Doğal Dil vs. Prolog
Bütün çocuklar kısadır.
kisa(X):-cocuk(X).
Bütün erkek çocuklar arabaları sever.
sever(X,araba):-erkek(X),cocuk(X).
Bütün çocukların annesi vardır.
var(X,anne):-cocuk(X).
Sebzeyi hiçbir çocuk sevmez.
sevmez(X,Y):-sebze(Y), cocuk(X).
Çocuğunu döven öğretmeni hiçbir anne sevmez.
sevmez(X,Y):-anne(X,Z),ogretmen(Y,Z),dover(Y,Z).
18
19. Prolog’da Veri Türleri
Prolog bir veri türünü onun şeklinden tanır.
Prolog herhangi bir veri tanımına ihtiyaç
duymaz.
19
20. Atom’lar (1)
Atom’lar aşağıdakilerde oluşan string’lerdir.
Büyük harf
A, B, …, Z
Küçük harf
a, b, …, z
Rakam
0, 1, …, 9
Özel karakterler
+-*/<>=:.&_~
20
21. Atom’lar (2)
Atom’lar 3 farklı şekilde oluşturulabilir:
1. Harf, rakam ve altçizgi(‘_’)’den oluşan küçük
harfle başlayan string’ler ile:
anna
nil
x25
x_25AB
x_
x___y
alpha_beta_procedure
miss_jones
sarah_jones 21
22. Atom’lar (3)
2. Özel karakterlerden oluşan string’ler ile:
<--->
======>
…
.:.
::=
Özel anlamı olan stirng’ler kullanılmamalı:
:-
22
23. Atom’lar (4)
3. Tek tırnak (’) arasına alınan karakterler ile:
‘Tom’
‘South_America’
‘Sarah Jones’
Büyük harfle başlayan Atom’lar oluşturmak için
kullanılabilir. Değişkenlerden bu şekilde ayrılabilirler.
23
24. Sayılar
Prolog’da iki tür sayı topla(X,Y,Z):-Z is X+Y.
kullanılabilir
Tamsayılar (integer) ?-topla(2,0.3,C).
1 0 -97 1313 C = 2.3 ;
En büyük ve en küçük sayı No
prolog derleyicisine bağlıdır.
Ondalıklı sayılar (real)
?-topla(200,0.0003,C).
3.14 100.2 -0.0035
C = 200.0 ;
Genelde tamsayılar kullanılır. No
Ondalıklı sayılar pek fazla
kullanılmaz Çünkü:
24
25. Değişken’ler (1)
Değişkenler; harf, rakam ve
altçizgi(‘_’)’den oluşan büyük harfle
yada altçizgi ile başlayan string’lerdir:
X
Result
Object2
Participant_list
ShoppingList
_x23
_23
25
26. Değişken’ler (2)
Anonim değişken : isimlendirilmemiş değişkenlerdir.
Sadece altçizgi ile ifade edilirler:
hasachild(X) :- parent(X, Y).
hasachild(X) :- parent(X, _).
Her altçizgi karakteri yeni bir anonim değişkeni ifade
eder.
somebody_has_a_child :- parent(_, _). %r1
r1 eşittir somebody_has_a_child :- parent(X, Y).
ancak farklıdır somebody_has_a_child :- parent(X, X).
Anonim değişkenlerin değerleri çıkış olarak verilmez.
?- parent(ali,Y). : ali’in çocuğu var mı? Ve varsa
çocuklarının isimleri nedir?
?- parent(ali,_). : sadece ali’in çocuğu var mı?
26
27. Değişken ve Atom’ların Alanları
(Scope)
Bir değişkenin değeri bir cümlecik
içinde sabittir.
Bir atomun değeri tüm program
boyunca sabittir
27
28. Aritmetik i ş l emler
+ addition
- subtraction
* multiplication
/ real division
// integer division
mod modulus
** power
?- X is 3*4.
X = 12
yes
28
29. Lojik i ş lemler
a :- b. % a if b
a :- b,c. % a if b and c.
a :- b;c. % a if b or c.
a :- ++ b. % a if b is not provable
a :- not b. % a if b fails
a :- b -> c;d. % a if (if b then c else d)
29
30. Listing 2 ?- assert(bitki(gul)).
Yes
3 ?- assert(bitki(meneksel)).
Memory’de o an olan Yes
4 ?- listing.
bilgileri ve kuralları hayvan(kedi).
hayvan(kuzu).
ekrana yazar.
canli(A) :-
1 ?- listing. hayvan(A).
canli(A) :-
hayvan(kedi). bitki(A).
hayvan(kuzu).
:- dynamic bitki/1.
canli(A) :-
hayvan(A). bitki(gul).
canli(A) :- bitki(meneksel).
bitki(A).
Yes Yes
5 ?- hayvan(tosbaga).
????
30
31. Listeleri Yazdırmak
listeyaz(A):- A==[].
listeyaz(A):- [B|C]=A,write(B),tab(1),listeyaz(C).
-? listeyaz([a,b,c,d,e]).
a b c d e
true
liste2yaz(A):- A==[].
liste2yaz(A):-[B|C]=A,listeyaz(B),nl,liste2yaz(C).
?- liste2yaz([[a,b],[c,d],[e,h]]).
a b
c d
e h
true
31
32. Listeye eleman ekleme ve
çıkarma
Listelere eleman eklemek ve çıkarmak hep 1. elaman
üzerinden yapılır. Listeden sadece 1.eleman çıkarılabilir ve
eklenecek eleman sadece 1. eleman olarak eklenebilir.
?- D = [1,2,3,4], [ B | A ] = D.
A listesi [2,3,4] şeklinde oluşur. İlk eleman silindi.
?- D = [1,2,3,4], A = [ 0 | D ].
A listesi [0,1,2,3,4] şeklinde oluştu. Listenin başına 0 eklenmiş
oldu.
32
33. process([hello]).
hi
process([i,have,a,problem,.]).
eliza
please go on
process([i,hate,lessons,.]).
do you really hate lessons ?
process([yes,but,.]).
please go on .
process([i,like,school,.]).
does anyone else in your family like school ?
process([i,think,my,father,likes,school,too,.]).
please go on .
process([do,you,believe,me,?]).
why do me ask if I believe you ?
process([i,am,paranoiac,.]).
please go on .
process([are,you,parrot,?]).
what makes you think I am parrot ?
process([you,always,repeat,same,thing,.]).
please go on .
process([bye,.]).
I hope I was of some help.
33
34. process([W1,_]):- % asagidaki listeden birinden sonra en çok bir kelime varsa
member(W1, [bye, goodbye, quit, halt, chow]),
write('I hope I was of some help.'), nl.
process(Input):-
Eliza
kod
rule(Input, Output),
reply(Output).
% donusumler
% rule([user'in cumlesi], [eliza'nin cumlesi]).
rule([Greeting|Rest], [hi|Rest]):- member(Greeting, [hi, hello]).
rule([i,hate,X,'.'], [do, you, really, hate, X, ?]).
rule([_,you,Y,me,'?'], [why, do, me, ask, if, 'I', Y, you, ?]).
rule([i,like,X,'.'], [does, anyone, else, in, your, family, like, X,?]).
rule([are, you, X,'?'], [what, makes, you, think, 'I', am, X, ?]).
rule([you, are, X, '.'], [does, it, please, you, to, believe, 'I', am,X,?]).
rule(_, [please, go, on, '.']). % anlamis havasinda :))
reply([]):- !.
reply([FirstWord|Rest]) :- % kelimeler arasina 1tab koyarak ekrana yaz
write(FirstWord),
tab(1),
reply(Rest). 34
35. Kaynaklar
PROLOG Programming for Artificial Intelligence, Ivan Bratko, 3rd Edition, Addison-
Wesley,
Tacettin Ayar, Prolog Ders Notları
Bergen, Karl von: LISP fiir Linguisten: ein Grundkurs zur E i i g in die Computerlinguistik.
FrankfurtIaM; Berlin; New York; Paris; Wien: Lang, 1992 (Hamburger englischeLinguistik Praktika Bd.
4).
Glinz, Hans: Deutsche Grammatik 11. FrankfurtlaM. 1971.
Knaus, Rodger: Faster and Smarter Queries. A1 Expert's Toolbok. May 1988, SS. 13-18.
Knaus, Rodger & : A Simple PROLOG DBMS [data base management system]. A1
Expert'sToolbok. April 1988, SS.13-21.
Kraml Willibald & Schrodt, Richard: Syntax lernen mit PROLOG. In: Ide: Zeitschrift fiir den
Deutschunterricht in Wissenschaft und Schule. 2i1990. SS. 98- 1 14.
Lenders, Winfried & Willee, Gerd: Linguistische Datenverarbeitung: ein Lehrbuch. Opladen:
Westdeutscher Verlag, 1986.
35