LING 388: Language and Computers Sandiway Fong 9/29 Lecture 11.

Slides:



Advertisements
Similar presentations
Why empty strings? A bit like zero –you may think you can do without –but it makes definitions & calculations easier Definitions: –An alphabeth is a finite.
Advertisements

LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
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.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
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.
LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong. Administrivia We'll postpone Homework 4 review until next week …
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/27.
1 Module 20 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA (extra credit) and therefore.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 16: 10/19.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/29.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/22.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
Introduction to Computability Theory
CS5371 Theory of Computation
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 8 9/25/03 Sandiway FONG.
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 6: 9/13.
Lecture 18 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA and therefore a subset.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
1 Lecture 16 NFA’s –nondeterministic transition functions computations are trees, not paths –L(M) and LNFA LFSA subset of LNFA –Comparing computational.
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 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 14: 10/12.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Regular Expressions and Automata Chapter 2. Regular Expressions Standard notation for characterizing text sequences Used in all kinds of text processing.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
Pushdown Automata (PDAs)
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.
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.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10.
Copyright © Curt Hill Finite State Machines The Simplest and Least Capable Automaton.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong. Administrivia Reading Homework – Chapter 3 of JM: Words and Transducers.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
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.
CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho.
Chapter 2 Scanning. Dr.Manal AbdulazizCS463 Ch22 The Scanning Process Lexical analysis or scanning has the task of reading the source program as a file.
1 Introduction to the Theory of Computation Regular Expressions.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Computability Joke. Context-free grammars Parsing. Chomsky
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Intro to Data Structures
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Chapter 1 Regular Language
Presentation transcript:

LING 388: Language and Computers Sandiway Fong 9/29 Lecture 11

Adminstrivia Homework 3 graded

Last Time Prolog FSA implementation –regular expression: baa + ! –query ?- s([b,a,a,!]). –code one predicate per state (but each predicate may have more than one rule) –s([b|L]) :- w(L). –y([a|L]) :- y(L). –y([!|L]) :- z(L). –z([]). –w([a|L]) :- x(L). –x([a|L]) :- y(L). z ! y a sw ba > x a

Today’s Topics More on –the power of FSA, and –writing FSA in Prolog

FSA Finite State Automata (FSA) have a limited amount of expressive power Let’s look at some modifications to FSA and their effects on its power

Last Time String Transitions if we allow strings to label arcs –do they endow the FSA with any more power? abb abb Empty Transitions if we allow empty transitions –do they endow the FSA with any more power? xy ε 12 a a 3 b > Set of states construction Eliminate all determinism Empty transitions and as well as symbol ambiguity 1 2,3 a 3 b 2 >

Equivalence FSANDFSA FSA with ε-transitions same expressive power

NDFSA and Prolog we have already seen how to encode a regular FSA in Prolog –(using one predicate per state) 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([]).

NDFSA and Prolog we can do the same for NDFSA –without the set-of-states conversion to FSA –let Prolog’s computation rule keep track of the possible states and choice points for us 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([]). sx a a y b >

NDFSA and Prolog computation tree –?- s([a]).L=[] rule 1 ?- x([]). –No ?- y([]).L=[] rule 2 –Yes rule 4 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([]). sx a a y b > 2

ε-Transitions and Prolog earlier example 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([]). ε sx a y b > pass on L from state s to state x unchanged

ε-Transitions and Prolog Computation tree: –?- s([b]). rule 2 ?- x([b]).L=[] rule 3 –?- y([]). rule 4 »Yes 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([]). ε sx a y b >

Worked Example Derivational Morphology Write a Prolog FSA that accepts all words ending in the verbal suffix -ize use: –atom_chars(Word,List) –from the previous homework examples: –formalize –summarize –*formalizes

Worked Example Derivational Morphology write a FSA that accepts all words ending in the verbal suffix -ize use: –atom_chars(Word,List) –from previous homework examples: –formalize –summarize –*formalizes

Worked Example Given code: ends_ize(Word) :- atom_chars(Word,List), s(List). s = start state Write s/1 such that ?- ends_ize(formalize). Yes ?- ends_ize(summarize). Yes ?- ends_ize(formalizes). No

Worked Example Step 1: Draw the FSA: Notes: –machine is non-deterministic see an i we don’t know if it’s the “i” in rise or formalize –we can name the states anything we want here: states are named after the portion of the suffix recognized so far s i iz ize z i e a-z

Worked Example Step 1: Draw the FSA:Step 2: Write the Prolog Hint: use the underscore variable to simulate the range a-z (more precisely, a variable will allow any character to match, not just a-z.) s i iz ize z i e a-z

Worked Example Step 1: Draw the FSA:Step 2: Write the Prolog s([_|L]) :- s(L). s([i|L]) :- i(L). i([z|L]) :- iz(L). iz([e|L]) :- ize(L). ize([]). s i iz ize z i e a-z

Recall [previous lecture] 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

Worked Example: Part 2 Let’s simplify the FSA for -ize using string transitions Give the modified Prolog form s i iz ize z i e a-z s ize a-z

Worked Example: Part 2 Give the modified Prolog form s([_|L]) :- s(L). s([i,z,e|L]) :- ize(L). ize([]). s([_|L]) :- s(L). s([i,z,e]). s i iz ize z i e a-z s ize a-z Note: this is a further simplication, it replaces: s([i,z,e]) :- ize([]).

Worked Example: Part 3 Note: -ize suffixation works with –formalize –modernize –summarize –concretize –Sterilize but not –*summaryize –*concreteize –*sterileize What rule of English is at work here?

Worked Example: Part 3 s([_|L]) :- s(L). s([X,i,z,e]) :- \+ vowel(X). vowel(e). vowel(y). etc… Exercise: pick some other English suffixation rule, e.g. –able, and implement it as a Prolog FSA. Exercise: pick some other English suffixation rule, e.g. –able, and implement it as a Prolog FSA.