حمل الملف

advertisement
LAB Experiments
1435 /1434 ‫الفصل الدراسى الثاني للعام الجامعي‬
363cs :‫المقرر‬
Course Name: Artificial Intelligence
156 ‫الشعبة‬
‫ السادس‬:‫المستوي‬
Week-7
‫جامعة سلمان بن عبد العزيز‬
‫كلية اآلداب والعلـوم بوادي الدواسر‬
‫قســـم علوم الحاسب و المعلومات‬
Date:………………………………
Student Name: …………………………………………
Academic Number:…………………………………….
Part A: Practicing
Aim: Predicates- Matching
Learning Objective: Prolog to test a given pair of points, whether they form a horizontal line or
vertical line.
1. Check the following for matching of predicates.



John is child of Ann
John is child of Alex.
Ann is child of bob.
2. Represent the following facts in prolog language
[bob, carol, ted, alice]
[X|Y]
matches with X=bob Y=[carol,ted,alice]
[X,Y|Z]
matches with X=bob, Y=carol, Z=[ted,alice]
[X,Y,Z|W]
matches with X=bob, Y=carol, Z=ted W=[alice]
[X,Y,Z,W|V] matches with X=bob, Y=carol, Z=ted, W=alice and V=[]
[X,Y,Z,Y]
won't match because Y=carol and carol != alice
[X,Y,Z,W,V|U] won't match because the list does not contain 5 elements
1. Lists in prolog
append([],List,List).
append([H|Tail],X,[H|NewTail]) :- append(Tail,X,NewTail).
Input: append([a,b,c],[d,e],X).
1
LAB Experiments
1435 /1434 ‫الفصل الدراسى الثاني للعام الجامعي‬
363cs :‫المقرر‬
Course Name: Artificial Intelligence
156 ‫الشعبة‬
‫ السادس‬:‫المستوي‬
Week-9
Date:………………………………
Student Name: …………………………………………
Academic Number:…………………………………….
Part A: Practicing
Aim: Family Tree
Objective: To deuce predicate and check it from given clause.
We have only clause father(A,B), e.g. father(ali,wali)
e.g. to deduce grandfather relation we will do asgrandfather(A,C):- father(A,B), father(B,C).
First we will create fact base to be used in both exercises.
father(ali,wali).
father(ali, hamza).
father(ali, saad).
father (ali, saud).
father(ali, saeed).
father(hamza,salman).
father(hamza, sultan).
2


‫جامعة سلمان بن عبد العزيز‬
‫كلية اآلداب والعلـوم بوادي‬
‫الدواسر‬

‫قســـم علوم الحاسب و‬
‫المعلومات‬
Deducing Uncle relationship
brother(A, B) :-father(C, A),father(C, B).
cousin(A, B) :-father(C, A),father(D, B),brother(C, D),C \= D.
uncle(X,Y):- father(A,X), father(A, Z), father(Z,Y).
Check the following exercise
?-uncle(wali, saeed).
?cousin(saeed, salman).
?-cousini(saad, saeed).
Exercise
3
LAB Experiments
1435 /1434 ‫الفصل الدراسى الثاني للعام الجامعي‬
363cs :‫المقرر‬
Course Name: Artificial Intelligence
156 ‫الشعبة‬
‫ السادس‬:‫المستوي‬
Week-
‫جامعة سلمان بن عبد العزيز‬
‫كلية اآلداب والعلـوم بوادي الدواسر‬
‫قســـم علوم الحاسب و المعلومات‬
Student Name:
Academic No:
Practicing Part A: Construct the following facts using prolog
John is a parent of Paul.
Paul is a parent of tom.
Tom is a parent of mary.
Represent the following below fact using PROLOG relations
If Y is a parent of X, then Y is an ancestor of X
If Z is an ancestor of Y and X is a parent of Z,
Then X is an ancestor of Y
Part B : Exercise
1. John is ancestor of paul.
2. Paul is ancestor of tom
3. Tom is ancestor of mary.
4
LAB Experiments
1435 /1434 ‫الفصل الدراسى الثاني للعام الجامعي‬
363cs :‫المقرر‬
Course Name: Artificial Intelligence
156 ‫الشعبة‬
‫ السادس‬:‫المستوي‬
Week- 11
‫جامعة سلمان بن عبد العزيز‬
‫كلية اآلداب والعلـوم بوادي الدواسر‬
‫قســـم علوم الحاسب و المعلومات‬
Student Name:
Academic No:
Practicing Part A: Construct the following facts using prolog
Aim: Semantic Networks
Represent the following facts in Prolog language.









Tom is a cat.
Tom caught a bird.
Tom is owned by John.
Tom is ginger in colour.
Cats like cream.
The cat sat on the mat.
A cat is a mammal.
A bird is an animal.
All mammals are animals.
5

Mammals have fur.
Exercise:
6
Download