CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.

Slides:



Advertisements
Similar presentations
CS 3240: Languages and Computation
Advertisements

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Finite Automata Section 1.1 CSC 4170 Theory of Computation.
Applied Computer Science II Chapter 1 : Regular Languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Introduction to Computability Theory
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CFG => PDA Sipser 2 (pages ). CS 311 Fall Formally… A pushdown automaton is a sextuple M = (Q, Σ, Γ, δ, q 0, F), where – Q is a finite set.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections: September 1, 2006.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Finite Automata Chapter 5. Formal Language Definitions Why need formal definitions of language –Define a precise, unambiguous and uniform interpretation.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
Finite Automata Costas Busch - RPI.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
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.
CSCI 2670 Introduction to Theory of Computing August 24, 2005.
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.
Theory of Computation - Lecture 3 Regular Languages What is a computer? Complicated, we need idealized computer for managing mathematical theories... Hence:
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
CHAPTER 1 Regular Languages
Finite Automata – Definition and Examples Lecture 6 Section 1.1 Mon, Sep 3, 2007.
Deterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.2)
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Finite Automata Chapter 1. Automatic Door Example Top View.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
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 Σ:
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
CSCI 2670 Introduction to Theory of Computing
Lecture2 Regular Language
Non Deterministic Automata
Finite Automata a b A simplest computational model
Nondeterministic Finite Automata
Two issues in lexical analysis
Finite Automata & Regular Languages
Jaya Krishna, M.Tech, Assistant Professor
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Non Deterministic Automata
Finite Automata.
Finite Automata.
Deterministic Finite Automaton (DFA)
Chapter 1 Regular Language
CSC 4170 Theory of Computation Finite Automata Section 1.1.
Non Deterministic Automata
What is it? The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled.
Presentation transcript:

CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics

Automata Theory Finite Sate Machines

Motivation Question: What is a computer? Too complex to allow a precise mathematical model We introduce an abstract idealized computer Computational model One such a model is called finite automaton

Key ideas Formal definition of a finite automaton Deterministic vs. nondeterministic finite automaton Regular languages Operations on regular languages Regular expressions Pumping Lemma

Automata Theory Deterministic Finite Automaton

Example: Automatic door Front pad Rear pad door Opens when someone approaches Holds open until person clears Doesn’t open when someone is standing behind the door

Automatic door Sensors The door has 4 sensors FRONT: someone on rear pad BEHIND: someone on the rear pad BOTH: someone on both pads NEITHER: no one on either pad

Automatic door states The door has two states OPEN CLOSE

Automatic door: state diagram CLOSEDOPEN

Automatic door: state diagram CLOSEDOPEN FRONT REAR BOTH

Automatic door: state diagram CLOSEDOPEN REAR BOTH NEITHER FRONT REAR BOTH

Automatic door: state diagram CLOSEDOPEN FRONT REAR BOTH NEITHER FRONT REAR BOTH

Automatic door: state diagram CLOSEDOPEN FRONT NEITHER REAR BOTH NEITHER FRONT REAR BOTH

Automatic door: state transition table CLOSEDOPEN FRONT NEITHER REAR BOTH NEITHER FRONT REAR BOTH NEITHERFRONT REARBOTH CLOSED OPEN CLOSED OPEN CLOSED CLOSED CLOSED OPEN OPEN OPEN

Informal definition The machine M has States: q1,q2, and q3 Start state: q1 (incoming arrow from nowhere) Accept state: q2 (thick circle) State transitions: arrows q1 q2 q ,1

Informal definition The machine M on input string begins in start state q1 after reading each symbol, 1 takes transition with matching symbol q1 q2 q ,1

Informal definition After processing all the input string machine M produces output accept if M is in an accepting state reject otherwise q1 q2 q ,1

Informal definition What happens on input string? q1 q2 q ,1

Informal definition What happens on input string? 1101 q1 q2 q ,1

Informal definition What happens on input string? 1101 q1 q2 q ,1

Informal definition What happens on input string? 1101 q1 q2 q ,1

Informal definition What happens on input string? 1101 Accept q1 q2 q ,1

Informal definition What happens on input string? 0010 q1 q2 q ,1

Informal definition What happens on input string? 0010 q1 q2 q ,1

Informal definition What happens on input string? 0010 q1 q2 q ,1

Informal definition What happens on input string? 0010 Reject q1 q2 q ,1

Informal definition Can you describe the language consisting of all string that M actually accepts? q1 q2 q ,1

Informal definition M actually accepts any string that ends with a 1 1,01,11, ,… any string the ends with an even number of 0’s after the last 1 100, ,… q1 q2 q ,1

Formal Definitions A finite automaton is a 5-tuple (Q,∑,ξ,q0,F), where Q is a finite set of states ∑ is a finite set of symbols called the alphabet ξ : Q x ∑  Q is the transition function q0 Є Q is the start state F ⊆ Q is the set of accept states or final states

Back to M M is a 5-tuple (Q,∑,ξ,q1,F), where Q is a finite set of states {q1,q2,q3} ∑ is {0,1} ξ : Q x ∑  Q is the transition function q1 Є Q is the start state F ⊆ Q is {q2} q1 q2 q , q1 q2 q3 q1q2 q3q2q2 ξ

Another example: M1 M1 is a 5-tuple (Q,∑,ξ,q1,F), where Q is a finite set of states {q1,q2} ∑ is {0,1} ξ : Q x ∑  Q is the transition function q1 Є Q is the start state F ⊆ Q is {q2} q1 q q1 q2 q1q2 ξ 0

Another example: M1 What language does M1 accept? q1 q

Another example:M1 What language does M1 accept? M1 accepts all the strings that end with a 1 q1 q

Another example:M2 q1r1 ab q2r2 s a a b b a ab b

Another example:M2 What language does M2 accept? q1r1 ab q2r2 s a a b b a ab b

Another example:M2 What language does M2 accept? M1 accepts all the strings that start and end with the same symbol! q1r1 ab q2r2 s a a b b a ab b

Languages The language of machine M is the set of strings A that M accepts L(M) = A Note that M can accept many strings … but M accepts only one language We say that M recognizes language A if A= {w | M accepts w}

Regular language A language is called a regular language if some finite automaton recognizes it

Formal model of computation Let M= (Q,∑,ξ,q 0,F) be a Deterministic Finite Automaton (DFA) Let w=w 1 w 2 …w n be a string over ∑ M accepts w if a sequence of states r 0,…,r n exist such that:  r 0 =q 0  ξ(r i,w i+1 )=r i+1, i<n  r n Є F

Formal model of computation Let M= (Q,∑,ξ,q 0,F) be a Deterministic Finite Automaton (DFA) Let w=w 1 w 2 …w n be a string over ∑ M accepts w if a sequence of states r 0,…,r n exist such that:  r 0 =q 0 : the machine starts in the start state  ξ(r i,w i+1 )=r i+1, i<n: the machines goes from state to state according to the transition function  r n Є F: machine accepts its input if it ends up in an accept state

The regular operations Union operation A U B = {x | x Є A or x Є B} It takes all string and A and B and puts them together into one language

The regular operations Union operation A U B = {x | x Є A or x Є B} It takes all string in A and B and puts them together into one language Let A={good, bad} and B ={boy, girl}  A U B ={good, bad, boy, girl}

The regular operations Concatenation operation A o B = {xy| x Є A and y Є B} It attaches a string from B to the end of a string from A in the new language

The regular operations Concatenation operation A o B = {xy| x Є A and y Є B} It attaches a string from B to the end of a string from A in the new language Let A={good, bad} and B ={boy, girl}  A o B = {goodboy, goodgirl, badboy, badgirl}

The regular operations Star operation A*={x 1 x 2 …x k | k is positive and each x i Є A} It applies to a single language Attaches any number of string from A to get a string in the new language

The regular operations Star operation A*={x 1 x 2 …x k | k is positive and each x i Є A} It applies to a single language Attaches any number of string from A to get a string in the new language Let A={good, bad}  A* = {Ø, good,bad, goodgood, goodbad, badbad, badgood, gooodgooodgood, goodgoodbad, goodbadgood,…}

“Closed under” The set of natural number N={1,2,3,….} is closed under multiplication For any a and b in N, a x b is also in N 3 x 5 = 15: 3, 5, and 15 are all naturals In general, a collection of objects is closed under some operation if applying that operation to members of the collection returns and object still in the collection Note; the set of natural numbers is not closed under division 3 / 5 is not a natural number

Regular languages closed under union Theorem: The class of regular languages is closed under the union operation If A1 and A2 are regular languages, so is A1 U A2

Proof idea How to prove such a theorem? Remember that the only result we have seen so far is “A language is called a regular language if some finite automaton recognizes it”

Proof idea “A language is called a regular language if some finite automaton recognizes it” So, let us look at our theorem from this perspective: If A1 and A2 are regular languages, so is A1 U A2 M1

Proof idea “A language is called a regular language if some finite automaton recognizes it” So, let us look at our theorem from this perspective: If A1 and A2 are regular languages, so is A1 U A2 M1M2

Proof idea “A language is called a regular language if some finite automaton recognizes it” So, let us look at our theorem from this perspective: If A1 and A2 are regular languages, so is A1 U A2 M1M2M Can we construct?

Proof: approach Approach: proof by construction Some M1 accepts A1 Some M2 accepts A2 Construct M that accepts A1 U A2

Proof: first attempt Given M1 and M2 First simulate M1 If M1 doesn’t accept then simulate M2

Proof: first attempt Given M1 and M2 First simulate M1 If M1 doesn’t accept then simulate M2 What is wrong with this approach? Once the symbols are read by M1, they are lost!  We cannot simulate M2! We need another way

Proof: a second attempt We need another way: Simulate both machines simultaneously! That way only one pass thru the input is necessary But, can we keep of both simulations with finite memory?

Proof: a second attempt But, can we keep of both simulations with finite memory? Answer: All you need to remember is the sate that each machine would be in if it had read up to this point in the input You need to remember a pair of states!

Proof: a second attempt q1 q2 r1 r2 q1,r1 M1 M2 M

Proof: a second attempt q1 q2 r1 r2 q1,r1 q1,r2 M1 M2 M

Proof: a second attempt q1 q2 r1 r2 q1,r1 q1,r2 q2,r1 M1 M2 M

Proof: a second attempt q1 q2 r1 r2 q1,r1 q1,r2 q2,r1 q2,r2 M1 M2 M

Proof: a second attempt q1 q2 r1 r2 q1,r1 q1,r2 q2,r1 q2,r2 M1 M2 M

Proof: a second attempt: Accept sates q1 q2 r1 r2 q1,r1 q1,r2 q2,r1q2,r2 M1 M2 M

Proof: a second attempt: Accept sates q1 q2 r1 r2 q1,r1 q1,r2 q2,r1q2,r2 M1 M2 M

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  Q = {(r 1,r 2 ) | r 1 Є Q 1 and r 2 Є Q 2 } This set is the Cartesian product of sets Q 1 and Q 2 Denoted by Q 1 x Q 2

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  ∑ is the same

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  ξ, the transition function is defined as follows ξ((r 1,r 2 ),a) = (ξ1(r 1,a), ξ2(r 2,a))

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  q is the pair (q 1,q 2 )

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  …  F is the set of pairs in which either member is an accept state of M1 or M2 F = {(r 1,r 2 ) | r 1 Є F 1 or r 2 Є F 2 }

Proof: formal details Let M1 = (Q 1,∑,ξ 1,q 1,F 1 ) accept A1 Let M2 = (Q 2,∑,ξ 2,q 2,F 2 ) accept A2 Define M = (Q,∑,ξ,q,F) as follows  …  …  …  …  Why not choose F as follows F = {(r 1,r 2 ) | r 1 Є F 1 and r 2 Є F 2 }=F 1 x F 2 ?

What about concatenation? Theorem: The class of regular languages is closed under the concatenation operation If A1 and A2 are regular languages, so is A1 o A2

Proof Idea Simulate M1 for a while, then switch to M2 BUT: when to switch? … leads us into nondeterminism

Conclusions Deterministic Finite State Machines Regular Languages Regular Operations Union Concatenation Star Next time: Nondeterministic FA