ATC_MODULE 4&MODULE5 internal solutions




1) a. If L1 and L2 are context free languages then show that L1 U L2, L1 - L2, L1 L2 are closed or not.
i)                    L1 U L2  
If L1 and L2 are context free languages then there exists a context-free grammar  G1 = (V11, R1,S1) and G2 = (V22,R2,S2) such that L1=L(G1) and L2=L(G2).
We will build a new grammar G such that L(G)=L(G1) U L(G2). G will contain all the rules of both G1 and G2.
 We add to G a new start symbol S and two new rules. S→S1 and S→S2. The two new rules allow G to generate a string iff at least one of G1or G2 generates it.
So, G = ( V1 U V2 U {S}, Σ1 U Σ2, R1 U R2 U {S→ S1,S→S2}, S )
Therefore, the context-free languages are closed under union
ii)                  L1 - L2
Given language L1 , L1=Σ*- L1 and L2 , L2=Σ*- L2
Σ* is context-free So, if the context-free languages were closed under difference, the complement of any CFL would necessarily be context-free But we just showed that is not so.
Therefore, L1 – L2 does not satisfies properties of context-free and the context-free languages are not closed under difference.

iii)                L1 L2
Let: L1={an bn cm | n, m ≥ 0} L2={am bn cn | n, m ≥ 0} Both L1and L2 are context-free since there exist straight forward CFGs for them.
But now consider: L =L1∩L2 ={an bn cn | n, m ≥ 0}. If the context-free languages were closure under intersection. L would have to be context-free. But we have proved that L is not CFG by using pumping lemma for CFLs.
Therefore, the context-free languages are not closed under intersection.

1) b. Define Pumping Theorem in CFL. Show that an bn cn is not context free.
Statement: If L is CFL, then: k ≥ 1 (strings w L, where |w| ≥ k (u,v,x,y,z (w=uvxyz, vy ≠ Ɛ, |vxy| ≤ k and q ≥ 0 (u v qx yq z is in L)))).
L = { an bn cn  | n>=0} is Not Context-Free.
Solution: If L is CFL then there would exist some k such that any string w, where |w|>=k must satisfy the conditions of the theorem.
Let w = akbkck, where ‘k’ is the constant from the Pumping lemma theorem. For w to satisfy
the conditions of the Pumping Theorem there must be some u,v,x,y and z, such that w=uvxyz, vy≠Ɛ, |vxy|≤k and q ≥ 0 , uvqxyqz is in L.
w = aaa…aaabbb…bbbccc…ccc, select v=aabbb & y=ccc:
Let q=2, then v2 and y2 will result following in w
w=aaa…aaabbaabb b..bbccccc…ccc
The resulting string will have letters out of order and thus not in L.
So L is not context-free.

2) a. Explain Turing Machine Model.
The Turing machine can be thought of as finite control connected to a R/W (read/write) head. It has one tape which is divided into a number of cells. The block diagram of the basic model for the Turing machine is given in Fig.
Turing machine model
 


Each cell can store only one symbol. The input to and the output from the finite state automaton are affected by the R/W head which can examine one cell at a time. In one move, the machine examines the present symbol under the R/W head on the tape and the present state of an automaton to determine:
(i) A new symbol to be written on the tape in the cell under the R/W head,
(ii) A motion of the R/W head along the tape: either the head moves one cell left (L), or one cell right (R).
(iii) The next state of the automaton, and
(iv) whether to halt or not.
Definition: Turing machine M is a 7-tuple, namely (Q, Σ, Г, ẟ, q0, b, F), where
1. Q is a finite nonempty set of states.
2. Г is a finite nonempty set of tape symbols,
3. b Г is the blank.
4. Σ is a nonempty set of input symbols and is a subset of Г and b Σ.
5. ẟ is the transition function mapping (q, x) onto (q', y, D) where D denotes the direction of movement of R/W head; D=L or R according as the movement is to the left or right.
6. q0Q is the initial state, and
7. F Q is the set of final states.

2) b. Construct a Turing Machine for an bn cn : n>=1.


 
 
Part B
3. Write a short note on the following
            i. Multi Tape Turing Machine
            ii. Post Correspondence Problem
i.                    Multi Tape Turing Machine
A multi tape TM has a finite set Q of states, an initial state q0, a subset F of Q called the set of final states, a set P of tape symbols, a new symbol b, not in P called the blank symbol.
There are k tapes, each divided into cells. The first tape holds the input string w. Initially, all the other tapes hold the blank symbol.          
Initially the head of the first tape (input tape) is at the left end of the input w. All the other heads can be placed at any cell initially.
is a partial function from Q x Гk  into Q x Гk  x {L, R, S}k. We use implementation description to define . Figure represents a multi tape TM. A move depends on the current state and k tape symbols under k tape heads.

Fig: Multi tape Turing Machine
In a typical move:
(i) M enters a new state.
(ii) On each tape, a new symbol is written in the cell under the head.
(iii) Each tape head moves to the left or right or remains stationary. The heads move         independently some move to the left, some to the right and the remaining heads do not move.
            The initial ID has the initial state q0, the input string w in the first tape (input tape), empty strings of b's in the remaining k - 1 tapes. An accepting ID has a final state, some strings in each of the k tapes. 



ii.                  Post Correspondence Problem
The Post Correspondence Problem (PCP) was first introduced by Emil Post in 1946. Later, the problem was found to have many applications in the theory of formal languages. The problem over an alphabet ∑ belongs to a class of yes/no problems and is stated as follows: Consider the two lists x = (x1  . . . xn), y = (y1 . . . yn) of nonempty strings over an alphabet ∑ = {0, 1}. The PCP is to determine whether or not there exist i1, . . . , im where 1 ≤  ij  ≤ n, such that
xi1  . . . xim = yi1 . . . yim
Note: The indices ij's need not be distinct and m may be greater than n. Also, if there exists a solution to PCP, there exist infinitely many solutions.

Example:
Does the PCP with two lists x = (b, bab3, ba) and y = (b3, ba, a) have a solution?
Solution:
We have to determine whether or not there exists a sequence of substrings of x such that the string formed by this sequence and the string formed by the sequence of corresponding substrings of yare identical. The required sequence is given by i1 =2,
i2 = 1, i3 = 1, i4 = 3, i.e. (2, 1, 1, 3), and m =4. The corresponding strings are


 
Thus PCP has a solution.
4. Write a short note on the following:
            i. Linear Bounded Automata
            ii. Halting Problem of TM
iii. Growth rate of function
i.                    Linear Bounded Automata (LBA)
LBA important because (a) the set of context-sensitive languages is accepted by the model, and (b) the infinite storage is restricted in size but not in accessibility to the storage in comparison with the Turing machine model. It is called the linear bounded automaton (LBA) because a linear function is used to restrict (to bound) the length of the tape.
      A linear bounded automaton is a nondeterministic Turing machine which has a single tape whose length is not infinite but bounded by a linear function of the length of the input string. The models can be described formally by the following set format:
M = (Q, ∑ , Г , , q0 , b , ₵ , $, F )
All the symbols have the same meaning as in the basic model of Turing machines with the difference that the input alphabet L contains two special symbols ₵ and $. ₵ is called the left-end marker which is entered in the leftmost cell of the input tape and prevents the R/W head from getting off the left end of the tape. $ is called the right-end marker which is entered in the rightmost cell of the input tape and prevents the R/W head from getting off the right end of the tape. Both the end markers should not appear on any other cell within the input tape, and the R/W head should not print any other symbol over both the end markers.
ii.                  Halting Problem of TM
Consider a problem A is reducible to problem B if a solution to problem B can be used to solve problem A.
For example, if A is the problem of finding some root of x4- 3x2 + 2 = 0 and B is the problem of finding some root of x2-2 = 0, then A is reducible to B. As x2-2 = 0 is a factor of x4- 3x2 + 2 = 0  a root of x2-2 = 0 is also a root of x4- 3x2 + 2 = 0.

Theorem:  HALTTM = {(M, w) | The Turing machine M halts on input w} is undecidable.
Proof:  We assume that HALTTM is decidable, and get a contradiction. Let M1 be the TM such that T(M1) = HALTTM and let M1 halt eventually on all (M, w). We construct a TM M2 as follows:
1. For M2, (M, w) is an input.
2. The TM M1 acts on (M, w).
3. If M1 rejects (M, w) then M2 rejects (M, w).
4. If M1 accepts (M, w), simulate the TM M on the input string w until M halts.
5. If M has accepted w, M2 accepts (M, w); otherwise M2 rejects (M, w).
    When M1 accepts (M, w) (in step 4), the Turing machine M  halts on w. In this case either an accepting state q or a state q' such that (q', a) is undefined till some symbol a in w is reached. In the first case (the first alternative of step 5) M2 accepts (M. w).
In the second case (the second alternative of step 5) M2 rejects (M, w).
It follows from the definition of M2 that M2 halts eventually.
Also, T(M2) = {(M, w) | The Turing machine accepts w}
  = ATM
This is a contradiction since ATM is undecidable.

iii.                Growth rate of function Definition with example
Definition: Let f, g : NR+ (R+ being the set of all positive real numbers). We say that f(n) = O(g(n)) if there exist positive integers C and N0 such that
f(n) ≤ Cg(n) for all nN0 .
In this case we say f is of the order of g (or f is 'big oh' of g)
Note: f(n) = O(g(n)) is not an equation. It expresses a relation between two functions f and g.
Example:
      Let f(n) = 4n3 + 5n2 + 7n + 3. Prove that f(n) = O(n3).
Solution:
      In order to prove that f(n) = O(n3) take C =5 and N0 = 10. Then
f(n) =4n3 + 5n2 + 7n + 3 ≤ 5n3       for    n ≥10
When n = 10, 5n2 + 7n + 3 =573 < 103.  For n > 10, 5n2 + 7n + 3 < n3
Then, f(n) = O(n3).


  • References:
  • Elaine Rich,  Automata, Computability and Complexity, 1st  Edition, Pearson Education,2012/2013
  • K L P Mishra, N Chandrasekaran , 3rd Edition, Theory of Computer Science, PhI, 2012.

Comments

Popular posts from this blog