Computer Science 313
Theory of Computation

Assignment 4 - Chapter 2 (continued)

Due Monday, 16 March

Extra Credit


You should also have an
accepts method, which takes a string and returns True if the DPDA accepts the string, and returns False otherwise. Acceptance takes place when the stack is empty and there is no more input, so you don't have to push and pop the $ symbol. Ideally, you should also have a __repr__ method (takes self and returns a string), so that printing out a DPDA object will result in a useful representation. For the transition function, you can have rules of the form p,a,b --> q,c, where p and q are states and a, b, and c are symbols. For the ε representing stack operations, you can use the symbol @. For example, a DPDA recognizing 0n1n might be represnted as follows:

Q: {q1, q2}
Sigma: {0, 1}
Gamma: {0}
S: q1
F: {q2}
  q1,0,@ --> q1,0
  q1,1,0 --> q2,@
  q2,1,0 --> q2,@

Put your code in a file along with some test cases and send it as an attachment. I should be able to run your tests by doing python