Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Theory of Digital Computation Course material for undergraduate students on IT Department of Computer Science University of Veszprem Veszprem, Hungary.

Similar presentations


Presentation on theme: "1 Theory of Digital Computation Course material for undergraduate students on IT Department of Computer Science University of Veszprem Veszprem, Hungary."— Presentation transcript:

1 1 Theory of Digital Computation Course material for undergraduate students on IT Department of Computer Science University of Veszprem Veszprem, Hungary 2002

2 2 Navigation Tools Navigation buttons at the bottom of each page make easy to jump to:  Previous page  Previous chapter  Table of Contents  Next chapter  Next page The title of the chapter is shown above the title of the page. Véges automatákNavigation

3 3 Table of Contents Alphabets and Languages Finite Automata Context-free Languages Turing Machines Universal Turing Machines Examples Problems Table of Contents

4 4 Alphabets and Languages Alphabet is a finite set of symbols. A string over an alphabet is a finite sequence of symbols from the alphabet. A string may have no symbols at all  in this case it is called the empty string and is denoted by e. The length of a string w,  w , is its length as a sequence. Alphabets and Languages

5 5 Two strings over the same alphabet can be combined to form a third by the operation concatenation. The concatenation of strings x and y, written x  y or simply xy, is the string x followed by the string y: w(j) = x(j) for j = 1,...,  x  w(  x  + j) = y(j) for j = 1,...,  y  If w = x  y then  w  =  x  +  y . Alphabets and Languages

6 6 A string v is a substring of w iff there are strings x and y such that w = xvy. The reversal of a string w, denoted by w R, is the string “spelling backwards”: If  w  = 0, then w R = w = e. If  w  = n+1 (>0), then w = ua for some a , and w R = au R. Any set of string over an alphabet is called language. Alphabets and Languages

7 7 Closure or Kleene star is a language operation of a single language L, denoted by L *. L * is the set of all strings obtained by concatenating zero or more strings from L. Alphabets and Languages

8 8 Definition A string over alphabet  (, ), Ø, , *} is a regular expression over alphabet  if it satisfies the following conditions. (1) Ø and each element of  is a regular expression (2) If  and  are regular expressions then so is (  ) (3) If  and  are regular expressions then so is (  ) (4) If  is a regular expression, then so is  *. (5) Nothing is a regular expression unless it follows from (1) through (4). Alphabets and Languages

9 9 Every regular expression represents a language. Formally, the relation between regular expressions and the corresponding languages is established by function L, where L(  ) is the language represented by regular expression . Thus, L is a function from strings to languages. Alphabets and Languages

10 10 Function L is defined as follows. (1)L(Ø) = Ø and L(  ) =  a  for each  = a   (2)If  and  are regular expressions, then L( (  ) ) = L(  )L(  ). (3)If  and  are regular expressions, then L( (  ) ) = L(  )  L(  ). (4)If  is a regular expression then L(  * ) = L(  )*. Alphabets and Languages

11 11 Finite Automata Definition Deterministic finite automaton (DFA) is a quintuple M = (K, , , s, F) where K is the set of states (finite set),  is an alphabet, s  K is the initial state, F is the set of final states (F  K), and , the transition function, is a function from K  to K.

12 12 Graphical representation of a DFA: state diagram  state p: -initial state q: -final state r:  transition  (p, b) = q: Finite Automata

13 13 A configuration of a DFA is determined by the current state and the unread part of input. In other words, a configuration of a deterministic finite automaton (K, , , s, F) is an element of K  *. If (q, w) and (q’, w’) are two configurations of M, then (q, w) ├─ M (q’, w’) iff w =  w’ for some symbol   , and  (q,  ) = q’. In this case, we say that configuration (q, w) yields configuration (q’, w’) in one step. Finite Automata

14 14 We denote the reflexive, transitive closure of ├─ M by ├─ M *; (q, w) ├─ M * (q’, w’) is read, configuration (q, w) yields configuration (q’, w’). A string w   * is said to be accepted by M iff there is a state q  F such that (s, w) ├─ M * (q, e ). The language accepted by M, L(M), is the set of all strings accepted by M. Finite Automata

15 15 Definition Non-deterministic finite automaton (NFA) is a quintuple M = (K, , , s, F) where K is the set of states (finite),  is an alphabet, s  K is the initial state, F is the set of final states (F  K),and , the transition relation, is a finite subset of K×  *×K. Finite Automata

16 16 Graphical representation of a NFA: state diagram  state p: -initial state q: -final state r:  transition (p, ba,q)   : Finite Automata

17 17 A configuration of M is an element of K×  *. The relation ├─ M (yields in one step) between configurations is defined as follows: (q, w) ├─ M (q’, w’) iff there is a u   * such that w = uw’ and (q, u, q’)  . ├─ M * is the reflexive, transitive closure of ├─ M. w   * is accepted by M iff there is a state q  F such that (s, w)├─ M *(q, e ). The language accepted by M, L(M), is the set of all strings accepted by M. Finite Automata

18 18 Definition Finite automata M 1, and M 2 are said to be equivalent iff L(M 1 ) = L(M 2 ). Theorem For each non-deterministic finite automaton, there is an equivalent deterministic finite automaton. (No proof here) Finite Automata

19 19 Theorem Languages accepted by finite automata are closed under union.  Proof: Let NFA M 1 = (K 1, ,  1, s 1, F 1 ) and M 2 = (K 2, ,  2, s 2, F 2 ). NFA M = (K, , , s, F) will be given such that L(M) = L(M 1 )  L(M 2 ). s is a new state not in K 1  K 2, K = K 1  K 2  s ,( K 1 and K 2 are disjoint.) F = F 1  F 2, and  =  1  2  (s, e, s 1 ), (s, e, s 2 ) . Finite Automata

20 20 Theorem Languages accepted by finite automata are closed under concatenation.  Proof: L(M) = L(M 1 ) ○ L(M 2 ) Construct a NFA M = (K, , , s, F), where K = K 1  K 2 ( K 1 and K 2 are disjoint.) s = s 1 F = F 2  =  1  2  (F 1  { e }  {s 2 }). Finite Automata

21 21 Theorem Languages accepted by finite automata are closed under Kleen-star.  Proof: L(M) = L(M 1 )* Construct a NFA M = (K, , , s, F), where K = K 1  s  s is a new state not in K 1 F = F 1  s   =  1  (F  { e }  {s 1 }) Finite Automata

22 22 Theorem Languages accepted by finite automata are closed under complementation.  Proof: L(M) = L(M 1 ) Construct a DFA M = (K, , , s, F) K = K 1 s = s 1 F = K 1 - F 1  =  1 Finite Automata

23 23 Theorem Languages accepted by finite automata are closed under intersection.  Proof: L(M) = L(M 1 )  L(M 2 ) Construct a DFA M L(M) =  * - ((  * - L(M 1 ))  (  * - L(M 2 ))). Note: L(M 1 )  L(M 2 ) = L(M 1 )  L(M 2 ) Finite Automata

24 24 Theorem There is an algorithm for answering the following question: Given a finite automaton M, is L(M) =  * ?  Proof: -Tracing the state diagram can answer the question wheather L(M’) = . -L(M) =  * iff L(M) = . -L(M’) = L(M). Finite Automata

25 25 Theorem There is an algorithm for answering the following question: Given two finite automata M 1 and M 2, is L(M 1 )  L(M 2 )?  Proof: L(M 1 )  L(M 2 ) iff (  *-L(M 2 ))  L(M 1 ) = . Finite Automata

26 26 Theorem There is an algorithm for answering the following question: Given two finite automata M 1 and M 2, is L(M 1 ) = L(M 2 ) ?  Proof: L(M 1 ) = L(M 2 ) iff (L(M 1 )  L(M 2 ) and L(M 2 )  L(M 1 )). Finite Automata

27 27 Context-free Languages Definition A context-free grammar (CFG) G is a quadruple (V, , R, S), where V is an alphabet,  (the set of terminals) is a subset of V, R (the set of rules) is a finite subset of (V-  )  V*, and S (the start symbol) is an element of V- . The members of V-  are called non-terminals.

28 28 For A  V-  and u  V *, A  G u if (A, u)  R. For any strings u, v  V *, u  G v if there are strings x, y, v’  V * and A  V-  such that u = xAy, v = xv’y and A  G v’. Relation  G * is the reflexive, transitive closure of  G. Language generated by G, is L(G) = {w   *: S  G * w}; we also say that G generates each string in L(G). Context-free Languages

29 29 Definition A language L is a context-free language if it is equal to L(G) for some context-free grammar G. Definition A context-free grammar G = (V, , R, S) is regular iff R  (V-  )   *((V-  )  e ). Context-free Languages

30 30 Theorem Context-free languages are closed under union.  Proof: Let G 1 = (V 1,  1, R 1, S 1 ) and G 2 = (V 2,  2, R 2, S 2 ) context-free grammars, V 1 -  1 and V 2 -  2 disjoint. CF grammar G = (V, , R, S) will be given such that L(G) = L(G 1 )  L(G 2 ) V = V 1  V 2  {S}  =  1   2 R = R 1  R 2  {S  S 1, S  S 2 } S = a new symbol not in V 1  V 2. Context-free Languages

31 31 Theorem Context-free languages are closed under concatenation.  Proof: L(G) = L(G 1 )  L(G 2 ) Construct CF grammar G = (V, , R, S) V = V 1  V 2  {S} ( V 1 -  1 and V 2 -  2 are disjoint.)  =  1   2 R = R 1  R 2  {S  S 1 S 2 } S = a new symbol not in V 1  V 2. Context-free Languages

32 32 Theorem Context-free languages are closed under Kleen-star.  Proof: L(G) = L(G 1 )* Construct CF grammar G = (V, , R, S) V = V 1  =  1 R = R 1  {S 1  e, S 1  S 1 S 1 } S = S 1 Context-free Languages

33 33 Definition A pushdown automaton (PDA) is a sixtuple M = (K, , , , s, F), where K is a finite set of states,  is an alphabet (the input symbols),  is an alphabet (the stack symbols), s is the initial state (s  K), F is the set of final states (F  K), and  is the transition relation, is a finite subset of (K  *  *)  (K  *). Context-free Languages

34 34 Graphical representation of a NFA: state diagram  state p: -initial state q: -final state r:  transition (p, ba, cd, q, dc)   : Context-free Languages

35 35 Intuitively, if ((p, u,  ), (q,  ))  , then M, whenever it is in state p with  at the top of the stack, may read u from the input tape,  replaced by  on the top of the stack, and enter state q. ((p, u,  ), (q,  )) is called a transition of M. To “push” a symbol is to add it to the top of the stack, to “pop” a symbol is to remove it form the top of the stack. A configuration is defined to be an element of K  *  *: The first component is the state of the machine, the second is the partition of the input yet to be read, and the third is the content of the pushdown store. Context-free Languages

36 36 For every transition ((p, u,  ),(q,  ))  , and for every x   * and    *, we define (p, ux,  ) ├─ M (q, x,  )), moreover, ├─ M (yields in one step) holds only between configurations that can be represented in this form for some transition, some x, and some . The reflexive, transitive closure of ├─ M is denoted by ├─ M *. We say that M accepts a string w   * iff (s, w, e ) ├─ M * (p, e, e ) for some p  F. Language accepted by M, L(M), is the set of all strings accepted by M. Context-free Languages

37 37 Turing Machines Definition A Turing machine is a quadruple (K, , , s) where K:is a finite set of states, not containing the halt state h; (h  K),  : is an alphabet, containing the blank symbol #, but not containing the symbols L and R; s: is the initial state;  : is a function from K  to (K  {h})  (   {L, R}). Configuration of a Turing machine M = (K, , ,s) is an element of (K  {h})  *   (  *(  -{#})  { e }).

38 38 Let (q 1, w 1, a 1, u 1 ) and (q 2, w 2, a 2, u 2 ) be configurations of Turing machine M. Then (q 1, w 1, a 1, u 1 ) ├─ M (q 2,w 2, a 2, u 2 ) iff for some b    {L, R},  (q 1, a 1 ) = (q 2, b) and either (1)b  , w 1 = w 2, u 1 = u 2, and a 2 = b; or (2)b = L, w 1 = w 2 a 2, and either (a) u 2 = a 1 u 1, if (a 1  # or u 1  e ), or (b) u 2 = e, if a 1 = # and u 1 = e ; or (3)b = R, w 2 = w 1 a 1 and either (a) u 1 = a 2 u 2, or (b) u 1 = u 2 = e and a 2 = #. Turing Machines

39 39 For any Turing machine M, relation ├─ M * is the reflexive, transitive closure of relation ├─ M ; We say configuration C 1 yields configuration C 2 if C 1 ├─* M C 2. A computation by M is a sequence of configurations C 0, C 1, C 2,..., C n (n  0) such that C 0 ├─ M C 1 ├─ M C 2 ├─ M … ├─ M C n. Turing Machines

40 40 Definition Let f be a function from  0 * to  1 *. Turing machine M = (K, , , s), where  0,  1  , computes f if w   0 * and f(w) = u, then (s, #w, #, e ) ├─ M * (h, #u, #, e ). If such a Turing machine exists, the function is called Turing computable. Turing Machines

41 41 Let  0 an alphabet not containing the blank symbol. Let Y and N be two fixed symbols not in  0. Then, language L   0 * is Turing decidable iff function x L :  0 *  { Y, N } is Turing computable, where for each w   0 *, x L (w) = Y if w  L N if w  L Turing Machines {

42 42 Let  0 be an alphabet not containing #. M accepts string w   0 * if M halts on input w. Thus, M accepts language L   0 * iff L = {w   0 *: M accepts w}. Definition A language is Turing acceptable if there is some Turing machine that accepts it. Turing Machines

43 43 Symbol writing Turing machines For alphabet  and symbol a  , let Turing machine a = (K, , , s) = ({p}, , {(p, b, h, a): for any b   }, p) Head moving Turing machines For alphabet , let Turing machine L be defined as L = (K, , , s) = ({p}, , {(p, b, h, L): for any b   }, p), and let Turing machine R be defined as R = (K, , , s) = ({p}, , {(p, b, h, R): for any b   }, p). Turing Machines

44 44 Definition A machine schema is a triplet (m,  M 0 ) where mis a finite set of Turing machines with common alphabet  and disjoint sets of states; M 0  m is the initial machine; and  is a function from subset of m  to m. Turing Machines

45 45 Let m  = {M 0, M 1, …, M m } (m≥0), where M i = (K i, ,  i, s i ) for i = 0, 1, …, m. Let q 0, q 1, …, q m be new states not in any of the K i. Then machine schema (m,  M 0 ) is defined asTuring machine M, where M = (K, , , s) K = K 0 ...  K m  {q 0, q 2, …, q m }, s = s 0, and  is defined as follows. Turing Machines

46 46 Definition of  (a)if q  K i (0 ≤ i ≤ m), a ,  i (q, a) = (p, b), and p  h, then  (q, a) =  i (q, a) = (p, b); (b)if q  K i (0 ≤ i ≤ m), a  , and  i (q, a) = (h, b) then  (q, a) = (q i, b); (c)if a   and  (M i, a) (0 ≤ i ≤ m) is not defined, then  (q, a) = (h, a); (d)if a   and  (M i, a) = M j (0 ≤ i ≤ m) and  j (s j, a) = (p, b), then  (q i, a) = (p, b) if p  h and (q j, b) if p = h. Turing Machines

47 47 Theorem Every Turing decidable language is Turing acceptable.  Proof: Theorem If L Turing decidable language, then it’s complement L is also Turing-decidable.  Proof: Turing Machines

48 48 A language is Turing-decidable if and only if both it and its complement are Turing acceptable.  Proof: (only if) L is a Turing decidable  L is also Turing decidable. L, L is Turing decidable  L, L is Turing acceptable. (if) 2-tape machine: M 1 accepts L, M 2 accepts L. Parallel simulation: Which halts? Turing Machines

49 49 Universal Turing Machines The only feature possessed by electronic computers that missing from the capability of Turing machines is the programmability. Difficulties:  The alphabet of any Turing machine must be finite.  The set of states of any Turing machine must be finite. Universal Turing Machines

50 50 Hints:  Assume that there are fixed countably infinite sets K  = {q 1, q 2, q 3,...}, and   = {a 1, a 2, a 3,...} such that for every Turing machine, the set of states is a subset of K  and the alphabet is a subset of  . Universal Turing Machines

51 51  Encode the alphabet and states of the Turing machine as  (  ) qiqi I i+1 hI LI RII aiai I i+2 Universal Turing Machines

52 52  Encode the Turing machine M over the alphabet {c, I}. p(M) = cS 0 cS 11 S 12... S 1l S 21 S 22... S k1... S kl c S 0 encodes the initial state, S 0 = (s). S pr encodes the values of the transition function, S pr = cw 1 cw 2 cw 3 cw 4, where w 1 = (q i p ), w 2 = (q j r ), w 3 = (q’), w 4 = (b) for each  (q i p, q j r ) = (q’, b). Universal Turing Machines

53 53  The symbols on the tape must also be in encoded form. p(w) = c (b 1 )c (b 2 )c... c (b n )c for each w = b 1 b 2... b n. Universal Turing Machines

54 54  Universal Turing machine U simulates Turing machine M on a three tape Turing machine. Tape 1: encoding of the tape of Turing machine M. Tape 2: encoding of Turing machine M (i.e., it is the “program”). Tape 3: encoding of the current state of Turing machine M during the simulation. Universal Turing Machines

55 55 Examples Symbol Every character is a symbol, e. g., a, b, and c, etc. Alphabet  = {a, b, c} is an alphabet. String cab, abaca, a, and the empty string e are strings over the alphabet  = {a, b, c}. Length of a string  cab  = 3,  abaca  = 5,  a  = 1, and  e  =0. Alphabets and Languages

56 56 Examples Concatenation of strings Strings cab and abaca can be concatenated to form string cababaca.  Formally: cab  abaca = cababaca Alphabets and Languages

57 57 Examples Substring Strings e, a, b, c, ab, ba, ac, ca, aba, bac, aca, abac, baca, and abaca are the substrings of the string abaca. Reversal of a string e R = e a R = a ab R = ba bac R = cab abaca R = acaba Alphabets and Languages

58 58 Examples Language Set L = { e, a, cab, abaca} is a language over the alphabet  = {a, b, c}. Thus, language L is a subset of  * = { e, a, b, c, aa, ab, ac, ba, bb, bc, ca, cb, cc, aaa, aab, aab, aba, …}. Alphabets and Languages

59 59 Examples Language operation Kleene star Closure or Kleene star of language L = {a, cab, abaca} the language L* = { e, a, cab, abaca, a  a, a  cab, a  abaca, cab  a, cab  cab, cab  abaca, …, abaca  a  a, abaca  a  cab, …} = { e, a, cab, abaca, aa, acab, aabaca, caba, cabcab, cababaca, …, abacaaa, abacaacab, …} Alphabets and Languages

60 60 Examples Regular expressions Expressions Ø, a, b, (ab), ((ab)a), (a  b), (a  (ab)), ((ab)  ((ab)a)), ((a  b)  c), ((a  b)a), ((a  b)(a  b)), a*, (ab)*, (a  b)*, (a*b), (a*  b), ((ab)*  ((ab*)a)), and ((a  b)*  c*) are regular expressions over the alphabet  = {a, b, c}. Alphabets and Languages

61 61 Examples Language represented by regular expression L(((a  b)c)*) = ? L(a) = {a}; L(b) = {b}; L(c) = {c}; L((a  b)) = L(a)  L(b) = {a}  {b} = {a, b}; L(((a  b)c)) = L((a  b))L(c) = {a, b} {c} = {ac, bc}; L(((a  b)c)*) = L(((a  b)c))* = {ac, bc}* = { e, ac, bc, acac, acbc, bcac, bcbc, acacac, acacbc, acbcac, …, acbcacbcac, acbcacbcbc, … } Alphabets and Languages

62 62 Examples Deterministic finite automaton M 1 = (K, , , s, F) = (K= {p, q},  = {a, b},  = {(p, a, p), (p, b, q), (q, a, q), (q, b, p)}, s = p, F = {q}) Finite Automata

63 63 Examples Graphical representation of DFA M 1 = (K= {p, q},  = {a, b},  = {(p, a, p), (p, b, q), (q, a, q), (q, b, p)}, s = p, F = {q}) is the state diagram: Finite Automata

64 64 Examples Configuration of DFA M 1 is: (p, babaa) Finite Automata

65 65 Examples Yields in one step (p, babaa)├─ M (q, abaa) Finite Automata

66 66 Examples Yields (p, babaa)├─ M *(p, aa) Finite Automata

67 67 Examples String accepted by DFA M 1 : abbba (p, abbba)├─ M *(q, e ) Finite Automata

68 68 Examples Language accepted by DFA M 1 = (K= {p, q},  = {a, b},  = {(p, a, p), (p, b, q), (q, a, q), (q, b, p)}, s = p, F = {q}) L(M 1 ) = {w  {a, b}*: the number of b’s in w is odd} Finite Automata

69 69 Examples Graphical representation of NFA M 2 = (K= {p, q},  = {a, b},  = {(p, ab, q), (p, e, q), (q, ba, q)}, s = p, F = {q}) is the state diagram: Finite Automata

70 70 Examples Language accepted by NFA M 2 = (K= {p, q},  = {a, b},  = {(p, ab, q), (p, e, q), (q, ba, q)}, s = p, F = {q}) is L(M 2 ) = L( ((ab)  e )(ba)*) ). Finite Automata

71 71 Examples For context-free grammar G =(V = {a, b, A, B, S},  = {a, b}, R = {(S, aSb), (S, e) }, S) we can write  S  aSb, S  e  S  aSb  aaSbb  aaaSbbb  aaabbb  S  * aaSbb  * aaabbb, and S  * aaabbb Context-free Languages

72 72 Examples Language generated by CFG G =(V = {a, b, A, B, S},  = {a, b}, R = {(S, aSb), (S, e) }, S) is L(G) = {a n b n : n  0}. Context-free Languages

73 73 Examples Graphical representation of PDA M 3 = (K= {p, q},  = {a, b},  = {c},  = {(p, a, e, p, c), (p, e, q), (q, b, c, q, e )}, s = p, F = {q}) is the state diagram: Context-free Languages

74 74 Examples Language accepted by PDA M 3 = (K= {p, q},  = {a, b},  = {c},  = {(p, a, e, p, c), (p, e, q), (q, b, c, q, e )}, s = p, F = {q}) is L(M 2 ) = {a n b n : n  0}. Context-free Languages

75 75 Examples Turing machine represented by the following machine schema operates as follows: (s, #w, #, e ) ├─ M * (h, #u, #, e ), where w  {a, b}* and u is derived from w by replacing each a in w to b and each b in w to a. Turing Machines

76 76 Problems Alphabets and Languages  Which strings are the elements of the following languages? -{w: for some u  {a, b}{a, b}, w = uu R u} -{w: ww = www} -{w: for some u, wuw = uwu} -{w: for some u, www = uu}

77 77 Problems  Is it true or false? -baa  {a}*{b}*{a}*{b}* -{b}*{a}*  {a}*{b}* = {a}*  {b}* -{a}*{b}*  {c}*{d}* =  -abcd  ({a} ({c}{d})* {b})*

78 78 Problems  Write regular expression R with -L(R) = {w  {a, b}*: there is at most three a's in w} -L(R) = {w  {a, b}*: there is no ab substring in w} -L(R) = {w  {a, b}*: w has exactly one aaa substring} -L(R) = {w  {a, b}*: in w every a is preceded and followed by a b} -L(R) = {w  {a, b, c}*: in w there is no aa, bb, cc substring in w}

79 79 Problems Finite Automata  Draw state diagram of DFA M with -L(M) = {w  {a, b}*: in w the number of a's is even and the number of b's is odd} -L(M) = {w  {a}*: in w the number of a's is even, but not divisible by 4} -L(M) = {w  {a}*: in w the number of a's is either even or divisible by 3} -L(M) = {w  {a}*: in w the number of a's is divisible by 3}

80 80 Problems  Draw state diagram of NFA M with L(M) = L(R) where -R = (a*b*)*(a  b) -R = (ab  a)*  (aa  b)* -R = ( (a*  b*)(ab) )* -R = ((a  b)(a  b))* -R = (a  b*)(a*  b)

81 81 Problems Context-free Languages  Which words can be derived in at most four steps in G = (V, , R, S) from S? V = {a, b, A, B, S},  = {a, b}, and -R = {S  A, S  abA, S  aB, A  Sa, B  b} -R = {S  A, S  abA, S  aB, A  a, B  Sb} -R = {S  ABS, A  aA, B  bB, S  e, A  a, B  b} -R = {S  aSB, S  bSA, S  a, S  b, A  aS, B  bS}

82 82 Problems  Give a CF grammar G with -L(G) = {w  {a, b}*: in w the number of b's is even} -L(G) = {a n b m a n : n, m > 0} -L(G) = {a n cb n c: n  0} -L(G) = {b n a n : n  0}  {a 3n b n : n  0} -L(G) = {a m b n c p d r : m+n = p+r}

83 83 Problems  Give a pushdown automaton M with -L(M) = {w  {a, b}*: in w the number of a's is larger than the number of b's} -L(M) = {w  {a, b}*: w = w R } -L(M) = {w  {a, b}*: in w the number of b's is odd} -  = {a, +, *, (, )} L(M) = {syntactically correct arithmetic expressions involving + and * over the variable a} -L(M) = {a m b n c p : m = n or m = p or n = p} -L(M) = {a m b n c n d m : m, n > 0}

84 84 Problems Turing machines  Give a Turing machine which decides language L -L = {w  {a, b}*: in w the number of a's is the double of the number of b's} -L = {w  {a, b}*: in w the number of a's is larger than the number of b's} -L = {w  {a, b}*: in w the number of b's is even} -L = {w  {a, b}*: w = w R } -L = {a n b n c n : n > 0}


Download ppt "1 Theory of Digital Computation Course material for undergraduate students on IT Department of Computer Science University of Veszprem Veszprem, Hungary."

Similar presentations


Ads by Google