Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Prolog question: Solving a Puzzle by Encoding it in Prolog: solve/1 (4 out of 10 marks): The following puzzle needs to expressed as a prolog
Prolog question:
Solving a Puzzle by Encoding it in Prolog: solve/1 (4 out of 10 marks): The following puzzle needs to expressed as a prolog program. The puzzle is the following. Four suspects a, b, c, and d were rounded up for questioning concerning a robbery. It was known for sure that at least one of them was guilty and that no one outside these four were involved. The following facts turned up 1. a was definitely innocent. 2. if b was guilty then he had exactly one accomplice 3. if c was guilty then he had exactly two accomplices You need to write a predicate, solve(Guilty), which when called with a variable will return one of the possible gangs (as lists) of people who could have committed the robbery together, given the facts above. Your predicate needs to handle redo's, i.e., after your predicate returns at the top-level, if you type in a";" then if there is another gang that could have committed the crime, then it should be returned, when there are no more gangs that could have committed the crime together then it should fail Every code line must end in a comment describing what the code does. You will want to use the subset/2 predicate (which is defined below) subset([J,0) subset([XIL],[XIS]) subset(L,S) Solving a Puzzle by Encoding it in Prolog: solve/1 (4 out of 10 marks): The following puzzle needs to expressed as a prolog program. The puzzle is the following. Four suspects a, b, c, and d were rounded up for questioning concerning a robbery. It was known for sure that at least one of them was guilty and that no one outside these four were involved. The following facts turned up 1. a was definitely innocent. 2. if b was guilty then he had exactly one accomplice 3. if c was guilty then he had exactly two accomplices You need to write a predicate, solve(Guilty), which when called with a variable will return one of the possible gangs (as lists) of people who could have committed the robbery together, given the facts above. Your predicate needs to handle redo's, i.e., after your predicate returns at the top-level, if you type in a";" then if there is another gang that could have committed the crime, then it should be returned, when there are no more gangs that could have committed the crime together then it should fail Every code line must end in a comment describing what the code does. You will want to use the subset/2 predicate (which is defined below) subset([J,0) subset([XIL],[XIS]) subset(L,S)
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