Question: A database can be represented in Prolog as a set of facts. For example, a database about families can be represented so that each family

A database can be represented in Prolog as a set of facts. For example, a database about families can be represented so that each family is described by one clause. As the number of children varies from family to family the children are represented by a list that can accommodate any number of items. Each person is, in turn, represented by a structure of four components:
name, surname, date of birth, job. The job information is unemployed', or it contains the name of the organization and the salary.
For instance:
family(
person(tom, fox, date(7,may,1950), works(bbc,15200)),
person( ann, fox, date(9,may, 1951), unemployed),
[ person(pat, fox, date(5,may,1973),unemployed),
person(jim, fox, date(S,may,1973), unemployed)]).
Write queries to find the following from the family database:
(a) names of families without children;
(b) all employed children;
(c) names of families with employed wives and unemployed husbands;
(d) all the children whose parents differ in age by at least 15 years.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!