Lecture Notes 

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

Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
CS21 Decidability and Tractability
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 Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
Introduction to Computability Theory
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
CS5371 Theory of Computation
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.
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.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
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.
Topics Automata Theory Grammars and Languages Complexities
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
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.
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.
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
REGULAR LANGUAGES.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
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.
Pushdown Automata (PDAs)
Athasit Surarerks THEORY OF COMPUTATION 07 NON-DETERMINISTIC FINITE AUTOMATA 1.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
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.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
1 Introduction to the Theory of Computation Regular Expressions.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Computation Automata Theory Dr. Ayman Srour.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
Nondeterminism The Chinese University of Hong Kong Fall 2011
CIS Automata and Formal Languages – Pei Wang
Lecture2 Regular Language
Non Deterministic Automata
Chapter 2 Finite Automata
Finite Automata a b A simplest computational model
Nondeterministic Finite Automata
An Introduction to Finite Automata
Chapter 2 FINITE AUTOMATA.
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Non Deterministic Automata
CSE 2001: Introduction to Theory of Computation Fall 2009
CS21 Decidability and Tractability
Chapter 1 Regular Language
Finite-State Machines with No Output
CSCI 2670 Introduction to Theory of Computing
Nondeterminism The Chinese University of Hong Kong Fall 2010
Presentation transcript:

Lecture Notes 

Classical Theory Algorithm Decidability Efficiency (P vs. NP) decidable efficient inefficient

Introduction to the Theory of Computation Part I: Automata

1.1 Finite Automata  Deterministic FA  Non-Deterministic FA  NFA = DFA  -NFA  -NFA = NFA

Finite Automata  The simplest computational model, with very limited memory, but highly useful  Example: a finite automaton modeling an on/off switch offon push Start

State Diagram of FA start state accept state transitions states M1: 1 0 q1q3q ,1

M1 Cont ’ d on input “ 0110 ”, the machine goes: q1  q1  q2  q3  q3 = “ reject ” 1 0 q1q3q ,1

M1 Cont ’ d on input “ 101 ”, the machine goes: q1  q2  q1  q2 = “ accept ” 1 0 q1q3q ,1

Strings and Languages  Alphabet: a finite set of symbols,  A string over an alphabet is a finite sequence of symbols from the alphabet  A language is a set of strings.

M1 Cont ’ d 010: 11: : : What is the language accepted by M1? accept reject accept 1 0 q1q3q ,1 Accepts all strings without two consecutive 1’s.

Formal Definition of FA  A finite automaton is defined by a 5- tuple (Q, Σ, , q 0, F) Q: finite set of states Σ: finite alphabet : transition function, : Q x Σ  Q, takes a state and input symbol as arguments, and returns a state q 0 Q: start state FQ: set of accept states

M1 ’ s Formal Definition  M1 = (Q, Σ, , q 0, F), where Q = {q1, q2, q3} Σ = {0, 1} (q1,0)=q1, (q1,1)=q2, (q2,0)=q1, (q2,1)=q3, (q3,0)=q3, (q3,1)=q3 q1 is the start state F = {q1,q2} q1 q2 q3 01 q1q2 q1q3 1 0 q1q3q ,1

Formal Definition of Computation  A DFA M accepts input w if w can be written as where and sequences of states exist that satisfy the following conditions: 1. 2.For, we have 3.r m is an accept state. Computations,Derivations and Proofs

Languages recognized by FA  If A is the set of all strings that machine M accepts, then A is called the language of M and write L(M)=A. We say that M recognizes A or M accepts A.  Two machines are equivalent if they recognize the same languages. If machine M accepts no strings, then L(M) is the empty language.

Designing Finite Automata  Given some language, design a FA that recognizes it.  Pretending to be a FA, You see the input symbols one by one You have finite memory, i.e. finite set of states, so remember only the crucial information (finite set of possibilities) about the string seen so far.

Example  Σ ={0,1}, L = {w | w has odd number of 1s}, design a FA to recognize L. What is the necessary information to remember? --- Is the number of 1s seen so far even or odd? Two possibilities.

Example  Σ ={0,1}, L = {w | w has odd number of 1s}, design a FA to recognize L. What is the necessary information to remember? --- Is the number of 1s seen so far even or odd? Two possibilities. Assign a state to each possibility. q even q odd

Example  Σ ={0,1}, L = {w | w has odd number of 1s}, design a FA to recognize L. What is the necessary information to remember? --- Is the number of 1s seen so far even or odd? Two possibilities. Assign a state to each possibility. Assign the transitions from one possibility to another upon reading a symbol. q even q odd

Example  Σ ={0,1}, L = {w | w has odd number of 1s}, design a FA to recognize L. What is the necessary information to remember? --- Is the number of 1s seen so far even or odd? Two possibilities. Assign a state to each possibility. Assign the transitions from one possibility to another upon reading a symbol. Set the start and accept states. q even q odd

Exercise  Σ ={0,1}, L = {w | w has even number of 0s and even number of 1s}, design a FA to recognize L. What to remember? How many possibilities?

Exercise q 00 q 01 q 10 q

Example 1.9  Σ ={0,1}, L = {w | w contains 001 as a substring}, design a FA to recognize L. four possibilities: 1.haven ’ t just seen any symbols of q 2.have just seen a q 0 3.have just seen a q 00 4.have seen the entire pattern q 001

Example 1.9 qq0q0 q 00 q , 1

1.1 Finite Automata  Deterministic FA  Non-Deterministic FA  NFA = DFA  -NFA  -NFA = NFA

Nondeterministic Finite Automata  Deterministic: At any point when the machine is in a state with an input symbol, there is a unique next state to go.  Non-Deterministic: There can be more than one next state for each state-input pair.  Example: an automaton that accepts all strings ending in 01. q0q0 q1q1 q2q2 10 0, 1 M2:

How an NFA computes? q0q0 q0q0 q0q0 q0q0 q0q0 q0q0 q1q1 q1q1 q1q1 q2q2 q2q (die) Input: q0q0 q1q1 q2q2 10 0, 1

Formal Definition of NFA  An NFA can be in several states at once, or viewed in another way, it can “ guess ” which state to go next.  Formally, an NFA is a 5-tuple N = (Q, Σ, , q 0, F), where all is as DFA, but : Q x Σ  P (Q) is a transition function from Q x Σ to the power set of Q.

M2 ’ s Formal Definition  M2 = (Q, Σ, , q 0, F), where Q = {q 0, q 1, q 2 } Σ = {0, 1} (q 0,0)={q 0,q 1 }, (q 0,1)={q 0 }, (q 1,1)={q 2 } q 0 is the start state F = {q 2 } q0q0 q1q1 q2q2 10 0, 1 q0q0 q1q1 q2q2 01 {q 0,q 1 }{q 0 }  {q 2 } 

Formal Definition of Computation  A NFA M accepts input w if w can be written as where and sequences of states exist that satisfy the following conditions: 1. 2.For, we have 3.r m is an accept state.

1.1 Finite Automata  Deterministic FA  Non-Deterministic FA  NFA = DFA  -NFA  -NFA = NFA

Equivalence of NFA and DFA  NFA ’ s are usually easier to “ program ” in.  Surprisingly, for each NFA there is an equivalent (recognizes the same language) DFA.  But the DFA can have exponentially many states.

Subset Construction  Given an NFA N=(Q N, Σ,  N, q 0, F N ), we will construct an DFA D=(Q D, Σ,  D, {q 0 }, F D ), such that L(D) = L(N).  Subset construction: Q D = {S | S  Q N }, i.e. power set of Q N  D (S, a) = ∪ p  S  N (p, a) F D = {S | S ∩ F ≠ , S ∈ Q D }

Construct DFA from M2  Subset construction: 01  {q 0 }{q 0,q 1 }{q 0 } {q 1 }  {q 2 }  {q 0,q 1 } {q 0,q 2 } {q 0,q 1 }{q 0 } {q 1,q 2 }  {q 2 } {q 0,q 1,q 2 }{q 0,q 1 }{q 0,q 2 } {q 0,q 1 } 10 1 {q 0 } {q 0,q 2 } possible subsets, 3 accessible:

Example NFA  Design an NFA to accept strings over alphabet {1, 2, 3} p q r s t 1, 2, , 2 1

Equivalent DFA  32 possible subsets, 15 accessible:  DFA is much larger than NFA 123 ppqprps pqpqtprps pqt prps prpqrprtps prtpqrprtps pqsprspst pqsprspst prspqrsprstpst prstpqrsprstpst pqspqstprspst pqst prspst pqrpqrtprtps pqrt prtps pqrspqrstprstpst pqrst prstpst

1.1 Finite Automata  Deterministic FA  Non-Deterministic FA  NFA = DFA  -NFA  -NFA = NFA

Finite Automata with - Transitions  Allow  to be a label on arcs.  Formally the transition function  of an -NFA is from Q x Σ ∪ {} to P (Q).  Nothing else changes: acceptance of w is still the existence of a path from the start state to an accept state with label w. But  can appear on arcs, and means the empty string (i.e., no visible contribution to w).

Example of an -NFA qr s   1 “001” is accepted by the path q  s  r  q  r  s with label 0  01  = 001

1.1 Finite Automata  Deterministic FA  Non-Deterministic FA  NFA = DFA  -NFA  -NFA = NFA

Elimination of -Transitions  -transitions are a convenience, but do not increase the power of FA's. To eliminate - transitions: 1.Compute the transitive closure of the -arcs only. 2.If a state p can reach state q by -arcs, and there is a transition from q to r on input a (not ), then add a transition from p to r on input a. 3.Make state p an accept state if p can reach some accept state q by -arcs. 4.Remove all -transitions.

-CLOSURE  -CLOSURE(q): all states reachable from q by a sequence  …  q-CLOSURE(q); p-CLOSURE(q) and r(p, )  r-CLOSURE(q)

Example 1.-CLOSURE(q)={q}, -CLOSURE(r)={r,s}, -CLOSURE(s)={r,s} qr s  

Example 1.-CLOSURE(q)={q}, -CLOSURE(r)={r,s}, -CLOSURE(s)={r,s} 2.Add (s, 0)={q}, (r, 1)={q} qr s 1 0 0, 1  

Example 1.-CLOSURE(q)={q}, -CLOSURE(r)={r,s}, -CLOSURE(s)={r,s} 2.Add (s, 0)={q}, (r, 1)={q} 3.Add r into F as an accept state q rs 1 0 0, 1  

Example 1.-CLOSURE(q)={q}, -CLOSURE(r)={r,s}, -CLOSURE(s)={r,s} 2.Add (s, 0)={q}, (r, 1)={q} 3.Add r into F as an accept state 4.Remove (s, )={r}, (r, )={s} q rs 1 0 0, 1

Summary of Finite Automata  DFA, NFA, and -NFA are all equivalent.  -NFA  NFA  DFA  -elimination subset construction

Assignment 1  Exercise 1.3  Exercise 1.5: (c)(d)  Exercise 1.12