Uploaded by mennaahmed0640

Mid

advertisement
Choose the correct
1) If sky is blue, everyone likes it. Write this statement as a prolog
clause
A) sky(blue): - everyone(likes).
B) blue(sky), likes(X).
C) likes (X, sky): - blue(sky)
D) likes (sky, everyone): - blue(sky)
2)? - owner (jack, cat (X)): - fur(X), spots(X). – what would be the
English meaning
A) jack is a owner of cat and fur and spots
B) jack is the owner of X or jack is the owner of fur and spots
C) jack is the owner of some cat if that cat has fur and spots
D) B & C both
3) Which one of the following is not a variable in prolog?
A) X_yz
B) g_23A
C) ‘_Xyz’
D) B & C both
4) Prolog program consists of facts and rules which we collectively
call clauses
A) True
B) False
5) Prolog is used in various domains of application such as
intelligent database retrieval and robot planning
A) True
B) False
6) The logic programming system combines existing statements to
find new statements called resolution
A) Ture
B) False
7)Horn clause consists of a consequent (head H) and a body (terms
B𝑖 )
A) True
B) False
8) PROgramming in LOGics (Prrolog) is a traditional functional
(Procedural) Programming language
A) True
B) False
9) In prolog after each line you have to use (;) symbol to show that
the line has ended
A) True
B) False
10) Rule can be defined as an explicit relationship between objects
and properties might have
A) True
B) False
2- Write the English Meaning
1) Color (carrots, orange).
Sol: The color of carrots is orange.
2) Likes (Person, carrots): - vegetarian (Person).
Sol: The person likes carrots if the person is a vegetarian.
3) Pass (Student): - study_hard (Student).
Sol: Student will pass if he studies hard.
4) ? - pass(who).
Sol: Who will pass?
5) Enemies (X, Y): - hates (X, Y), fights (X, Y).
Sol: X is enemy to Y if X hates Y and X fights Y.
3- Write applicable Prolog facts and rules: 1) Maria reads logic programming book.
Sol: Reads (Maria, logic_programming_book).
2) Anyone likes shopping if she is a girl.
Sol: likes (X, shopping): - girl(X).
3) Who likes shopping?
Sol: ?-likes (Y,shopping).
4) John is healthy.
Sol: ?- healthy (john).
5) Anyone is a traveler if he is healthy and wealthy.
Sol: traveler(X): - healthy(X), wealthy(X).
Download