1 / 16

Language Recognition

Language Recognition. MSU CSE 260. Outline. Introduction Regular Expressions & Regular Sets Kleene’s Theorem Regular Sets and Regular Grammars Examples More powerful Types of Machines Exercise 10.4. Introduction. The sets (languages) recognized by FAs are those formed from:

bettinas
Download Presentation

Language Recognition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Language Recognition MSU CSE 260

  2. Outline • Introduction • Regular Expressions & Regular Sets • Kleene’s Theorem • Regular Sets and Regular Grammars • Examples • More powerful Types of Machines • Exercise 10.4

  3. Introduction • The sets (languages) recognized by FAs are those formed from: • null (empty) set , • empty string (), and • singleton strings by taking (in arbitrary order): • concatenations, • unions, • Kleene Closures. • Regular languages

  4. Regular Expressions • Definition. The regular expressions over a set I are defined recursively by: • the symbol  is a regular expression; • the symbol  is a regular expression; • the symbol x is a regular expression whenever x  I. • the symbols (AB), (AB), and A* are regular expressions whenever A and B are regular expressions. Examples. The following are regular expressions over I={0,1}: 10*, (10)*, 001, 0(01)*, (0*1)* Note.AB is sometimes represented as A+B. Precedence rules: Kleene closure(*), concatenation, union

  5. Regular Sets • Each regular expression represents a (regular) set. Reg. Exp.Set represented  the empty set   the set {} xthe set {x} (AB) the concatenation of the sets represented by A and by B (AB) the union of the sets represented by A and by B A* the Kleene closure of the set represented by A Examples.10*: strings consisting of a 1 followed by any number of 0s (10)*: any arbitrary combinations of string 10 (including ) 0  01: the set consisting of the two strings 0 and 01 0(0  1)*: the set of strings which begin with 0

  6. Kleene’s Theorem • Kleene’s Theorem. A set is regular if and only if it is recognized by a finite-state automaton. Proof. The proof is done by construction of NFAs for sets represented by regular expressions.

  7. NFAs for Basic Regular Sets recognizes  Start s0 recognizes {} Start s0 a recognizes {a} Start s0 s1

  8. NFA for Concatenation • Let A be recognized by MA=(SA, I, fA, sA, FA), and B recognized by MB=(SB, I, fB, sB, FB) MAB f MA MB Start f i sA sB i • A transition to final state in MA produces a transition to sB. • A transition from sB in MB produces a transition from sAB=sA if sA is a final state. • Start state of MAB is sAB=sA, which is final if both sA and sBare final. • Final states of MAB include all final states of MB.

  9. NFA for Union • Let A be recognized by MA=(SA, I, fA, sA, FA), and B recognized by MB=(SB, I, fB, sB, FB) i MA i sA MAB Start sAB MB i sB i • Start state of MAB issAB, which is final if sA or sBis final. • Final states of MAB are the final states of MA and MB.

  10. NFA for Kleene Closure • Let A be recognized by MA=(SA, I, fA, sA, FA). i MA Start i MA* sA* sA i • Transitions from sA produce transitions from sA* and all final states of MA. • Start state of MA* is sA*, which is a final state. • Final states of MA* include all final states of MA.

  11. NFA for a Set Generated by a Regular Grammar • Theorem. A set generated by a regular grammar is regular. Let G = (V, T, S, P) be a regular grammar. Then the corresponding NFA is M = (S, I, f, s0, F): • S contains a state sA for each nonterminal symbol A of G, and an additional (final) state sF. • Start state is s0 = sS. • Transitions are formed from the productions: • A aB produces a transition from sA to sB on input a • A a produces a transition from sA to sF on input a • F also includes s0 if P includes production S .

  12. Example • Let G=(V,T,S,P) where V={0,1,A,S}, T={0,1}, and the productions in P are: • S1A, S0, S, A0A, A1A, A1 • The corresponding NFA is M=(S, I, f, s0, F): • S={sS, sA, sF}, s0=sS, F={sF}, I={0,1}, and state diagram 0,1 1 sA Start sS 1 0 sF

  13. Regular Grammar Generating a Regular Set • Theorem. If a set is regular, then there is a regular grammar that generates it. Let M = (S, I, f, s0, F) be the NFA recognizing this set. Then the regular grammar generating it is G = (V, T, S, P): • Assign a nonterminal symbol As to each state s of S; • Assign a terminal symbol toeach input symbol in I; • Start symbol S corresponds to start state s0. • Productions are formed from the transitions: • A transition from sto t on input aproduces As aAt • A transition from sto a final stateon input aproduces As a • P also includes production S  if L(M).

  14. Example • Let NFA M=(S, I, f, s0, F), where: S={s0, s1, s2}, I={0,1}, F={s0, s2}, and state diagram: 0 0 s1 Start s0 1 0 1 1 s2 • The corresponding regular grammar G=(V,T,S,P) • V={S=A0, A1, A2, 0, 1}, T={0, 1}, and productions in P: • S0A1, S1A2, A10A1, A11A2, A20A1, • A21A2, A11, A21, S1, S

  15. More powerful Types of Machines The set {0n1n | n = 0, 1, 2, …} is not regular; has no FA. The limitation of FAs is their finite memory. More powerful models of computation: • Pushdown automata • Include all FA’s features, plus a stack for unlimited memory. • Recognize languages generated by context-free grammars. • Example: {0n1n | n=0, 1, 2, …} • Linear bounded automata • Context-sensitive languages. Example: {0n1n2n | n = 0, 1, 2,…} • Turing machines • Include FA’s features and a tape (infinite in both directions) for read and write. ►All languages generated by grammars.

  16. Exercise 10.4

More Related