domains
date = d(day,mon,year)
dm = da(day,mon)
day , mon ,year = integer
sign = symbol
predicates
zodiac_month(sign,dm,dm)
find_sign(Date)
clauses
zodiac_month(aquarius,da(20,1),da(18,2)).
zodiac_month(pisces,da(19,2),da(20,3)).
zodiac_month(aries,da(21,3),da(19,4)).
zodiac_month(taurus,da(20,4),da(20,5)).
zodiac_month(gemini,da(21,5),da(21,6)).
zodiac_month(cancer,da(22,6),da(22,7)).
zodiac_month(leo,da(23,7),da(22,8)).
zodiac_month(virgo,da(23,8),da(22,9)).
zodiac_month(libra,da(23,9),da(23,10)).
zodiac_month(scorpio,da(24,10),da(21,11)).
zodiac_month(sagittarius,da(22,11),da(21,12)).
zodiac_month(capricorn,da(22,12),da(19,1)).
find_sign(d(Day,Mon,Year)) :-
zodiac_month(Sign,da(_,_),da(Day2,Mon2)),
Mon2 = Mon,
Day <= Day2,
write("Zodiac sign is " , Sign),nl.
find_sign(d(Day,Mon,Year)) :-
zodiac_month(Sign,da(Day1,Mon1),da(_,_)),
Mon1 = Mon,
Day >= Day1,
write("Zodiac Sign is " ,Sign),nl.
find_sign(d(Day,Mon,Year)) :-
write("Incorrect Date specified").
Output :
Goal: find_sign(d(6,5,1982))
Zodiac sign is taurus
Yes