LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13.

Slides:



Advertisements
Similar presentations
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
Advertisements

LING 388: Language and Computers Sandiway Fong Lecture 5: 9/5.
Theory Of Automata By Dr. MM Alam
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/8.
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.
YES-NO machines Finite State Automata as language recognizers.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/27.
LING 388: Language and Computers Sandiway Fong 9/29 Lecture 11.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/19.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/29.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 3: 8/29.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/22.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/27.
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.
LING 388 Language and Computers Lecture 14 10/16/03 Sandiway FONG.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/6.
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.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/5.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5.
LING 388 Language and Computers Lecture 11 10/7/03 Sandiway FONG.
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.
LING 388: Language and Computers Sandiway Fong Lecture 4: 9/1.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
LING 388 Language and Computers Lecture 9 9/30/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
Regular Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
::ICS 804:: Theory of Computation - Ibrahim Otieno SCI/ICT Building Rm. G15.
LING 388: Language and Computers Sandiway Fong Lecture 30 12/8.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Theory of Languages and Automata
LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong.
1 Computability Five lectures. Slides available from my web page There is some formality, but it is gentle,
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/15.
LING/C SC/PSYC 438/538 Lecture 12 10/4 Sandiway Fong.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong. Administrivia Reading Homework – Chapter 3 of JM: Words and Transducers.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
Regular Languages Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Translators.
LING/C SC/PSYC 438/538 Lecture 16 Sandiway Fong. SWI Prolog Grammar rules are translated when the program is loaded into Prolog rules. Solves the mystery.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
1.2 Three Basic Concepts Languages start variables Grammars Let us see a grammar for English. Typically, we are told “a sentence can Consist.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
1 Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CST229 Week 6 Questions or concerns? Homework #4 due
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Finite-state automata
Regular Grammar.
CSE322 NDFA WITH NULL MOVES AND REGULAR EXPRESSION
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Chapter 1 Regular Language
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13

Administrivia Next Monday –September 20th –Laboratory Class –Homework #2 will be handed out –Instructional Computing Lab (ICL) –meet in SBS 224 (not here) Homework #1 –has been graded

Review Rules: 1.app([],L2,L2). 2.app([X|L1],L2,[X|L3]) :- app(L1,L2,L3). Computation tree: ?- app([1,2],[3,4],L). renames variables internally, cf. priming, L = _G297 Call: (7) app([1, 2], [3, 4], _G297) ? _G297 = [1|_G360] Call: (8) app([2], [3, 4], _G360) ? _G360 = [2|_G363] Call: (9) app([], [3, 4], _G363) ? _G363 = [3,4] Exit: (9) app([], [3, 4], [3, 4]) ? Exit: (8) app([2], [3, 4], [2, 3, 4]) ? _G360 = [2| [3,4]] Exit: (7) app([1, 2], [3, 4], [1, 2, 3, 4]) ? _G297 = [1|[2,3,4]] L = [1, 2, 3, 4] L = _G297

Last Time … Regular Expressions Finite State Automata (FSA) in Prolog sx y a a b b a+b+a+b+ 

Today’s Topic Equivalence between regular expressions and FSA More on FSA …

Regular Expressions (RE)  FSA How to show equivalence? Example (RE  FSA) –show methodically how each regular expression operator can be converted into a piece of a FSA [standard grep-style (not microsoft word) notation] –asingle symbol a –a n n occurrences of a –a * zero or more occurrences of a –a + one or more occurrences of a –a|ba or b –a?a is optional

Regular Expressions (RE)  FSA Operators –asingle symbol a –a n n occurrences of a –a –a n a 3  a a aa

Regular Expressions (RE)  FSA Operators –a * zero or more occurrences of a –a + one or more occurrences of a –a * –a + a + = aa * a a a

Regular Expressions (RE)  FSA Operators –a|ba or b –a?a is optional –a|b –a? a? = a| a b a

Regular Expressions (RE)  FSA -Transitions –do they endow the FSA with any more power? –Answer: No –We can always convert a machine with -transitions into one without Example: –(ab)|b a b a b b

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 choice point  need to keep track of where we could be –Example: Initially, states 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: –see 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

Equivalence Regular Grammars FSA Regular Expressions NDFSA FSA with -transitions

NDFSA and Prolog We have already seen how to encode a regular FSA in Prolog –First method: (one predicate per state) s([a|L]) :- x(L). x([a|L]) :- x(L). x([b|L]) :- y(L). y([]). y([b|L]) :- y(L). s([a|L]) :- x(L). x([a|L]) :- x(L). x([b|L]) :- y(L). y([]). y([b|L]) :- y(L). sx y a a b b

NDFSA and Prolog We can do the same for NDFSA –direct encoding –without conversion to FSA –let Prolog ’ s computation rule keep track of the possible states and choice points for us sx a a y b s([a|L]) :- x(L). s([a|L]) :- y(L). x([b|L]) :- y(L). y([]). s([a|L]) :- x(L). s([a|L]) :- y(L). x([b|L]) :- y(L). y([]).

NDFSA and Prolog Computation tree –?- s([a]).L=[] rule 1 ?- x([]). –No ?- y([]).L=[] rule 2 –Yes rule 4 sx a a y b 1.s([a|L]) :- x(L). 2.s([a|L]) :- y(L). 3.x([b|L]) :- y(L). 4.y([]). 1.s([a|L]) :- x(L). 2.s([a|L]) :- y(L). 3.x([b|L]) :- y(L). 4.y([]).

-Transitions and Prolog Earlier example: sx a y b s([a|L]):- x(L). s(L):- x(L). x([b|L]):- y(L). y([]). s([a|L]):- x(L). s(L):- x(L). x([b|L]):- y(L). y([]).

-Transitions and Prolog Computation tree: –?- s([b]). rule 2 ?- x([b]).L=[] rule 3 –?- y([]). rule 4 »Yes sx a y b 1.s([a|L]):- x(L). 2.s(L):- x(L). 3.x([b|L]):- y(L). 4.y([]). 1.s([a|L]):- x(L). 2.s(L):- x(L). 3.x([b|L]):- y(L). 4.y([]).

Next time Another neat feature of Prolog –Definite clause grammars (DCG) –Regular grammars