Department of Computer Science, CSUDH

CSC 321: Programming Languages

CSC521: Advanced Programming Languages

(Spring 2007)

 

Writing Assignment 9

 

Chapter 15: Logic Programming

 

Due May 8, 2007

 

 

All questions are scored the same.

 

  1. Explain the following concepts in logic programming: (Section 15.1)
  1. Closed-world assumption in Prolog

  2. Horn clause in Prolog

  3. Unification in Prolog

  4. Backtracking in Prolog

  5. Cuts in Prolog

  6. Prolog search tree (and-or tree)

  1. Consider a relation member defined by Prolog rules: (Section 15.2)

member(M, [M|_]).

member(M, [_|T]) :- member(M, T).

 

Draw Prolog search trees for the following queries:

                                                   i.            ?- member(b, [a, b, c]).

                                                 ii.            ?-X = [1, 2, 3], member(a, x).

                                                iii.            ?-Member(a, x), x = [1, 2, 3].

 

  1. For graduates only. Write Prolog rules to
    1. Remove all duplicates of elements in a list.
    1. Reverse the sequence of elements in a list.