Vous êtes sur la page 1sur 2

[] PROLOG

LAB

LAB #4

OPERATORS ( ADD, SUBTRACT, DIVIDE, MULTIPLY)


Dictionary (synonym(), antonym(.) )
Even Odd
Positive and Negative

%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).

%Lab4_5: Using not


DOMAINS
name = symbol
gpa = real
PREDICATES
honor_student(name)
student(name, gpa)
probation(name)
CLAUSES
student("omer ali", 3.5).
student("salem", 2.0).
student("mohammed", 3.7).
probation("omer ali").
probation("salem").
honor_student(Name):- student(Name, GPA),
GPA >= 3.5,
not(probation(Name)).
GOAL
honor_student(X).
-------------------------------------------------------------------------------------------------------------------------Dr Mohammed Fadhl
2

Vous aimerez peut-être aussi