LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10.

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
Theory Of Automata By Dr. MM Alam
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 13: 10/9.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/27.
LING 388: Language and Computers Sandiway Fong 9/29 Lecture 11.
Finite-state automata 2 Day 13 LING Computational Linguistics Harry Howard Tulane University.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/19.
Regular Expressions (RE) Used for specifying text search strings. Standarized and used widely (UNIX: vi, perl, grep. Microsoft Word and other text editors…)
LING 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/29.
1 Regular Expressions and Automata September Lecture #2-2.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
CS5371 Theory of Computation
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/27.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/4.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/21.
LING 388: Language and Computers Sandiway Fong Lecture 21: 11/7.
LING 388: Language and Computers Sandiway Fong Lecture 12: 10/5.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/26.
LING 388 Language and Computers Lecture 4 9/11/03 Sandiway FONG.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 11: 10/3.
Computational Language Finite State Machines and Regular Expressions.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
LING 388: Language and Computers Sandiway Fong Lecture 10: 9/26.
LING 388 Language and Computers Lecture 7 9/23/03 Sandiway FONG.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 11: 10/2.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
CPSC 388 – Compiler Design and Construction
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/15.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
2. Regular Expressions and Automata 2007 년 3 월 31 일 인공지능 연구실 이경택 Text: Speech and Language Processing Page.33 ~ 56.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong. Administrivia Reading Homework – Chapter 3 of JM: Words and Transducers.
Finite-state automata Day 12 LING Computational Linguistics Harry Howard Tulane University.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
Natural Language Processing Lecture 4 : Regular Expressions and Automata.
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
BİL711 Natural Language Processing1 Regular Expressions & FSAs Any regular expression can be realized as a finite state automaton (FSA) There are two kinds.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Theory of Computation Automata Theory Dr. Ayman Srour.
Topic 3: Automata Theory 1. OutlineOutline Finite state machine, Regular expressions, DFA, NDFA, and their equivalence, Grammars and Chomsky hierarchy.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Non Deterministic Automata
Pushdown Automata PDAs
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Non Deterministic Automata
NFAs and Transition Graphs
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
CSC312 Automata Theory Transition Graphs Lecture # 9
NFAs and Transition Graphs
Non Deterministic Automata
Lexical Analysis Uses formalism of Regular Languages
Presentation transcript:

LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10

Adminstrivia Reminder –Homework 4 due Wednesday

Today’s Topic Finite State Automata (FSA) –equivalent to the regular expressions we’ve been studying

Regular Expressions: Example.... from lecture 8 example (sheeptalk) –baa! –baaa! –baaaa! –… regular expression –baaa*! –baa+!

Regular Expressions: Example.... from lecture 8 example (sheeptalk) –baa! –baaa! –baaaa! –… regular expression –baaa*! –baa+! sw z b ! y a a > x a

Regular Expressions: Example step-by-step regular expression –baaa*! s > Start state: s

Regular Expressions: Example step-by-step regular expression –baaa*! –b –from s, –see ‘b’, –move to w sw b >

Regular Expressions: Example step-by-step regular expression –baaa*! –ba –From w, –see an ‘a’, –move to x sw ba > x

Regular Expressions: Example step-by-step regular expression –baaa*! –baa –From x, –see an ‘a’, –move to y sw b y a > x a

Regular Expressions: Example step-by-step regular expression –baaa*! –baaa* –baa –baaa –baaaa –baaaaa... –from y, –see an ‘a’, –move to ? y’ y” a a a... but machine must have a finite number of states! but machine must have a finite number of states! sw b y a > x a

Regular Expressions: Example step-by-step regular expression –baaa*! –baaa* –baa –Baaa –baaaa –baaaaa... –from y, –see an ‘a’, –“loop” aka return to state y y a sw ba > x a

Regular Expressions: Example step-by-step regular expression –baaa*! –from y, –see an ‘!’, –move to final state z (indicated in red) z ! y a Note: machine cannot finish (i.e. reach the end of the input string) in states s, x or y sw ba > x a

Finite State Automata (FSA) construction –the step-by-step FSA construction method we just used –works for any regular expression conclusion –anything we can encode with a regular expression, we can build a FSA for it –an important step in showing that FSA and REs are equivalent

Microsoft Word Wildcards basic wildcards –? and * ? any single character e.g. p?t put, pit, pat, pet *zero or more characters xy d a b c e z etc.... y a etc. one loop for each character

Microsoft Word Wildcards basic wildcards one or more of the preceding character e.g. –[ ] range of characters e.g. [aeiou] xy a a xy o a e i u

Microsoft Word Wildcards basic wildcards – < beginning of a word can think of there being a special symbol/invisible character marking the beginning of each word > end of a word suppose there is an invisible character marking the end of each word xy < see anything but ‘<‘ xy > see anything but ‘>‘

Microsoft Word Wildcards basic wildcards – > end of a word –Note the see-anything-but loop is implicit m> “word that ends in m” example: –mom is... xy > see anything but ‘>‘ xy m see anything but ‘m‘ z >

Finite State Automata (FSA) more formally –(Q,s,f,Σ,  ) 1.set of states (Q): {s,w,x,y,z} 5 statesmust be a finite set 2.start state (s): s 3.end state(s) (f): z 4.alphabet ( Σ ): {a, b, !} 5.transition function  : signature: character × state → state  (b,s)=w  (a,w)=x  (a,x)=y  (a,y)=y  (!,y)=z z ! y a sw ba > x a

Finite State Automata (FSA) in Prolog –define one predicate for each state taking one argument (the input list L ) consume input character (take the head of the list) call next state with the tail of the list –rule fsa(L) :- s(L). i.e. call start state s

Finite State Automata (FSA) state s: (start state) –s([b|L]) :- w(L). match input string beginning with b and call state w with remainder of input state w: –w([a|L]) :- x(L). state x: –x([a|L]) :- y(L). state y: –y([a|L]) :- y(L). –y([!|L]) :- z(L). state z: (end state) –z([]). z ! y a sw ba > x a

Finite State Automata (FSA) query –?- s([b,a,a,a,!]). Database s([b|L]) :- w(L). w([a|L]) :- x(L). x([a|L]) :- y(L). y([a|L]) :- y(L). y([!|L]) :- z(L). z([]). [b,a,a,a,!] [a,a,a,!][a,a,!] [!] [] z ! y a sw ba > x a [a,!]

Finite State Automata (FSA) In which state does query –?- s([b,a,b,a,!]). fail? z ! y a sw ba > x a Database s([b|L]) :- w(L). w([a|L]) :- x(L). x([a|L]) :- y(L). y([a|L]) :- y(L). y([!|L]) :- z(L). z([]). [b,a,b,a,!] [a,b,a,!] [b,a,!]

FSA Finite State Automata (FSA) have a limited amount of expressive power Let’s look at a modification to FSA and its effect on its power

String Transitions –so far... all machines have had just a single character label on the arc so if we allow strings to label arcs –do they endow the FSA with any more power? b Answer: No –because we can always convert a machine with string-transitions into one without abb abb

Finite State Automata (FSA) equivalent s z baa ! y a > machine with 5 states z ! y a sw ba > x a

Finite State Automata (FSA) equivalent Database s([b|L]) :- w(L). w([a|L]) :- x(L). x([a|L]) :- y(L). y([a|L]) :- y(L). y(['!'|L]) :- z(L). z([]). Database s([b,a,a|L]) :- y(L). y([a|L]) :- y(L). y(['!'|L]) :- z(L). z([]). z ! y a sw ba > x a s z baa ! y a >

Empty Transitions –so far... how about allowing the empty character? –i.e. go from x to y without seeing a input character –does this endow the FSA with any more power? b Answer: No –because we can always convert a machine with empty transitions into one without xy ε

Empty Transitions example –(ab)|b a ε ba b b >>

Empty Transitions example –(ab)| (empty string) aba ε b > = final state

NDFSA Basic FSA –deterministic it’s clear which state we’re always in, or deterministic = no choice point NDFSA –ND = non-deterministic i.e. we could be in more than one state non-deterministic  choice point –example: initially, either in state 1 or 2 sx y a a b b 12 a ε 3 b > >

NDFSA more generally –non-determinism can be had not just with ε-transitions but with any symbol example: –given a, we can proceed to either state 2 or 3 12 a a 3 b >

NDFSA –are they more powerful than FSA? –similar question asked earlier for ε-transitions –Answer: No –We can always convert a NDFSA into a FSA example –(set of states) 12 a a 3 b 1 2,3 a 3 b 2 > >

NDFSA example –(set of states) –construct new machine with states = set of possible states of the old machine Essential trick: –i.e. simulate the old (non- deterministic) machine with the new machine 12 a a 3 b > {1} > a > {2,3} {3}{3} ba {1} > {2,3} {3} ba {1} > {2,3} 1 2,3 a 3 b 2 >