Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided by author Slides edited for.

Slides:



Advertisements
Similar presentations
CMPS 3223 Theory of Computation
Advertisements

Finite Automata CPSC 388 Ellen Walker Hiram College.
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
Regular Languages and Regular Grammars Chapter 3.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 2 Updated and modified by.
Strings and Languages Operations
1 Languages and Finite Automata or how to talk to machines...
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
1 Regular Expressions/Languages Regular languages –Inductive definitions –Regular expressions syntax semantics Not covered in lecture.
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory III Languages And Regular Expressions Construction of FA’s for given languages.
Thopson NFA Presenter: Yuen-Shuo Li Date: 2014/5/7 Department of Computer Science and Information Engineering National Cheng Kung University, Taiwan R.O.C.
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
CMPS 3223 Theory of Computation
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 INFO 2950 Prof. Carla Gomes Module Modeling Computation: Language Recognition Rosen, Chapter 12.4.
1 Computability Five lectures. Slides available from my web page There is some formality, but it is gentle,
1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a compiler PART II:
1 Module 14 Regular languages –Inductive definitions –Regular expressions syntax semantics.
Regular Grammars Chapter 7. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
MA/CSSE 474 Theory of Computation Kleene's Theorem Practical Regular Expressions.
Review: Compiler Phases: Source program Lexical analyzer Syntax analyzer Semantic analyzer Intermediate code generator Code optimizer Code generator Symbol.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
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.
Regular Expressions Chapter 6 1. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts 2.
CHAPTER 1 Regular Languages
Regular Expressions Chapter 6.
Regular Expressions Chapter 6. Regular Languages Regular Language Regular Expression Finite State Machine Recognizes or Accepts Generates.
CSC312 Automata Theory Lecture # 3 Languages-II. Formal Language A formal language is a set of words—that is, strings of symbols drawn from a common alphabet.
Regular Expressions Chapter 6. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts.
Recursive Definations Regular Expressions Ch # 4 by Cohen
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
Modeling Computation: Finite State Machines without Output
Lecture # 4.
Mathematical Foundations of Computer Science Chapter 3: Regular Languages and Regular Grammars.
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch
CS 154 Formal Languages and Computability February 11 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Conversions Regular Expression to FA FA to Regular Expression.
1 Introduction to the Theory of Computation Regular Expressions.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
Practical Regular Expressions
Formal Language & Automata Theory
Properties of Regular Languages
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz
Language Recognition (12.4)
REGULAR LANGUAGES AND REGULAR GRAMMARS
Chapter 7 Regular Grammars
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
Language Recognition (12.4)
Instructor: Aaron Roth
Chapter 1 Regular Language
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
Kleene’s Theorem (Part-3)
CHAPTER 1 Regular Languages
Presentation transcript:

Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided by author Slides edited for use by MSU Department of Computer Science – R. Halverson 1

Regular Expressions LOTS of problems at end of chapter for you to practice!

Regular Languages Regular Language Regular Expression Finite State Machine L Accepts

 A method to describe a regular language. ◦ Different from that of a FSM  Consists of set of symbols + a syntax  Symbols ◦ Special symbols: ∅  U ( ) * + ◦ Alphabet ∑: from which strings in language are made

Regular Expressions The regular expressions over an alphabet  are all and only the strings that can be obtained as follows: 1.  is a regular expression. 2.  is a regular expression. 3. Every element of  is a regular expression. 4. If ,  are regular expressions, then so is . 5. If ,  are regular expressions, then so is . 6. If  is a regular expression, then so is  *. 7. If  is a regular expression, then so is  If  is a regular expression, then so is (  ). Know this definition!

Regular Expression Examples If  = { a, b }, the following are regular expressions:   a ( a  b )* abba   b*(aa  bb) + b

Regular Expressions Define Languages Define L, a semantic interpretation function for regular expressions: 1. L(  ) = . 2. L(  ) = {  }. 3. L(c), where c   = {c}. 4. L(  ) = L(  ) L(  ). 5. L(    ) = L(  )  L(  ). 6. L(  *) = (L(  ))*. 7. L(  + ) = L(  *) = L(  ) (L(  ))*. If L(  ) is equal to , then L(  + ) is also equal to . Otherwise L(  + ) is language formed by concatenating together one or more strings drawn from L(  ). 8. L((  )) = L(  ).

 Rules 1, 3, 4, 5 & 6 give the language its power to define sets.  Rule 8 has as its only role grouping other operators.  Rules 2 & 7 appear to add functionality to regular expression language, but don’t. 2.  is a regular expression.  * =  this is like 5 0 = 1,  0 =  7.  is a regular expression, then so is  +.  + =  *

L(( a  b )* b ) = L(( a  b )*) L( b ) = (L(( a  b )))* L( b ) = (L( a )  L( b ))* L( b ) = ({ a }  { b })* { b } = { a, b }* { b }.

Examples Convention dictates that omit the L( ) portion and use the expression to represent a language. Give a description. L(a*b*) = a*b* = {a}*{b}* L((a  b)*) = (a  b)* = {a,b}* L((a  b)*a*b*)=(a  b)* a*b*={a,b}*{a}*{b}* L((a  b)*abba(a  b)*) = (a  b)*abba(a  b)*) = {a,b}*abba{a,b}*

Give a Regular Expression L = {w  { a, b }*: |w| is even}

Solution L = {w  { a, b }*: |w| is even} ( a  b ) ( a  b ))* OR ( aa  ab  ba  bb )* Explain how this guarantees an even number of characters in each string that fits the pattern of the regular expression.

Give a regular expression L = {w  { a, b }*: w contains an odd number of a ’s}

Solution L = {w  { a, b }*: w contains an odd number of a ’s} b * ( ab * ab *)* a b * b * a b * ( ab * ab *)*

More Regular Expression Examples L ( ( aa *)   ) = L ( ( a   )* ) = L = {w  { a, b }*: there is no more than one b in w} L = {w  { a, b }* : no two consecutive letters in w are the same}

Common Idioms What do these mean? (    ) ( a  b )* ( a  b )+

Operator Precedence in Regular Expressions RegularArithmeticExpressions HighestKleene starexponentiation concatenationmultiplication Lowestunionaddition a b *  c d *x y 2 + i j 2

The Details Matter Explain the differences! These will be components of MANY of your regular expressions a *  b *  ( a  b )*  ( ab )* ( ab )*  a * b *

The Details Matter L 1 = {w  { a, b }* : every a is immediately followed a b } A regular expression for L 1 : A FSM for L 1 : L 2 = {w  { a, b }* : every a has a matching b somewhere} A regular expression for L 2 : A FSM for L 2 :

In this course…  We will make claims that 2 methodologies are equivalent. i.e. Have the same power.  We will also claim that one methodology is more powerful than another What does that mean?  Descriptive, Define

6.2 Kleene’s Theorem Finite state machines & regular expressions define the same class of languages. i.e. They are equivalent. i.e. They are equally powerful. To prove this, we must show: Theorem: Any language that can be defined with a regular expression can be accepted by some FSM and so is regular. Theorem: Every regular language (i.e., every language that can be accepted by some DFSM) can be defined with a regular expression.

For Every Regular Expression There is a Corresponding FSM  We’ll show this by construction.  That is, for each of the components in the definition of a Regular Expression (page 128), we will develop a corresponding finite state machine.  The result will not necessarily be deterministic  The methods in the proof are not necessarily unique

For Every Regular Expression There is a Corresponding FSM For the first 3 components:  : A single element c of  :  = (  *):

M1for Expression 1  M2 for Expression 2  Do any other states need to change? Minimal? S1 S2 S

M1for Expression 1  is this still F?  M2 for Expression 2 Do any other states need to change? Finals? S1 S2 F

M1for Expression 1  Do any other states need to change? Finals? S1 SF F 

M1for Expression 1  Do any other states need to change? Finals? SF F 

Example 1 (b  ab )* An FSM for b An FSM for a An FSM for b An FSM for ab : Note: This Example 6.5 page 136 is in error in text.

Example 1 ( b  ab )* An FSM for ( b  ab ): Can we reduce it?

Example 1 ( b  ab )* An FSM for ( b  ab )*: Reduce?? Do Homework starting page 151.

Simplifying Regular Expressions Regex’s describe sets: ● Union is commutative:    =   . ● Union is associative: (    )   =   (    ). ●  is the identity for union:    =    = . ● Union is idempotent:    = . Concatenation: ● Concatenation is associative: (  )  =  (  ). ●  is the identity for concatenation:   =   = . ●  is a zero for concatenation:   =   = . Concatenation distributes over union: ● (    )  = (   )  (   ). ●  (    ) = (   )  (   ). Kleene star: ●  * = . ●  * = . ●(  *)* =  *. ●  *  * =  *. ●(    )* = (  *  *)*.

 End of Chapter – Page  Try all of the problems – Really!