Docsity

Introduction to Languages, Grammars, and Automata, Study notes of Design and Analysis of Algorithms

Partial preview of the text

Download Introduction to Languages, Grammars, and Automata and more Study notes Design and Analysis of Algorithms in PDF only on Docsity!

Three Basic Concepts

• Languages

• Grammars

• Automata

Languages

  • (^) Alphabet: a finite and nonempty set of symbols  = {a, b}
  • (^) String: finite sequence of symbols from  w = abaaa : empty string : the set of all strings on  (+^ = ^  {})

Languages

  • (^) Example 1:  = {a, b} *^ = {, a, b, aa, ab, ba, aaa, ...} L 1 = {a, aa, aab} (finite language) L 2 = {anbn^ | n  0} = {, ab, aabb, ...}

Languages

  • (^) Language concatenation: L 1 L 2 = {xy | xL 1 , yL 2 } Ln^ = L L ... L (n times) L^0 = {}

Languages

  • (^) Example 2: L = {anbn^ | n  0} L^2 = {anbnambm^ | n  0, m  0}

Languages

  • (^) Star-closure: L*^ = L^0  L^1  L^2 ...
  • (^) Positive closure: L+^ = L^1  L^2 ...

Grammars

  • (^) Formal grammar: G = (V, T, S, P) V: finite set of variables T: finite set of terminal symbols SV: start variable P: finite set of productions

Grammars

  • (^) Productions: x  y x(VT)+^ y(VT)*
  • (^) w = uxv derives z = uyv w  z w 1 *^ wn (w 1  w 2  ...  wn | w 1 = wn) w 1 +^ wn

Grammars

  • (^) Example 3: G = ({S}, {a, b}, S, P) P: S  aSb S   S  aSb  aaSbb  aabb aabb: sentence aaSbb: sentential form

Grammars

  • (^) Example 3: G = ({S}, {a, b}, S, P) P: S  aSb S  

Grammars

  • (^) Example 4: G 1 = ({A, S}, {a, b}, S, P 1 ) P 1 : S  aAb |  A  aAb | 

Grammars

  • (^) Example 4: G 1 = ({A, S}, {a, b}, S, P 1 ) P 1 : S  aAb |  A  aAb |  L(G 1 ) = {anbn^ | n  0} G and G 1 are equivalent

Grammars

  • (^) Example 5: G 2 = ({S}, {a, b}, S, P 2 ) P 2 : S  SS S   S  aSb S  bSa L(G 2 ) = {w | na(w) = nb(w)}

Automata

An abstract model of digital computer: Control unit Input file Output Storage