Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This exercise demonstrates how to implement a simple database in Prolog. Copy the following list of eight facts (the data) into a program file: born(jan,

This exercise demonstrates how to implement a simple database in Prolog. Copy the following list of eight facts (the data) into a program file: born(jan, date(20,3,1977)). born(jeroen, date(2,2,1992)). born(joris, date(17,3,1995)). born(jelle, date(1,1,2004)). born(jesus, date(24,12,0)). born(joop, date(30,4,1989)). born(jannecke, date(17,3,1993)). born(jaap, date(16,11,1995)). That is, we are representing dates as terms of the form date(Day,Month,Year). (a) Write a predicate year/2 to retrieve all people born in a given year (through repeated backtracking). Example: ?- year(1995, Person). Person = joris ; Person = jaap ; No (b) Implement a predicate before/2 that, when given two date-expressions, will succeed if the first expression represents a date before the date represented by the second expression (you may assume that the user will only ask for well-formed dates, e.g., not for the 31st of April, and so forth). Example: ?- before(date(31,1,1990), date(7,7,1990)). Yes (c) Implement a predicate older/2 that succeeds in case the person given first is (strictly) older than the person given second. Example: ?- older(jannecke, X). X = joris ; X = jelle ; X = jaap ; No You should get 28 solutions for the query older(X, Y). Explain why

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions