Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

1.

Wts. C∩R =D where D is a context free language

Let P be the PDA for C

Let X be the DFA for R

The intersection could be at most |C| or |R|

Any word in the intersection is already accepted by X, but not all words in C are accepted by
C ∩ R, only the words that also are accepted by X.

Take

C ∩ R → C ∩ (R ∪ C )

The size of this intersection is still no larger than |C| or |R|

Then by absorption laws

C ∩ (R ∪ C ) = C

So C = D

Then D is context free

To build any PDA for C ∩ R, just take the cross product of their tuples

4.

For an input w:

FORMAT CHECK

If char at q0 is ‘1’, replace with ’S’ and scan right until ‘<‘

Otherwise, reject w (a valid binary string starts with 0)

If a blank is encountered before ‘<‘, reject w (rejects empty string and strings missing ‘<‘)

Move right one cell, if the char is ‘1’, replace with ’S’

Otherwise reject w for same reason as above

Move one cell right

If a blank is ever encountered after this stage, reject the string.

(I sometimes put the step down anyways to be clear.

MAIN LOOP

If cell contains ‘0’, replace with ’S’ and jump to CANDIDATE

If cell contains ‘1’, replace with ’S’ and scan left until ’<’ appears

Scan left until ’S’ appears

Scan one cell right

If cell contains ‘1’, replace with ’S’ and scan right until ‘<‘ appears

If cell contains ‘0’, jump to ACCEPT

Scan right until ’S’ appears

Scan right until ‘1’ or ‘0’ or ‘_’ appears

If ‘_’ appears, jump, to sREJECT

If ‘1’ or ‘0’ appears, jump to MAIN LOOP

CANDIDATE

Scan left until ‘<‘

Scan left until ’S'

Scan one cell right

If cell contains ‘1’, jump to REJECT

If cell contains ‘0’, replace with ’S’, then scan right until ‘<‘, then scan until ‘1’ or
‘0’ appears, then jump to MAIN LOOP

sREJECT

Scan left until ‘<‘ appears

Scan one cell left

If ’S’ appears, jump to REJECT

If ‘1’ or ‘0’ appears, scan right until ‘0’, ‘1’, or ‘_’ appears

If ‘_’ appears, jump to REJECT

If ‘1’ or ‘0’ appears, jump to ACCEPT

ACCEPT

Accept string. (means LS < RS)

REJECT

Reject string (means LS > RS)

My Turing machine works by going back and forth, starting from the right binary, and
checking that the number (1 or 0) at each of the binary numbers’ indices are equal.

If the numbers, or number of indices are unequal, the Turing machine accepts or rejects
based on the appropriate case.

It does this using ’S’ to keep track of numbers that have been verified as equal, and
moving down the list.

If a ‘_’ or ‘<‘ appears, it means the strings are of unequal length and rejects or accepts
based on the case

5.


Create an isomorphism between single tape TM and DFA defined by (Q, , δ, q0,F)

Q<—> the cells on the tape


<—> the alphabet

q0 <—> the first cell (the head of the tape)

F <—> the symbol ‘$’, written outside the input portion, one cell after the first ‘_’

6. Create an isomorphism between a 2 stack PDA and a TM

If the PDA had only one stack, pushing and popping from the stack could be replicated
on the TM by (on a portion outside the input) either shifting each cell one to the left
(losing the first cell), or shifting one right, and ‘popping’ the input into the first cell.

If a PDA had two stacks, then the PDA could mimic pushing and popping in two
directions, like the TM, scans in two directions.

You could follow the arrows of the PDA (acting as the TM’s input), and use the two
stacks like the TM uses memory.

You might also like