Description
CSCI 421 Project Five focuses on logic programming in SWI-Prolog through solution enumeration and duplicate elimination. Based on Exercise 21 on page 412, the project requires students to determine the total number of generated solutions, identify distinct results, and modify a Prolog program to display only unique solutions using logical queries and backtracking.
Assignment Description
Refer to Exercise 21 on page 412.
Please note that the students need to answer the following two questions:
1. How many solutions does it print?
2. How many of them are distinct?
Then the student need to modify the program so that only the distinct solutions will be print
out.
Instruction on how to write and run the SWI-Prolog program:
Step One: Write your program using any text editor. Save the program as
YourNameProjFive.swipl
Step Two: Open terminal window. Use cd command to navigate to the folder where you saved
your project four program.
Step Three: Type swipl. The SWI-Prolog program will run
Step Four: Type consult(‘YourNameProjFour.swipl’). (must have period at the end)
Step Five: Tyep length(X, 7), solution([w, w, w, w], X). (end with period) Use the semicolon after
each solution to make it print them all.
Solution Overview
The solution addresses counting all results generated by the specified SWI-Prolog query, determining how many are distinct, and modifying the program to print only unique solutions. It covers Prolog backtracking, solution enumeration, duplicate filtering, and interactive query execution.


