LING 388 Language and Computers Lecture 4 9/11/03 Sandiway FONG.

Slides:



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

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.
Chapter Section Section Summary Set of Strings Finite-State Automata Language Recognition by Finite-State Machines Designing Finite-State.
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 7: 9/12.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
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/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 2: 8/23.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
LING 388: Language and Computers Sandiway Fong Lecture 2: 8/23.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/26.
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 11: 10/3.
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.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
PZ02B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02B - Regular grammars Programming Language Design.
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.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
LING 438/538 Computational Linguistics Sandiway Fong Lecture 14: 10/12.
Topics Automata Theory Grammars and Languages Complexities
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Regular Expressions/Languages Regular languages –Inductive definitions –Regular expressions syntax semantics Not covered in lecture.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
CPSC 388 – Compiler Design and Construction
Finite-State Machines with No Output
PZ02B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02B - Regular grammars Programming Language Design.
REGULAR EXPRESSIONS. Lexical Analysis Lexical analysers can be constructed by programs such as LEX These programs employ as input a description of the.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Great Theoretical Ideas in Computer Science.
Push-down Automata Section 3.3 Fri, Oct 21, 2005.
LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010.
Fundamentals of Informatics
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
CS 203: Introduction to Formal Languages and Automata
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 5 graded.
using Deterministic Finite Automata & Nondeterministic Finite Automata
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
BİL711 Natural Language Processing1 Regular Expressions & FSAs Any regular expression can be realized as a finite state automaton (FSA) There are two kinds.
CS 154 Formal Languages and Computability February 11 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
1 Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong.
Compiler Construction
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Presentation transcript:

LING 388 Language and Computers Lecture 4 9/11/03 Sandiway FONG

Administrivia Homework 1 Homework 1  account for submissions   Need help with Homework 1?  Ask Charles after class today  I’ll also be in Douglass 309 this afternoon  Homework hint  Number of inference steps?  Count the number of calls in the debugger

Administrivia Question from Tuesday’s computer lab class Question from Tuesday’s computer lab class  How to make SWI-Prolog print the entire list?  Answer:  ?- set_prolog_flag(toplevel_print_options,[max_depth(0)]).

Strings and Languages String: String:  sequence of characters, possibly empty  constructor operation: concatenation  Examples: a aaabc  (empty string) Alphabet: Alphabet:  set of possible characters  Examples: {a,b} {0,1,2,3,4,5,6,7,8,9} Language: Language:  set of strings defined over an alphabet  Examples: {,a,aa,aaa,aaaa} {}

Regular Expressions Regular Expressions Regular Expressions shorthand for describing sets of strings  Examples:  string + - set of one or more occurrences of string a + = {a, aa, aaa, aaaa, aaaaa, …}a + = {a, aa, aaa, aaaa, aaaaa, …} (abc) + = {abc, abcabc, abcabcabc, …}(abc) + = {abc, abcabc, abcabcabc, …}  string * - set of zero or more occurrences of string a * = {, a, aa, aaa, aaaa, …}a * = {, a, aa, aaa, aaaa, …} (abc) * = {, abc, abcabc, …}(abc) * = {, abc, abcabc, …}  Note: a a * = a +a a * = a + a {, a, aa, aaa, aaaa, …}a {, a, aa, aaa, aaaa, …} = {a, aa, aaa, aaaa, aaaaa, …}

Regular Expressions Regular Expressions Regular Expressions  Examples: contd.  string n - exactly n occurrences of string a 4 b 3 = { aaaabbb }a 4 b 3 = { aaaabbb }  (string 1 | string 2 ) - either string 1 or string 2 (a|b) = {a,b}(a|b|c) = {a, b, c}(a|b) = {a,b}(a|b|c) = {a, b, c}

Regular Expressions Regular Expressions contd. Regular Expressions contd.  can’t describe all possible languages  formally equivalent to regular grammars/finite state automata How to show this?How to show this? –Proof by construction… as we’ll see  How to show this?  Examples: {a n b n | n>=0}is not regular{a n b n | n>=0}is not regular {ww R | w  {a,b} + } is not regular{ww R | w  {a,b} + } is not regular –R = reverse, e.g. abc R = cba Proof by Pumping LemmaProof by Pumping Lemma

Regular Expressions Regular Expressions contd. Regular Expressions contd.  popularized by  string matching utilities - grep in Unix  Perl  typically augmented with  meta-characters denoting classes of characters e.g. [:digit:] = [0-9],. = any single charactere.g. [:digit:] = [0-9],. = any single character  special operators negation: e.g. [^0-9]negation: e.g. [^0-9] optionality: e.g. 1?optionality: e.g. 1? for dealing with lines: e.g. ^ (beginning) $ (end)for dealing with lines: e.g. ^ (beginning) $ (end)

Finite State Automata (FSA) Example: Example:  Language: L = {a + b + } “one or more a’s followed by one or more b’s”  regular language described by a regular expressiondescribed by a regular expression  Note: infinite set of strings belonging to language Linfinite set of strings belonging to language L –e.g. abbb, aaaab, aabb, *abab, * –e.g. abbb, aaaab, aabb, *abab, *

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

Finite State Automata (FSA) FSA shown on previous slide: FSA shown on previous slide:  acceptor - no output  cf. transducer - input/output pairs  deterministic- no ambiguity i.e. at any given state and input character, the next state is uniquely determined  cf. non-deterministic FSA (NDFSA)  Note: NDFSA are not more powerful than FSANDFSA are not more powerful than FSA Proof: by constructionProof: by construction

Finite State Automata (FSA) More formally: More formally:  Set of states: {s,x,y}  Start state: s, end state: y  Alphabet: {a, b}  Transition function  : signature: character x state -> state   (a,s)=x   (a,x)=x   (b,x)=y   (b,y)=y

Finite State Automata (FSA) A possible Prolog encoding strategy: A possible Prolog encoding strategy:  Define one predicate for each state  taking one argument (the input string)  consume input character  call next state with remaining input string  Initially:  fsa(L) :- s(L). call start state s

Finite State Automata (FSA)  State s: (start state)  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).

Finite State Automata (FSA)  Example: 1. ?- fsa([a,a,b]). 2. s([a,a,b). 3. x([a,b]). 4. x([b]). 5. y([]). succeeds

Finite State Automata (FSA)  Example: 1. ?- fsa([a,b,a]). 2. s([a,b,a]). 3. x([b,a]). 4. y([a]). fails

Finite State Automata (FSA) Another possible Prolog encoding strategy: Another possible Prolog encoding strategy:  fsa(S,L) :- L = [C|M], transition(S,C,T),fsa(T,M).  fsa(y,[]).% End state  transition(s,a,x).% Encodes transition  transition(x,a,x).% function   transition(x,b,y).  transition(y,b,y).

Finite State Automata (FSA)  Example: 1. ?- fsa(s,[a,a,b]). 2. transition(s,a,T). T=x 3. fsa(x,[a,b]). 4. transition(x,a,T’). T’=x 5. fsa(x,[b]). 6. transition(x,b,T”). T”=y 7. fsa(y,[]). succeeds