Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w 2.....w n be a string where each wi is a member of the.

Slides:



Advertisements
Similar presentations
CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Advertisements

Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
CS21 Decidability and Tractability
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
NFAs Sipser 1.2 (pages 47–54). CS 311 Mount Holyoke College 2 Recall… Last time we showed that the class of regular languages is closed under: –Complement.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
CS5371 Theory of Computation
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
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.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Theory of Languages and Automata
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
Theory of Computation - Lecture 3 Regular Languages What is a computer? Complicated, we need idealized computer for managing mathematical theories... Hence:
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CS355 - Theory of Computation Regular Expressions.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Finite Automata & Regular Languages Sipser, Chapter 1.
Lecture Notes 
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
 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 11, 2007.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Computation Automata Theory Dr. Ayman Srour.
Foundations of Computing Science
Lecture2 Regular Language
PROPERTIES OF REGULAR LANGUAGES
CSE 105 theory of computation
Nondeterministic Finite Automata
Lecture3 DFA vs. NFA, properties of RL
COSC 3340: Introduction to Theory of Computation
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Regular Languages Finite Automata eg. Supermarket automatic door:
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
Teori Bahasa dan Automata Lecture 6: Regular Expression
CHAPTER 1 Regular Languages
Presentation transcript:

Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w w n be a string where each wi is a member of the alphabet ∑. Then M accepts w if a sequence of states r 0, r 1, ….,r n In Q exists with three conditions: 1- r 0 = q 0, 2- δ(r i, w i +1)=r i +1, for i=0,...,n-1, and 3- r n ∈ F

Cont. Condition 1 says that the machine starts in the start state. Condition 2 says that the machine goes from state to another according to the transition function Condition 3 says that the machine accepts its input if it ends up in an accept state. We say that M recognizes language A if A = {w | M accepts w}

Regular Language Definition: A language is called a regular language if some finite automaton recognizes it. See example 1.17 p. 41

Designing Finite Automata Just like artwork, design is a creative process... Suppose you are given some language, and you want to design a FA that recognizes it...pretend that you are the machine! Take symbols, one by one, and and after each symbol, you should decide whether the string so far is in the language or not.

Designing Finite Automata – Cont. What if the string is from earth to moon long? And your memory (as a FA) is like a sheet of paper? Worry-less, you will have to memorize the crucial info only, like: “What's my status now?” Example: suppose: alphabet = {0,1}, and that the language consists of all strings with an odd number of 1s. You want to construct a FA E 1 to recognize this language

Designing Finite Automata – Cont. By pretending that you're the FA, get the symbols (1 by 1), do you need to remember all the string? No! Just remembering the number of 1s so far is even or not is enough, so that if next is 0, don't change, if 1, change! Therefore, you have 2 states, say: q odd, q even.

Designing Finite Automata – Cont. Next, assign transitions. Assign a start state (q even ) in our example, since no symbol has been entered so far (0) and 0 is even. What about Final state (accept)? See example P.43

Regular Operations We use them to study properties of regular languages, those properties will help us develop a toolbox that will include ways of proving certain other languages are nonregular (i.e. beyond the capability of FA)

Regular Operations If A and B are languages, then: Union: A ∪ B = {x|x ∈ A or x ∈ B} Concatenation: A ○ B = {xy | x ∈ A and y ∈ B} Star: A* = {x 1 x 2....x k | k>=0 and each x i ∈ A} The star operation is unary operation (on 1 language) while the union and conc. are binary operations

Regular Operations – cont. Let ∑ = {a,b,....,z}, if A = {good, bad}, and B = {boy, girl} the: A ∪ B = {good, bad, boy, girl} A ○ B = {goodboy, goodgirl, badboy, badgirl} A*= {ε, good, bad, goodgood, badbad, badgood, goodgoodgood, goodgoodbad, etc.....}

Regular Operations Cont. Closed under multiplication: example, if x and y are two numbers from N, then x*y results a number also from N. But N is not closed under division, because x/y may result a number which isn't member of N, ex. X=1, y=2, x/y=1/2 which isn't member of N Please read theorems 1.25, 1.26 p.45, 46

Nondeterminism DFA vs. NFA: DFA has exactly one exiting transition arrow for each symbol in the alphabet, NFA violets that. DFA uses symbols from alphabet only for arrow labels, NFA may use others, such as ε. What will happen if a state has two arrows for same input? Or if input is ε?

NFA q1q2q3q4 10,ε 1 0,1 q4q4

Examples: 1.30, 1.33, 1.35 P: 51-53

Formal definition of NFA Similar to DFA, the NFA has the 5-tuple, yet the difference is in δ (The Transition Function) In DFA, δ takes a state and an input symbol and produces the next state. In NFA, δ takes a state and an an input symbol OR the empty string and produces the set of possible next states.

Cont. Therefore, point 3 of the tuple would be as: δ : Q X ∑ ε → P(Q), where ∑ ε is the result of ∑ ∪ ε

Example The formal definition of N1 (slide 13): 1- Q = {q 1,q 2,q 3,q 4 } 2- ∑ = {0,1} 3- δ is given as: 4- q 1 =start state 5- F ={q 4 } 01 ε q1q1 {q 1 }{q 1,q 2 }Ф q2q2 {q 3 }Ф q3q3 Ф{q 4 }Ф q4q4 Ф

Reading Every NFA has an equivalent DFA... To prove, read P.54- P.58 Based on your previous reading (P.45), read Closure under the regular operations (P.58-63). Which is similar to, yet easier than example P.45.

Regular Expressions In math, we use + and x to build up expressions like: (5+3)x4 (Gives 32) Similarly, we use ∪ and * to build up expressions describing languages, called Regular Expressions (RegEx): (0 ∪ 1)0* … (Gives a language) What does (0 ∪ 1)0* mean? It's a language consisting of all strings starting with a 0 or 1 followed by any number of 0s.

RegEx – Cont. (0 ∪ 1)0* is: - (0 ∪ 1) = ({0} ∪ {1}) = {0,1} - 0* means {0}*, means a language consisting of of any number of 0s. The concatenation between (0 ∪ 1) and 0* is a shorthand for for (0 ∪ 1) ○ 0* Applications of RegEx: many, Grep (text-search)in Unix and Linux, Perl, C++, text editors etc.... In C++, you can use regex r("(\\+|-)?[[:digit:]]+");, but why?

Regex- Example (0 ∪ 1)* = the language consisting of all possible strings of 0s and 1s. If ∑ ={0,1}, then ∑ is a shorthand for (0 ∪ 1). Generally, if ∑ is any alphabet, the regex ∑ describes the language consisting of all strings of length 1 over the alphabet, and ∑* describes the language consisting of all strings over the alphabet. ∑*1 is the language that contains all strings that end with 1

Regex- Example-cont. The language (0 ∑*) ∪ (∑*1) consists of all strings that either start with a 0 or end with a 1. * similar to mathematical precedence ( x before + for example), in regex, * is done first,then concatenation, finally the union. Unless parentheses are used.

Formal Definition of regex We say that R is a regex if R: 1. a for some a in the alphabet 2. ε, (R 1 ∪ R 2 ) 5. (R 1 ○ R 2 ) 6. (R 1 *), where R 1 is a regex