LING 388 Language and Computers Lecture 7 9/23/03 Sandiway FONG.

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

CMPS 3223 Theory of Computation
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
Lecture 6 Nondeterministic Finite Automata (NFA)
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/5.
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/8.
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.
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.
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 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.
1 Lecture 13 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/25.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/7.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/26.
LING 388 Language and Computers Lecture 4 9/11/03 Sandiway FONG.
1 Lecture 16 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
LING 438/538 Computational Linguistics Sandiway Fong Lecture 11: 10/3.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13.
LING 388: Language and Computers Sandiway Fong Lecture 4: 8/31.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING 388: Language and Computers Sandiway Fong Lecture 3: 8/29.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
1 Lecture 16 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
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/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 11: 10/2.
LING 388: Language and Computers Sandiway Fong Lecture 4: 9/1.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
LING 438/538 Computational Linguistics Sandiway Fong Lecture 14: 10/12.
LING 388 Language and Computers Lecture 9 9/30/03 Sandiway FONG.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
LING 388 Language and Computers Lecture 12 10/9/03 Sandiway FONG.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 6.
CSC312 Automata Theory Lecture # 19 Chapter # 8 by Cohen Finite Automata with Output.
LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 12 10/4 Sandiway Fong.
LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10.
LING/C SC/PSYC 438/538 Lecture 14 Sandiway Fong. Administrivia Homework 6 graded.
Three Basic Concepts Languages Grammars Automata.
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.
Lecture # 15. Mealy machine A Mealy machine consists of the following 1. A finite set of states q 0, q 1, q 2, … where q 0 is the initial state. 2. An.
CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho.
CS 154 Formal Languages and Computability February 4 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
BİL711 Natural Language Processing1 Regular Expressions & FSAs Any regular expression can be realized as a finite state automaton (FSA) There are two kinds.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
Pushdown Automata PDAs
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Non-Deterministic Finite Automata
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Mealy and Moore Machines
Non Deterministic Automata
Presentation transcript:

LING 388 Language and Computers Lecture 7 9/23/03 Sandiway FONG

Administrivia Reminder Reminder  Thursday  Computer Lab Class Part 2…

Exercise 1: Finite State Automata (FSA) sx y a a b b L = {a + b + }

Exercise 1 From Lecture 4… From Lecture 4…  A possible Prolog encoding strategy:  Define one predicate for each state Name of state = name of predicateName of state = name of predicate Arity of predicate = 1Arity of predicate = 1 –taking one argument (the input string)

Exercise 1 Basic Idea 1: Basic Idea 1:  Treat the input string as a list  Consume one input character corresponding to transition arc from state, and  Call next state with remaining input string Basic Idea 2: Basic Idea 2:  For end state(s), match empty input  i.e. we can stop only when all input has been consumed and we’re in an end state

Exercise 1 Machine for L = {a + b + }Machine for L = {a + b + }  State s:  s([a|L]) :- x(L). match input string beginning with a and call state x with remainder of input  State x:  x([a|L]) :- x(L).  x([b|L]) :- y(L).  State y: (end state)  y([]).  y([b|L]) :- y(L).

Exercise 1 Consult FSA Consult FSA Turn on tracing facility Turn on tracing facility  ?- trace. Run query step-by-step Run query step-by-step  ?- s([a,a,b,b]). Run query Run query  ?- s([a,b,a]). Run query Run query  ?- s([a,X]).

Exercise 1 Homework Question (A): Homework Question (A):  What and how many answers does the query ?- s([X,Y,Z]). return? Homework Question (B): Homework Question (B):  If the clause x([a|L]) :- x(L). is removed from the program, what language does the revised FSA accept?

Exercise 2: Finite State Automata (FSA) Also from Lecture 4… Also from Lecture 4…  Formally:  Set of states: {s,x,y}  Start state: s, end state: y  Alphabet: {a, b}  Transition function  with signature: character x state -> state  (a,s)=x  (a,x)=x  (b,x)=y  (b,y)=y

Exercise 2 Basic Idea: Basic Idea:  Implement details of FSA as database facts  Write a generic program to call database facts Note: Note:  Compare implementation with Exercise 1 …where FSA details such as the layout of the FSA and program control, e.g. in the sense of what state to call next, are merged

Exercise 2 Database Facts: Database Facts:  startState(s).  endState(y).  transition(s,a,x).  transition(x,a,x).  transition(x,b,y).  transition(y,b,y).

Exercise 2 Generic Program: Generic Program:  fsa(L) :- startState(S),fsa(S,L).  fsa(S,[C|L]) :- transition(S,C,T),fsa(T,L).  fsa(S,[]) :- endState(S).

Exercise 2 Consult FSA and turn on tracing facility Consult FSA and turn on tracing facility Re-run queries from Exercise 1: Re-run queries from Exercise 1:  ?- fsa([a,a,b,b]).  ?- fsa([a,b,a]).  ?- fsa([a,X]).

Exercise 2 Homework Question (A): Homework Question (A):  What happens when we run the following query?  ?- fsa(L). Homework Question (B): Homework Question (B):  Does the corresponding query for the program in Exercise 1  ?- s(L). do the same thing? Homework Question (C): Homework Question (C):  Explain the behavior of the programs

Exercise 3 We’re going to implement a Finite State Transducer We’re going to implement a Finite State Transducer  i.e. a FSA that not only accepts input but produces output as well Strategy: Strategy:  Modify an existing FSA acceptor to take one more parameter (the output list)

Exercise 3: Finite State Transducer ab y : ies X : X Notation: input : output Variable denotes any character Example: convert word ending in –y to word ending in –ies

Exercise 3 Acceptor Program: Acceptor Program:  a([y|L]) :- b(L).  a([X|L]) :- a(L).  b([]). Note: Note:  FSA is non-deterministic

Exercise 3 Run queries: Run queries:  ?- a([f,l,y]).  ?- a([b,a,b,y]).  ?- a([a,p,p,l,e]).

Exercise 3 Convert FSA into transducer: Convert FSA into transducer:  a([y|L],M) :- b(L,M).  a([X|L],[X|M]) :- a(L,M).  b([],[i,e,s]). Notes: Notes:  M represents the output list

Exercise 3 Re-do previous queries with the extra output parameter: Re-do previous queries with the extra output parameter:  ?- a([f,l,y],X).  ?- a([b,a,b,y],X).  ?- a([a,p,p,l,e],X).

Exercise 3 Homework Question: Homework Question:  How does the transducer handle more than one “y” in the input?  Example: a([y,u,c,k,y],X).  Hint: turn on tracing