Prolog problems
1. In the database for PROLOG there are some facts about families. Thbere are facts about persons in the following format person(code,name,surname,gender,date_of_birth,birth_place,living_place) and facts about the family in the following format family(code_father,code_mother,list_codes_children) list_codes_children is a list of children from that marriage
Ex data: person(1,petko,petkovski,m,datum(1,3,1950),kratovo,skopje). person(2,marija,petkovska,z,datum(30,5,1954),kumanovo,skopje). person(3,ljubica,petkovska,z,datum(29,11,1965),skopje,skopje). person(4,vasil,vasilev,m,datum(8,4,1954),bitola,bitola). person(5,elena,vasileva,z,datum(19,6,1958),resen,bitola). person(6,krste,krstev,m,datum(9,8,1948),veles,veles). person(7,biljana,krsteva,z,datum(13,8,1949),veles,veles). person(8,igor,krstev,m,datum(26,10,1971),veles,skopje). person(9,kristina,krsteva,z,datum(30,5,1974),kumanovo,skopje). person(10,julija,petrova,z,datum(30,5,1978),skopje,skopje). person(11,bosko,petkovski,m,datum(13,11,1981),skopje,skopje). person(12,gjorgji,vasilev,m,datum(15,7,1978),bitola,bitola). person(13,katerina,petkovska,z,datum(11,12,1979),bitola,skopje). person(14,petar,vasilev,m,datum(21,2,1982),skopje,skopje). person(15,andrej,krstev,m,datum(3,8,1998),skopje,skopje). person(16,martina,petkovska,z,datum(5,12,2005),skopje,skopje). family(1,2,[9,10]). family(1,3,[11]). family(4,5,[12,13,14]). family(6,7,[8]). family(8,9,[15]). Family(11,13,[16]).
a) Write a PROLOG predicate born_different_city(amm) which returns how many children were born in a city different to the one where both parents were born EX from given data: born_different_city(amm) amm=3 b) Write a PROLOG predicate ancestors(code,L) which as input takes the code for a person and as output gives all the codes for its ancestors for which the following conditions have been met: the ancestor needs to be the same gender as the person that is being used as input and the ancestor’s birth day can only be 7 days different than the one used for the input person (assume every month has 30 days) EX from given data: ancestors(8,L) L=[], ancestors(15,L) L=[6], ancestors(16,L) L=[13,3]
2. Write the predicates and the solution to the following facts
1. Theo sits leftmost and is eating a sandwich. 2. Mary loves crosswords and enjoys a pie 3. The girl is wearing a white shirt 4. Bruno has a yellow shirt 5. The one that likes to write is eating a hamburger 6. The person eating a pie is sitting next to Theo 7. Bruno is sitting next to the person eating a pie 8. The person sitting next to the one wearing white likes pizza 9. Igor likes to read 10. The person sitting to the right of the girl has a blue shirt
Every person has a favorite food, a hobby and is wearing a different color shirt. Facts can only be solved by PROLOG. EX: the only girl is Mary, so we know that Mary is wearing a white shirt, but that can’t be a given, we need to solve that Mary is wearing a white shirt.
solution(L) needs to return a list of all persons in this format person(name,food,hobby,color_shirt)