cpsc 121 models of computation
play

CPSC 121: Models of Computation Instructor: Bob Woodham - PowerPoint PPT Presentation

CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2009/2010, Section 203 CPSC 121: Models of Computation Menu March 15, 2010 Topics: DFAs


  1. CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2009/2010, Section 203 CPSC 121: Models of Computation

  2. Menu March 15, 2010 Topics: DFAs and Regular Expressions Pre-class reading: Today: Epp 12.1 Lab 7 (Pre-Lab) Reminders: Lab 8 this week (pre-lab worth marks) 2nd Midterm Wednesday, March 24, 7:00–8:00pm Final exam Thursday, Apr 29, noon, OSBO A Bob’s course office hours, Friday, 10:30–noon, ICCS 119 Bring iClickers to class READ the WebCT Vista course announcements board www: http://www.ugrad.cs.ubc.ca/~cs121/ WebCT Vista: http://www.vista.ubc.ca CPSC 121: Models of Computation

  3. Formal Languages: Terminology An alphabet, Σ , is a finite set of characters A string over Σ is an ordered n-tuple of elements of Σ , written without parentheses or commas, or the null (i.e., empty) string ǫ A formal language over Σ is a set of strings over the alphabet, Σ CPSC 121: Models of Computation

  4. Formal Languages: Notation Let Σ be a given alphabet. Then Σ n is the set of all strings over Σ with length n 1 Σ ∗ is the set of all strings over Σ . 2 Σ ∗ is called the Kleene closure of Σ Σ + is the set of all strings over Σ with length at least 1. 3 Σ + is called the positive closure of Σ CPSC 121: Models of Computation

  5. Operations on Formal Languages Let L and L ′ be languages over Σ . Three new languages are defined as follows: The concatentation of L and L ′ , denoted LL ′ , is the set 1 LL ′ = { xy | x ∈ L and y ∈ L ′ } The union of L and L ′ , denoted L ∪ L ′ , is the set 2 L ∪ L ′ = { x | x ∈ L or x ∈ L ′ } The Kleene closure of L , denoted L ∗ , is the set 3 L ∗ = { x | x is the concatentation of any number of strings in L } NOTE: ǫ ∈ L ∗ CPSC 121: Models of Computation

  6. Definition: Regular Expression Let Σ be a given (finite) alphabet. The following defines the regular expressions over Σ : Base cases: ∅ , ǫ and each individual character in Σ are 1 regular expressions over Σ Recursive cases: If r and s are regular expressions over Σ , 2 then so are the following: ( rs ) , the concatenation of r and s ( r | s ) , read as r or s ( r ∗ ) , the Kleene closure of R Exclusion: Nothing is a regular expression over Σ except 3 for the objects defined in the 1. Base cases and the 2. Recursive cases given above CPSC 121: Models of Computation

  7. Language Defined by a Regular Expression Let Σ be a given (finite) alphabet. The function L that associates a language to each regular expression, r , over Σ is defined below. L ( r ) is called the language defined by r Base cases: L ( ∅ ) = ∅ , L ( ǫ ) = { ǫ } , ∀ a ∈ Σ , L ( a ) = { a } 1 Recursive cases: If L ( r ) and L ( s ) are languages defined by 2 regular expressions r and s over Σ , then L ( rs ) = L ( r ) L ( s ) L ( r | s ) = L ( r ) ∪ L ( s ) L ( r ∗ ) = ( L ( r )) ∗ CPSC 121: Models of Computation

  8. Result: Regular Languages and DFAs By definition, regular languages over a given alphabet, Σ , are (formal) languages that can be defined by a regular expression, r over Σ Kleene’s theorem: The set of languages defined by regular expressions is identical to the set of languages accepted by a deterministic finite state automaton (DFA). That is, Given any language that is accepted by a DFA, there is a regular expression that defines the same language Given any language defined by a regular expression, there is a DFA that accepts the same language CPSC 121: Models of Computation

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend