Download Questions on Artificial Intelligence with Solution - Midterm Exam | CAP 4621 and more Exams Computer Science in PDF only on Docsity!
CAP4621 Artificial Intelligence
Midterm – Fall 2003
Includes problems and solutions
Instructor: Alin Dobra
October 27, 2003
Name:
SID:
Email:
- This is a 50 minute, closed-book exam. You are allowed to use handwritten notes on both sides of a US letter size sheet of paper.
- This exam contains 6 single-sided sheets of paper (including this one)
- Write all answers on these pages, preferably on the white space in the problem statement. Continue on the back page if running out of space but clearly number your answers if doing so.
- Make sure you attack every problem; partial credit will be awarded for incomplete or partially correct results.
Grading:
Total 100
- Search and Constraint Satisfaction [45]
A Latin square of order n is an n × n square whose elements are chosen from integers 1 through n in such a way that each integer occurs exactly once in each column and in each row. An example of an order 4 Latin square is the following:
1 2 3 4 2 3 4 1 3 4 1 2 4 1 2 3
In this problem we consider methods to find such Latin squares.
a. [10] Model the problem of finding a Latin square of order n as an Uninformed Search problem. That is, specify (in clear and concise English) how the uninformed search problem can be set up such that any uninformed search algorithm can be used to solve it. Solution: To model the Latin Squares problem as an uninformed search problem we have to spec- ify the states, successor function, start state and goal test. Once this is done, any uninformed search algorithm can be used to solve the problem. Note that you were not required to solve the problem but to model it (i.e. formulate the problem as an uninformed search problem).
- States: A partial assignment of values to squares, i.e. the value of some squares is specified and the value for some other squares is NULL.
- Successor State For any given state, the successor states can be defined as the states that have the same assignment except one of the squares without a value now has a value. Thus, the number of successor states is the number of unassigned squares times n, the number of possible values for each square.
- Start State: All squares have NULL value
- Goal Test: Succeeds if all the squares have non NULL value and no value is repeated in any row or column.
[5] What would be a good choice for an uninformed search algorithm to solve this prob- lem? (Explain in one or two sentences your choice) Solution: Clearly, depth first search(DFS) is the best choice since all the solutions are found at the same depth so the time complexity of DFS is the same on this problem as for breadth first search (BFS) but the space complexity is much better. Depth limited search does not work here since it is essentially BFS. Iterative deepening is not necessary either (solutions at fixed depth).
- Logic [30] Here are some sentences in first order logic that encode knowledge about the “kinship do- main”. 1. Father(X, Y ) → Parent(X, Y ) 2. Mother(Z, W ) → Parent(Z, W ) 3. Wife(A, B) → Married(A, B) 4. Husband(C, D) → Married(C, D) 5. Married(E, F ) ∧ Parent(F, G) → Parent(E, G) 6. Sister(I, J) ∧ Parent(J, K) → Aunt(I, K) 7. Brother(L, M ) ∧ Parent(M, N ) → Uncle(L, N )
As usual, the convention these two arguments predicates follow is: Father(X, Y ) means “X is the father of Y ”, Wife(X, Y ) means “X is the wife of Y ”, etc. Also, the universal quantifier for all the variables used in a sentence is implicit (i.e. Father(X, Y ) → Parent(X, Y ) is actually ∀X, Y Father(X, Y ) → Parent(X, Y )).
- Write additional sentences in Horn normal form for this knowledge base to add defini- tions for the following new predicates. Use only the predicates introduced above and the ones that you will write below. Make your sentences as general as possible! a. [5] Sibling(X, Y ): X is the sibling of Y.
b. [5] Grandparent(X, Y ): X is the grandparent of Y.
- [20] Using the original knowledge base (sentences 1-7), use the forward chaining to add the following sentences: - Father(homer,lisa) - Mother(marge,bart) - Wife(marge,homer) - Sister(patty,marge) Use the chart below to show each step of forward chaining. You should only show the successful attempts at matching rules. As an example of how you would fill out the chart for this problem, here is how you would start forward chaining on the sentence: Husband(bob,alice): sentence Term added to KB, or matches with premise(s) to match number premise sought sentence# substitution conclusion produced 8 Husband(bob,alice) 4 C=bob, D=alice Maried(bob,alice) Each fact is added one-by-one and all the conclusions that are possible to derive with the new facts are produced rightaway. Remember that forward chaining is data-driven so all the consequences are derived without any goal in mind.
sentence Term added to KB, or matches with premise(s) to match number premise sought sentence# substitution conclusion produced 8 Father(homer,lisa) 1 X=homer,Y=lisa Parent(homer,lisa) 9 Mother(marge,bart) 2 Z=marge,W=bart Parent(marge,bart) 10 Wife(marge,homer) 3 A=marge,B=homer Married(marge,homer) 11 5 E=marge,F=homer,G=lisa Parent(marge,lisa) 12 Sister(patty, marge) 6 I=patty, J=marge, K=bart Aunt(patty,bart) 13 Sister(patty, marge) 6 I=patty, J=marge, K=lisa Aunt(patty,lisa)
Thus, 6 new conclusions can be drawn from the KB.
- Prolog mystery predicate [25] Consider the following mystery predicate:
p([],[]). p([A|B],C) :- p(B,D), append(D,[A],C).
where append has the usual definition.
- Describe what would happen for each of the following queries in terms of the kinds of errors that would result or the solution(s) that would be found (you have to specify the errors at a conceptual level, not the exact error message SWI Prolog would return). If more than one solution would be found, characterize them all. a. [10] p([a,b,c],X) Solution: i. At the first call of p([a,b,c],X), only p([A|B],C) can be matched with A=a, B=[b,c], C=X. To satisfy this definition of p, the predicate p([b,c],D) must first be satisfied. Once this predicate is satisfied, which will hopefully result in variable D getting bound to some list, append will put value a at the end of this list and unify the result with X, our answer. ii. Similarly, to satisfy p([b,c],D), unifications A1=b, B1=[c], C1=D are per- formed and the predicate p([c],D1) must be satisfied. After that b is appended at the end of D1 and the result unified with D. iii. To satisfy p([c],D1), first p([],D2) has to be satisfied. The only way to achieve this is to apply the first definition of p which produce the unification D2=[]. After that c is appended at the end of D2 and the result unified with D1. Then b is appended at the end of D1 so D2=[c,b]. Finally, a is appended at the end of D1 and the result is unified with X which gives the unification X=[c,b,a]. Since exactly one of the definitions of p matched at every stop, the only solution is X=[c,b,a].