Question
Write a Prolog program to solve the Riding Stable Puzzle: Last Saturday, all six of the horses in Johnson Stables were rented to children for
Write a Prolog program to solve the Riding Stable Puzzle:
Last Saturday, all six of the horses in Johnson Stables were rented to children for the day, all of them regulars. Each of the horses (whose names are Boris, Hunter, Lady, Ranger, Santa Fe, and Topper) lives in one of the six stalls, numbered one to six from west to east. The children included three boys (Brian, Curtis, and Roy) and three girls (Lily, Michelle, and Theresa), each a different age (15, 14, 12, 10, 9, and 7 years old).
The following facts are known about the horses and the children who rode them that day:
1. Topper lives two or more stalls to the east of Theresa's horse.
2. The nine-year-old's horse lives somewhere to the west of Brian's horse.
3. Three horses in consecutive stalls, from west to east, are Boris, Brian's horse, and the 12-year-old's horse.
4. The child who rode Topper is three years older than the one who rode the horse in stall 4, while Roy is three years older than Michelle. (These are 4 different children).
5. Ranger's rider is three years older than Lily, who in turn is two years older than the girl who rode Lady.
6. Santa Fe lives somewhere to the west of Curtis's horse.
7. Brian is just one year older than Theresa.
8. Roy didn't ride the horse in stall 6.
Can you determine each horse's stall number, and the name and age of the child who rode him or her that day?
For full marks, implement your solution such that the puzzle can be solved by the query
?- solve.
NOTE: Youre program should use a knowledge base to find a solution, not simply print a pre-computed solution.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started