Today:
Prolog.
Homework 6 solutions: pda.py
For next time:
Reading questions below.
Start Homework 8.
Prepare for a quiz.
1) Review member, takeout/putin and append from Lecture 13.
Add the following rules to a file named list.pl, and run some queries to test them.
takeout(X,[X|R],R).
takeout(X,[F|R],[F|S]) :- takeout(X,R,S).
putin(X, A, B) :- takeout(X, B, A).
2) Here is a set of rules that defines perm such that perm(A,B) is true if B is a permutation of the elements in A. Type them in and test them.
perm([X|Y],Z) :- perm(Y,W), putin(X,W,Z).
perm([],[]).
3) Write a set of rules for cross so that cross(X,Y,Z) is true if Z is an element of the Cartesian product of sets X and Y.
4) It is often easy to enumerate the elements of a set; for example, cross enumerates the elements of the Cartesian product of two sets.
As an alternative, you might want to generate the entire set as a list of tuples.
Write a set of rules for cross_set so that cross_set(X,Y,Z) is true if Z is the Cartesian product of X and Y, represented as a set of pairs (which is to say, a list of lists). Hint: See findall.
Sipser, pages 165-178
1) Why should we study unsolvability?
2) On page 166, what do the angle brackets mean? What type are the elements of A_DFA?
3) What algorithm is used to demonstrate the decidability of the language in Theorem 4.4?
4) What algorithm is used to demonstrate the decidability of the language in Theorem 4.8?
5) Why does the proof that EQ_DFA is decidable fail to prove that EQ_CFG is decidable?
6) In the discussion of theorem 4.9, the issue of non-halting branches in a non-deterministic PDA should be familiar. Why?
7) What is the relationship between Theorem 4.7 and Theorem 4.9?
8) How do you show that a set is countable? How do you show that it's not?
9) Which of the following sets are countable?
a) integers
b) rational numbers
c) pairs of integers
d) k-tuples of integers
e) real numbers
f) strings
g) infinite binary sequences
h) languages
i) Turing machines