Non-Deterministic Finite Automata

Slides:



Advertisements
Similar presentations
Lecture 6 Nondeterministic Finite Automata (NFA)
Advertisements

1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2005.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 Introduction to Computability Theory Lecture3: Regular Expressions 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.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Regular Expressions.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
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.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
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.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
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.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
1 Non-Deterministic Automata Regular Expressions.
Finite Automata Costas Busch - RPI.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
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.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automaton (DFA) Input Tape “Accept” or “Reject” String Finite Automaton Output.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Regular Expressions Costas Busch - LSU.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Lecture #5 Advanced Computation Theory Finite Automata.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Theory of Computation Automata Theory Dr. Ayman Srour.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Languages.
Non-regular languages
PDAs Accept Context-Free Languages
Non Deterministic Automata
Busch Complexity Lectures: Turing Machines
Properties of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
Busch Complexity Lectures: Reductions
Reductions Costas Busch - LSU.
NPDAs Accept Context-Free Languages
Pushdown Automata PDAs
Pushdown Automata PDAs
NPDAs Accept Context-Free Languages
Single Final State for NFA
Chapter 2 FINITE AUTOMATA.
Language Recognition (12.4)
Hierarchy of languages
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
Non-Deterministic Finite Automata
Properties of Regular Languages
Principles of Computing – UFCFA3-30-1
CSE322 Definition and description of finite Automata
Decidable Languages Costas Busch - LSU.
Non Deterministic Automata
Elementary Questions about Regular Languages
CSCI 2670 Introduction to Theory of Computing
Undecidable problems:
Language Recognition (12.4)
CSE 311 Foundations of Computing I
Chapter 1 Regular Language
NFAs accept the Regular Languages
Non Deterministic Automata
Presentation transcript:

Non-Deterministic Finite Automata Costas Busch - LSU

Nondeterministic Finite Automaton (NFA) Alphabet = Costas Busch - LSU

Alphabet = Two choices No transition No transition Costas Busch - LSU

First Choice Costas Busch - LSU

First Choice Costas Busch - LSU

First Choice All input is consumed “accept” Costas Busch - LSU

Second Choice Costas Busch - LSU

Second Choice Input cannot be consumed Automaton Halts “reject” Costas Busch - LSU

if there is a computation path of the NFA that accepts the string A NFA accepts a string: if there is a computation path of the NFA that accepts the string all the symbols of input string are processed and the last is an accepting state Costas Busch - LSU

is accepted by the NFA: “accept” “reject” because this computation accepts this computation is ignored Costas Busch - LSU

Rejection example Costas Busch - LSU

First Choice “reject” Costas Busch - LSU

Second Choice Costas Busch - LSU

Second Choice “reject” Costas Busch - LSU

Another Rejection example Costas Busch - LSU

First Choice Costas Busch - LSU

First Choice Input cannot be consumed “reject” Automaton halts Costas Busch - LSU

Second Choice Costas Busch - LSU

Second Choice Input cannot be consumed Automaton halts “reject” Costas Busch - LSU

OR A NFA rejects a string: if there is no computation of the NFA that accepts the string. For each possible computation path: All the input is consumed and the automaton is in a non accepting state OR The input cannot be consumed Costas Busch - LSU

All possible computations lead to rejection is rejected by the NFA: “reject” “reject” All possible computations lead to rejection Costas Busch - LSU

All possible computations lead to rejection is rejected by the NFA: “reject” “reject” All possible computations lead to rejection Costas Busch - LSU

Language accepted: Costas Busch - LSU

Epsilon Transitions Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

input tape head does not move Automaton changes state Costas Busch - LSU

all input is consumed “accept” String is accepted Costas Busch - LSU

Rejection Example Costas Busch - LSU

Costas Busch - LSU

(read head doesn’t move) Costas Busch - LSU

Input cannot be consumed Automaton halts “reject” String is rejected Costas Busch - LSU

Language accepted: Costas Busch - LSU

Another NFA Example Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

“accept” Costas Busch - LSU

Another String Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

“accept” Costas Busch - LSU

Language accepted Costas Busch - LSU

Another NFA Example Costas Busch - LSU

Language accepted (redundant state) Costas Busch - LSU

Simple Automata Costas Busch - LSU

NFAs are interesting because we can express languages easier than DFAs Costas Busch - LSU

Formal Definition of NFAs Set of states, i.e. Input aplhabet, i.e. Transition function Initial state Accepting states Costas Busch - LSU

Transition Function resulting states reached by following one transition with input symbol Costas Busch - LSU

States reachable from scanning Costas Busch - LSU

States reachable from scanning Costas Busch - LSU

States reachable from with one transition scanning no input symbol Costas Busch - LSU

States reachable from scanning Costas Busch - LSU

Extended Transition Function Similar with but applied on strings Costas Busch - LSU

States reachable from scanning Costas Busch - LSU

States reachable from scanning Costas Busch - LSU

Special case: for any state Costas Busch - LSU

In general : there is a walk from to with label Costas Busch - LSU

The Language of an NFA The language accepted by is: Where for each and there is some (accepting state) Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

Costas Busch - LSU

NFAs accept the Regular Languages Costas Busch - LSU

Equivalence of Machines Definition: Machine is equivalent to machine if Costas Busch - LSU

Example of equivalent machines NFA DFA Costas Busch - LSU

Theorem: Languages accepted Regular by NFAs Languages Languages by DFAs NFAs and DFAs have the same computation power, namely, they accept the same set of languages Costas Busch - LSU

Proof: we need to show Languages accepted Regular by NFAs Languages AND Languages accepted by NFAs Regular Languages Costas Busch - LSU

Every DFA is trivially a NFA Proof-Step 1 Languages accepted by NFAs Regular Languages Every DFA is trivially a NFA Any language accepted by a DFA is also accepted by a NFA Costas Busch - LSU

Any NFA can be converted to an equivalent DFA Proof-Step 2 Languages accepted by NFAs Regular Languages Any NFA can be converted to an equivalent DFA Any language accepted by a NFA is also accepted by a DFA Costas Busch - LSU

Conversion of NFA to DFA Costas Busch - LSU

NFA DFA Costas Busch - LSU

empty set NFA DFA trap state Costas Busch - LSU

NFA union DFA Costas Busch - LSU

NFA union DFA Costas Busch - LSU

NFA DFA trap state Costas Busch - LSU

END OF CONSTRUCTION NFA DFA Costas Busch - LSU

General Conversion Procedure Input: an NFA Output: an equivalent DFA with Costas Busch - LSU

The DFA has states from the power set The NFA has states The DFA has states from the power set Costas Busch - LSU

1. Initial state of NFA: Conversion Procedure Steps step Initial state of DFA: step Costas Busch - LSU

Example NFA DFA Costas Busch - LSU

step 2. For every DFA’s state compute in the NFA Union add transition to DFA Union Costas Busch - LSU

Example NFA DFA Costas Busch - LSU

3. Repeat Step 2 for every state in DFA and symbols in alphabet until no more states can be added in the DFA step Costas Busch - LSU

Example NFA DFA Costas Busch - LSU

if some is accepting state in NFA step 4. For any DFA state if some is accepting state in NFA Then, is accepting state in DFA Costas Busch - LSU

Example NFA DFA Costas Busch - LSU

then the two automata are equivalent: Lemma: If we convert NFA to DFA then the two automata are equivalent: Proof: We need to show: AND Costas Busch - LSU

First we show: We only need to prove: Costas Busch - LSU

NFA Consider symbols Costas Busch - LSU

denotes a possible sub-path like symbol denotes a possible sub-path like symbol …… …… Costas Busch - LSU

We will show that if NFA then DFA state state label label Costas Busch - LSU

More generally, we will show that if in : (arbitrary prefix) NFA then DFA Costas Busch - LSU

is true by construction of Proof by induction on Induction Basis: NFA DFA is true by construction of Costas Busch - LSU

Induction hypothesis: Suppose that the following hold NFA DFA Costas Busch - LSU

Then this is true by construction of Induction Step: Then this is true by construction of NFA DFA Costas Busch - LSU

Therefore if NFA then DFA Costas Busch - LSU

We have shown: With a similar proof we can show: Therefore: END OF PROOF Costas Busch - LSU