Question: Hi, Chegg Expert PLEASE DO AS SOON AS POSSIBLE, REALLY URGENT. All the information is provided before, clicking on NEED MORE INFORMATION, FIRST READ,THANKS. Question
Hi, Chegg Expert PLEASE DO AS SOON AS POSSIBLE, REALLY URGENT. All the information is provided before, clicking on NEED MORE INFORMATION, FIRST READ,THANKS.
Question (See Below) - NEEDS TO BE DONE IN PROLOG:

To be Done in Prolog (See Below Example):


1. A database of Prolog facts for a group of people contains the following two types of facts: name([, , ...)). E.g., male([alex, tom, vic, ...]). female([, ,...)). E.g., female([ann, sara, ella, ...]). age(, ) E.g. age(ann, 66). For these facts write the following rules (you may use Prolog library functions): person(, ). Find the number of female in the database gender(, gender>). Find the name and the gender (male or female) youngest(, ,). Find the name/age/gender of the youngest person meanAge(). Find the mean age of all people in the database The following sample data been added to the database. 1 2 3 4 5 6 AN male(tom, 25). %add data to the database male(tim, 26) male(jerry,24). female(tony, 18) female(lily, 19) female(lisa, 20). The rules have been written for the asked questions male(ton,25) add data to the database naletim, 26) male(erry,24) female(tony, 18) female(lity, 19) female(lisa, 20) person(Name, Age) - male(Name, Age); female(Name, Age) find name and age of person ncount(Count) - indall(x,malel X).L). Length(L.Count) find the count of male using Tindall function fcount(Count) - findall(x, female X).L). Length(.Count) find the count of male using findall function listal(L) - Tindall (X. (malel X) ; female(x)),L) find list of all ages.using find all count_elems([HIT). N. Acc. Count) :- H>N. count this person if he is older than N Accl is ACC + 1. increment the accumulator count elems(T. N. Acci, Count) check the rest of the list count elems([HIT). N. Acc. Count): Ha N. don't count this person if he is younger than N count clems (T. N. Acc, Count) check rest of list without incrementing acc) count elems(1). Count. Count) At the end, instantiate total with accumulator older (Age. Count) - ListAll().count_elens(L.Age, 0. Count) first find ist of all ages and then count function to find the saximum of list: maxlist(1, R. R) Send maxlist([xlxs). Ca. R)- X > Ca, maxlist(xs. X. R) > Co and X will be the max until here maxlist(XIXS]. Co, R) - X Ca, maxlist(Xs. Ca. R) X