Conjunction((and)) and Disjunction((or)) in prolog
For conjunction, comma , is used and it is read as and .
For Disjunction, semicolon ; is used and it is read as or .
Example:: Write a program in prolog contain 3 group(a, b, c). a contain 3 degree(9,10,11), b(9,12),c(9,12,10) .
Predicates
group(symbol, integer).
Clauses
group(a ,9).
group(a ,10).
group(a ,11).
group(b ,9).
group(b ,12).
group(c ,9).
group(c ,12).
group(c ,10).
Goal: group(a,X),X=9.
Goal: group(c,X), X>=10.
Goal: group(c,X),group(b,X).
Example:: If you have the following facts answer the questions:
Predicates
age(symbol, integer).
woman(symbol).
friend(symbol, symbol).
Clauses
woman(sara).
woman(jody).
woman(noor).
friend(sara,jody).
friend(noor, muna).
age(noor,20).
age(sara,25).
age(jody,22).
Goal: woman(X),friend(X,Y).
Goal: woman(X);friend(X,Y).
Example:: Given the following facts answer the questions:
Files Edit Run Compile Options Setup
Editor
Line1 Col1 Indent Insert Work.pro
Predicates
likes(symbol, symbol).
has(symbol, symbol).
friends(symbol, symbol).
Clauses
friends(dick, ed).
has(dick, book).
has(dick, mercedes).
likes(dick, mercedes).
likes(dick, wine).
likes(ed, wine).
----Dialog-----
Goal: friends(dick, ed).
Goal: likes(X, wine).
Goal: likes(X, Y), likes(X, mercedes).
Goal: likes(X, Y) ; likes(X, mercedes).