Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5.

Similar presentations


Presentation on theme: "LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5."— Presentation transcript:

1 LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5

2 2 Administrivia homework #2 –sorry: still not done with grading those yet homework #3 –out today –usual rules apply –due next Thursday

3 3 Last Time FSA and closure properties –concatenation, union, intersection, etc. Limits on FSA –some informal discussion –problem: shoehorn an infinite set into a machine with finite number of states and loops –for any given # states, if the (accepted) input string is long enough, you’ll need to loop –not all kinds of infinity can be encoded using just finite state loops: hard sometimes to see which ones can and cannot be

4 4 The Limits of Finite State Technology from last lecture example –L = a + b + = { ab, abb, aab, aabb, aaab, abbb, … } –“ one or more a ’ s followed by one or more b ’ s ” Note: –can be divided into two independent halves –each half can be replaced by iteration s1s1 s2s2 s3s3 ba s1s1 s2s2 s3s3 aa s4s4 b s1s1 s2s2 s3s3 ba s4s4 b s1s1 s2s2 s3s3 aa s4s4 b s5s5 b s1s1 s2s2 s3s3 aa s4s4 a s5s5 b s1s1 s2s2 s3s3 ba s4s4 b s5s5 b s1s1 s2s2 s3s3 ba s4s4 b s1s1 s2s2 s3s3 aa s4s4 b s5s5 b s0s0 ε ε s1s1 s2s2 s3s3 aa s4s4 a s5s5 b s6s6 b s0s0 ε ε s1s1 s2s2 s3s3 aa s4s4 a s5s5 b s6s6 bb s7s7 s1s1 s2s2 s3s3 aa s4s4 a s5s5 b b s3s3 s4s4 a s5s5 b b a

5 5 A Formal Tool: The Pumping Lemma A tool used to prove languages are NOT regular –based on the intuition that if a language is regular, it “pumps” (iterates) –Recall: for any given # states, if the (accepted) input string is long enough, you’ll need to loop Note: –can’t be used to prove a language is regular –to show something is regular: proof by exhibition describe a FSA (or regular expression or regular grammar)

6 6 A Formal Tool: The Pumping Lemma If a language L is regular, then there exists a number p > 0 –(sometimes called a magic number) such that every string w in L with |w| ≥ p can be written in the following form, where p is a pumping length: w = xyz with strings x, y and z such that |xy| ≤ p, |y| > 0 and xy i z is in L for every integer i ≥ 0.

7 7 A Formal Tool: The Pumping Lemma Example: –show that a n b n is not regular Proof (by contradiction): –pick a sufficiently long string in the language –e.g. a..aab..bb (#a’s = #b’s) –Partition it according to w = xyz –then show xy i z is not in L –i.e. string does not pump

8 8 A Formal Tool: The Pumping Lemma aaaa..aabbbb..bb Case 1: w = xyz, y straddles the ab boundary what happens when we pump y? Case 2: w = xyz, y is wholly within the a’s what happens when we pump y? Case 3: w = xyz, y is wholly within the b’s what happens when we pump y? yyy

9 9 Question 1 438/538 (4pts) Give the minimum size regular expression for the FSA below (2pt) Give an equivalent FSA without the ε-transition (2pts) –answer in the form of a diagram or formal definition or Prolog definition are all ok sxy a a b ε

10 10 Question 2 438/538 (8pts) convert the NDFSA into a deterministic FSA (3pts) implement both the NDFSA and the equivalent FSA in Prolog using the “one predicate per state” encoding (5pts) –submit your code –run both machines on the strings abab and abaaba, –how many steps (transitions + final stop) does each machine make? from figure 2.27 in the textbook

11 11 Question 3 438/538 (8pts) (5pts) Give a FSA in Prolog that accepts a binary string (made up of 0’s and 1’s) if and only if it begins with a 1 and contains exactly one 0 –examples: –1111011 –10 –*111011101 (3pts) Given the regular expression equivalent of the FSA

12 12 Summary Total: 20pts Question 1: 4pts Question 2: 8pts Question 3: 8pts


Download ppt "LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5."

Similar presentations


Ads by Google