Professional Documents
Culture Documents
% Subtract, Divide, Multiply: Prolog Lab
% Subtract, Divide, Multiply: Prolog Lab
% Subtract, Divide, Multiply: Prolog Lab
LAB
LAB #4
%Lab4_1:
PREDICATES
addi(integer,integer)
% subtract, divide, multiply
addr(real,real)
%subti
CLAUSES
addi(A,B) if C =A+B, write(" The sum is ",C), nl.
addr(A,B) if C =A+B, write(" The sum is ",C), nl.
% subti(A,B) .
GOAL
addr(4.3, 5.5).
%Lab4_2:
PREDICATES
synonym(symbol, symbol)
antonym(symbol, symbol)
CLAUSES
synonym(brave, daring).
synonym(honest, truthful).
synonym(brave, powerful).
antonym(brave, cowardly).
antonym(honest, dishonest).
GOAL
antonym(brave, A), write( The antonym for brave is , A), nl.
%Lab4_3:
PREDICATES
OddEven(integer)
CLAUSES
OddEven(X):- X mod 2= 0 , write(" It is Even"), nl.
OddEven(X):- write("It is Odd "), nl.
GOAL
OddEven(-5).
%OddEven(19).
-------------------------------------------------------------------------------------------------------------------------Dr Mohammed Fadhl
1
[] PROLOG
LAB
%Lab4_4:
PREDICATES
positive(integer)
CLAUSES
positive(X):- X >=0 , write(" It is positive"), nl.
positive(_):- write("It is negative "), nl.
GOAL
positive(-5).
%positive(5).