CSC 261 | Grinnell College | Fall, 2007 |
Artificial Intelligence | ||
The accompanying table indicates programming assignments, projects, and due dates for Computer Science 261 and are subject to the following notes.
Unless otherwise indicated, textbook references are to Stuart J. Russell and Peter Norvig, Artificial Intelligence: A Modern Approach (Second Edition), Prentice-Hall, 2003.
Details for programming exercises and projects are given later on this page.
Unless otherwise stated,
Due Date | Collaboration Allowed | Problems |
---|---|---|
Fri., Sept. 7 | Yes | Programming Problem 1 |
Mon., Sept. 10 | No | Programming Problem 2 |
Fri., Sept. 21 | Yes | Project 1 |
Mon., Oct. 8 | Yes | Programming Problem 3 |
Wed., Oct. 10 | No | Programming Problem 4 |
Mon., Oct. 15 | Yes | Project 2 |
Wed., Nov. 7 | Yes | Expert Systems Lab |
Mon., Nov. 19 | Yes | Project 3 |
Wed., Dec. 5 | Yes | Neural Network Lab |
Mon., Dec. 10 | Yes | Project 4 |
Since every programming task should yield readable and carefully tested code, the grading of all programs for this course will begin with the following algorithm (expressed in C/Java format):
if ((no_comments) || (no_evidence_of_compilation) || (no_test_runs) || (no_commentary_on_correctness)) return (no_grade);
When a program is submitted, it should be understood that the program listing produces any output submitted. Editing of the output or turning in output that does match a program may raise questions of academic dishonesty; and, by College policy, any evidence of academic dishonesty must be turned over to the Academic Standing Committee for action.
Given a multiplicative expression in list form, write a LISP procedure simplify-1 to reformat and simplify the expression, as follows:
Note: You need not evaluate nested lists in this procedure.
Examples:
(simplify-1 '(* 3 a b (- x y) 0 5 r 8 z)) ; product 0 ==> 0 (simplify-1 '(* 3 a b (- x y) 1/120 5 r 8 z)) ; product 1 ==> (* a b (- x y) r z) (simplify-1 '(* 3 a b (- x y) 5 r 8 z)) ; product of 3 5 8 is 120 ==> (* 120 a b (- x y) r z) (simplify-1 '(* 3 a b (- x y) -5 r 8 z)) ; product is -120 ==> (* -120 a b (- x y) r z) (simplify-1 '(* 3 a b (- x y) (- 3 3) 5 r 8 z)) ; (- 3 3) not evaluated ==> (* 120 a b (- x y) (- 3 3) r z)
Write a LISP procedure same-term that takes two multiplicative LISP expressions as parameters, and returns true (T) if they are the same (except for leading numeric coefficient), and returns false (NIL) otherwise.
Examples:
(same-term '(* 3 x y) (* -2 x y)) ==> T (same-term '(* 3 x y) (* -2 y x)) ==> T (same-term '(* 3 x y) (* -2 x z)) ==> NIL (same-term '(* 3 x y) (* -2 x)) ==> NIL
Write Prolog predicates to solve the following three problems
double([a, b, c], [a, a, b, b, c, c]). yields yes
double([a, b, c], [a, b, c, a, b, c]). yields no
double([1, 2, 3, 4]), Y). yields Y = [1, 1, 2, 2, 3, 3, 4, 4]
double([], Y). yields Y = []
insert has three parameters, an item and two lists, and returns true in the second list may be obtained by inserting the item at some position of the first. Examples:
insert(1, [a, b], [1, a, b]). insert(1, [a, b], [a, 1, b]). and insert(1, [a, b], [a, b, 1]). return yes.
insert(1, [a, b], [b, 1, a]). returns no, because a comes before b in the first list but after in the second.
ordered([]). yields yes (no numbers out of order)
ordered([1]). yields yes
ordered([1, 2, 3]). yields yes
ordered([1, 3, 2, 4]). yields no
Note: You may not use the built-in sort predicate for this problem.
Write a Prolog predicate nextItem that has three parameters: a list, and two items. The predicate is true if the second item follows immediately after the first on the given list. Examples:
nextItem([1,2,3,4], 1, 2),
nextItem([1,2,3,4], 2, 3), and
nextItem([1,2,3,4], 3, 4) all yield yes.
nextItem([1,2,3,4], 1, 3) yields no because 3
does not follow immediately after 1 on the list — there is a
2 between them.
nextItem([1,2,3,4], 1, 5) yields no because 5
is not on the list at all.
merge([],Y,Y). merge(X,[],X). merge([H|T1], [H|T2], [H,H|T3]) :- merge(T1, T2, T3). merge([H1|T1], [H2|T2], [H1|T3]) :- merge(T1, [H2|T2], T3), H1<H2 . merge([H1|T1], [H2|T2], [H2|T3]) :- merge([H1|T1], T2, T3), H1>H2 .
Draw a full search tree to show the processing involved for the query merge(X,Y,[1,2,3]).
Initial planning for the course anticipates four programming-based projects.
Students may collaborate in pairs on each project. (Groups of more than 2 may be considered only with prior approval of the instructor.)
Consider valid algebraic LISP expressions defined recursively as follows:
Basic Problem: Write a LISP function diff-basic that takes two parameters, a valid algebraic LISP expression VALP and a symbol X, and that returns the (unsimplified) derivative of VALP with respect to X. The result of VALP must again be a valid algebraic LISP expression. To emphasize the note in the first sentence, diff-basic need not perform any simplifications of any kind. Thus, (diff-basic '(* 2 X) 'X) might return (+ (* 2 1) (* X 0)) and (diff-basic '(* 2 X Y) 'X) might return (+ (* 2 (+ (* X 0) (* Y 1))) (* (* X Y) 0))).
Refined Problem: Write a LISP function diff-better that takes the same two parameters as diff-basic, differentiates the given expression, and performs at least three of the following simplifications:
Additional simplifications may be considered, but check with the instructor first (e-mail: walker@cs.grinnell.edu).
Extra Credit is possible on this project if more than 3 types of simplifications are performed within diff-better.
One of the early, well-known programs within the field of artificial intelligence was called Eliza, a program by Joseph Weizenbaum. The idea was to simulate conversation between a patient and psycho-therapist, based on a series of patterns and corresponding responses. Although the original program had an extensive sequence of patterns, this assignment focuses on the following five rules:
Pattern | Response Template | |
---|---|---|
---_{1} my singleWord ---_{2} me ---_{3} | tell me about your singleWord | |
---_{1} i am ---_{2} | i am sorry to hear you are ---_{2} | |
---_{1} am i ---_{2} | do you believe you are ---_{2} | |
---_{1} you ---_{2} me ---_{ 3 } | why do you think i ---_{2} you | |
---_{1} | in what way |
In this table, the blank spaces in a pattern, denoted by subscripted dashes, can be filled in with any sequence of words. Similarly, singleWord represents exactly one word in a sentence. For example, these patterns might generate the following "conversation," where the responses are indented and in italics:
well my friend made me come here
tell me about your friend
he says i am depressed
i am sorry to hear you are depressed
i think i need help
in what way
i wonder if you would help me learning to program Scheme
why do you think i would help you
when i registered for the course i wondered am i crazy
do you believe you are crazy
Each of these statements and responses follows the template/response patterns given. For example, in the first statement:
well my friend made me come here
the presence of the word my
near the start of the sentence
with the word me
later on corresponds to the first pattern,
with the following matches:
Pattern Element | Words from this Sentence |
---|---|
---_{1} | well |
my | my |
singleWord | friend |
---_{2} | made |
me | me |
---_{3} | come here |
After identifying these pattern elements for the first pattern, the Eliza program uses the corresponding response template. In this case, the program prints "Tell me about your friend". The first four of these words come directly from the template. For the final word, singleWord in the template was matched with the word "friend" in the above analysis.
Although this approach may seem simple today, Joseph Weizenbaum used this approach as the basis for his widely heralded Eliza in 1966. In 1976, Weizenbaum noted he "was startled to see how quickly and how deeply people conversing with [ Eliza] became emotionally involved" in the conversation. People shared their hopes and secrets, and they became annoyed if other people looked over their shoulders or otherwise interrupted. Even when they knew Eliza was a program, they often talked as if it were a close personal friend.
Write a PROLOG program to solve this Eliza-based pattern-matching problem. In the interests of time, we will largely ignore niceties of I/O for this project. Thus, you are not allowed to use such I/O predicates as get, put, read, or write. Rather, you should enter a sentence directly as a list, within the context of Prolog query. For example,
eliza ([well, my, friend, made, me, come, here], Response).
The current rule-base to place incoming students in computer science and mathematics courses may be found at ~walker/261/tmycin/newstudents.lsp. After copying this program to your account, expand it to include statistics placements, following the Placement Cases for Statistics as outlined in supplemental problem 2 fof this course.
Notes:
The above placements are listed in ascending order of preparation. If a student has adequate background for several placements, the student should be placed in the highest of the relevant courses.
You should assume that newstudents.lsp already gives appropriate computer science and mathematics placements, and you are free to use those placements in your rules for statistics.
newstudents.lsp classifies ACT/SAT scores into ranges, giving attribute stdscores values superior, high, good, fair, poor, low, and unknown. For the purposes of this problem, you should consider an ACT of 29 or higher as being superior or high for attribute stdscores. (This is off by 1 on the ACT scores from the Placements Cases for Statistics, but this categorization will be considered appropriate for this exercise.)
As with computer science and mathematics placements, your expert system should give a placement for every student; use unknown if all else fails!
Develop a neural network to solve the statistics placement problem.
Several scripts may help with data sets for setting up this problem:
This document is available on the World Wide Web as
http://www.walker.cs.grinnell.edu/courses/261.fa07/projects.shtml
created 29 August 2007 last revised 30 November 2007 | |
For more information, please contact Henry M. Walker at (walker@cs.grinnell.edu) |