CS 541 HOMEWORK 3, Prolog For all Prolog programs, you must run your code with either C Prolog or SBProlog. You must also provide evidence that your program is correct (verbal arguments or test cases or both). You might wish to look again at section 4 of the course specification for more details. NOTE FOR NEXT YEAR: GIVE INFO ABOUT WHAT KINDS OF QUERIES THE SOLUTIONS MUST BE ABLE TO ANSWER The following problems are due Friday, Feb. 7. 1. What ways can logic programs, as described by Kowalski, allow for parallel execution? 2. (Extra credit only) What changes would you make to Prolog's semantics to make it easier or more beneficial to run Prolog programs in parallel? 3. How does logic programming, as described by Kowalski, differ from Prolog? 4. Write clauses, specifying the following relations, in Prolog. Do not use cut (!) in your solutions to these problems. a. find_last/2, where find_last(L,X) holds if X is the last element in the list L. b. consecutive/3, where consecutive(L,X,Y) holds if in the list L, the elements X and Y appear in that order; for example consecutive([3,4,5],4,5) would be satisfied. c. delete_once/3, where delete_once(L1,X,L2) holds if L2 is like L1 except that one occurence of X has been deleted. You may assume that L1 has an occurence of X in it. d. delete/3, where delete(L1,X,L2) holds if L2 is like L1 except that all occurences of X have been deleted. You may assume that L1 has an occurence of X in it. 5. Turn the graph on the accompanying page into a Prolog program. Your program should be able to answer the following queries. a. language/2, where language(L,Y) holds if language L was produced in year Y. For example, language(fortran_1,1957) would hold. b. parent/2, where parent(L1,L2) holds if L1 is a parent of L2; that is, higher up on the chart with an arc from L1 to L2. For example, parent(algol_60,algol_W) holds, but not parent(algol_60,pascal). c. ancestor/2, where parent(L1,L2) holds if there is a directed path from L1 to L2 on the chart. For example, ancestor(algol_60,pascal) holds. A language is *not* its own ancestor. Also translate the following queries into Prolog. d. What language is an ancestor of C++? e. What ancestor of C++ was produced in 1960? f. What language is both an ancestor of Ada and C? g. What descendent of Algol-60 is an ancestor of Pascal?