cs188 sp04 mt1 Sol
cs188 sp04 mt1 Sol
cs188 sp04 mt1 Sol
FUN ARGS) returns T if (FUN ARGS) terminates after some finite time and NIL otherwise. Turing showed that while such a function
is easy to describe, there is no way to compute it, that is, no agent program can implement the HALT function.
Here is an outline that gives some intuition as to why HALT cant be computed. Suppose HALT does exist, we can then define a
second lisp function (DEFUN PARADOX (S) (IF (HALT S S) (PARADOX S) T)). The function PARADOX returns if (S S) terminates
and goes into infinite recursion when (S S) doesnt terminate.
Now we ask ourselves, what does (HALT #PARADOX #PARADOX) return, T or NIL? Suppose it returns T, then the IF conditional
in PARADOX is true so PARADOX goes into infinite recursion. This means that PARADOX actually doesnt halt when fed itself as
input, contradicting our assumption that (HALT #PARADOX #PARADOX) returns T. Suppose instead that (HALT #PARADOX
#PARADOX) returns NIL, then PARADOX called on itself would terminate, returning T, so in fact HALT cant return T either. Since
PARADOX is a well defined function, it must be that HALT cannot exist.
1
3. (25) CSPs and local search
Consider the problem of placing k knights on an n n chessboard such that no two knights are attacking each
other, where k is given and k n2 .
(a) (5) Choose a CSP formulation. In your formulation, what are the variables?
Solution A: There is a variable corresponding to each of the n 2 positions on the board.
Solution B: There is a variable corresponding to each knight.
2
5. (18) Propositional logic
According to political pundits, a person who is radical (R) is electable (E) if he/she is conservative (C), but
otherwise is not electable.
(a) (12) Which of the following are correct representations of this assertion?
i. (R E) C
No, a conservative doesnt have to be radical.
ii. R (E C)
Yes, if a person is a radical then they are electable if and only if they are conservative.
iii. R ((C E) E)
No, this is equivalent to R C E E which is a tautology, true under any assignment.
We decided that this question did not deserve 12 points, so we gave 6 for free and 6 for the answers.
(b) (6) Which of the sentences in (a) can be expressed in Horn form?
(i) Yes
(R E) C ((R E) C) (C (R E))
((R E) C) (C R) (C E)
(ii) Yes
R (E C) R ((E C) (C E))
R ((E C) (C E))
(R E C) (R C E))
(i) is a correct translation; as stated in class, there is no need to require (x = y) because we know that no
country is adjacent to itself.
(ii) is also a correct translation, but the (x = y) is unnecessary.
(iii) is incorrect, it asserts that all x are countries (as well as some other things).
(iv) is syntactically malformed.
(b) (6) Which of the following are valid sentences?
i. (x x = x) (y z y = z).
Valid. The premise is true for any model in which there is an object. (In lecture, it was stressed that this
is always the clase for FOL, but we put it in as a premise just in case.) Since there is an object in the
model, then for every y we can find a z (namely, the object referred to by y) that is the same as y.
ii. x P (x) P (x).
Valid. For any given x, P (x) P (x) is a propositional tautology.
iii. x Smart(x) (x = x).
Valid. For every x, x = x is true, so the disjunction is true.