CS 208: Automata Theory and Logic

Similar documents
Finite Automata and Languages

Extended transition function of a DFA

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 455/555: Finite automata

Lecture 1: Finite State Automaton

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Formal Models in NLP

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Theory of Computation (I) Yijia Chen Fudan University

Sri vidya college of engineering and technology

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CSC236 Week 11. Larry Zhang

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Finite Universes. L is a fixed-length language if it has length n for some

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Inf2A: Converting from NFAs to DFAs and Closure Properties

Introduction to Formal Languages, Automata and Computability p.1/51

Nondeterministic Finite Automata

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

Finite Automata and Regular Languages

Nondeterministic finite automata

Equivalence of DFAs and NFAs

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 43

Decision, Computation and Language

Nondeterministic Finite Automata

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35

CS 154, Lecture 3: DFA NFA, Regular Expressions

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Intro to Theory of Computation

Lecture 4 Nondeterministic Finite Accepters

Chapter Five: Nondeterministic Finite Automata

September 7, Formal Definition of a Nondeterministic Finite Automaton

Nondeterminism and Epsilon Transitions

Classes and conversions

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

C2.1 Regular Grammars

Closure under the Regular Operations

Finite Automata. Mahesh Viswanathan

C2.1 Regular Grammars

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

CS21 Decidability and Tractability

Nondeterministic Finite Automata

Introduction to Finite-State Automata

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

CS243, Logic and Computation Nondeterministic finite automata

CS 121, Section 2. Week of September 16, 2013

Computability and Complexity

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Deterministic Finite Automata (DFAs)

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Fooling Sets and. Lecture 5

Nondeterministic Finite Automata

Automata and Languages

CS 154 Formal Languages and Computability Assignment #2 Solutions

Finite Automata Part Two

2. Elements of the Theory of Computation, Lewis and Papadimitrou,

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Finite Automata and Regular languages

Takeaway Notes: Finite State Automata

Computability and Complexity

Deterministic Finite Automata (DFAs)

Constructions on Finite Automata

Constructions on Finite Automata

Finite State Automata

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Automata Theory for Presburger Arithmetic Logic

More on Finite Automata and Regular Languages. (NTU EE) Regular Languages Fall / 41

CSE 135: Introduction to Theory of Computation Equivalence of DFA and NFA

CPS 220 Theory of Computation REGULAR LANGUAGES

Uses of finite automata

Reversal of Regular Languages and State Complexity

Regular Expressions. Definitions Equivalence to Finite Automata

Computational Theory

Finite Automata (contd)

Lecture 2: Connecting the Three Models

Notes on State Minimization

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Automata theory. An algorithmic approach. Lecture Notes. Javier Esparza

Formal Language and Automata Theory (CS21004)

Deterministic Finite Automata (DFAs)

Subset construction. We have defined for a DFA L(A) = {x Σ ˆδ(q 0, x) F } and for A NFA. For any NFA A we can build a DFA A D such that L(A) = L(A D )

Non Determinism of Finite Automata

Finite Automata and Regular Languages (part III)

Nondeterminism. September 7, Nondeterminism

Methods for the specification and verification of business processes MPB (6 cfu, 295AA)

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Nondeterministic Finite Automata and Regular Expressions

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

Business Processes Modelling MPB (6 cfu, 295AA)

Finite Automata. Theorems - Unit I SUSAN ELIAS. Professor Department of Computer Science & Engineering Sri Venkateswara College of Engineering

3515ICT: Theory of Computation. Regular languages

Automata: a short introduction

Transcription:

CS 28: Automata Theory and Logic b a a start A x(la(x) y(x < y) L b (y)) B b Department of Computer Science and Engineering, Indian Institute of Technology Bombay of 32

Nondeterminism Alternation 2 of 32

Finite State Automata start E O Warren S McCullough Walter Pitts 3 of 32

Deterministic Finite State Automata (DFA) start A finite state automaton is a tuple A = (S, Σ, δ, s, F), where: S is a finite set called the states; Σ is a finite set called the alphabet; δ : S Σ S is the transition function; s S is the start state; and F S is the set of accept states E O 4 of 32

Deterministic Finite State Automata (DFA) start A finite state automaton is a tuple A = (S, Σ, δ, s, F), where: S is a finite set called the states; Σ is a finite set called the alphabet; δ : S Σ S is the transition function; s S is the start state; and F S is the set of accept states For a function δ : S Σ S we define extended transition function ˆδ : S Σ S using the following inductive definition: { q if w = ε ˆδ(q, w) = δ(ˆδ(q, x), a) if w = xa st x Σ and a Σ E O 4 of 32

Deterministic Finite State Automata (DFA) start E O A finite state automaton is a tuple A = (S, Σ, δ, s, F), where: S is a finite set called the states; Σ is a finite set called the alphabet; δ : S Σ S is the transition function; s S is the start state; and F S is the set of accept states The language L(A) accepted by a DFA A = (S, Σ, δ, s, F) is defined as: L(A) = def {w : ˆδ(w) F} 5 of 32

Computation or Run of a DFA start E O computation string computation string start E start E E E O E E O 6 of 32

Deterministic Finite State Automata Semantics using extended transition function: The language L(A) accepted by a DFA A = (S, Σ, δ, s, F) is defined as: L(A) = def {w : ˆδ(w) F} Semantics using accepting computation: A computation or a run of a DFA A = (S, Σ, δ, s, F) on a string w = a a a n is the finite sequence s, a s, a 2,, a n, s n where s is the starting state, and δ(s i, a i ) = s i+ A string w is accepted by a DFA A if the last state of the unique computation of A on w is an accept state, ie s n F Language of a DFA A Proposition L(A) = {w : string w is accepted by DFA A} Both semantics define the same language Proof by induction 7 of 32

Nondeterministic Finite State Automata,,, ε start s s 2 s 3 s 4 Michael O Rabin Dana Scott 8 of 32

Non-deterministic Finite State Automata,,, ε start s s 2 s 3 s 4 A non-deterministic finite state automaton (NFA) is a tuple A = (S, Σ, δ, s, F), where: S is a finite set called the states; Σ is a finite set called the alphabet; δ : S (Σ {ε}) 2 S is the transition function; s S is the start state; and F S is the set of accept states 9 of 32

Non-deterministic Finite State Automata,,, ε start s s 2 s 3 s 4 A non-deterministic finite state automaton (NFA) is a tuple A = (S, Σ, δ, s, F), where: S is a finite set called the states; Σ is a finite set called the alphabet; δ : S (Σ {ε}) 2 S is the transition function; s S is the start state; and F S is the set of accept states For a function δ : S Σ 2 S we define extended transition function ˆδ : S Σ 2 S using the following inductive definition: {q} if w = ε ˆδ(q, w) = δ(p, a) if w = xa st x Σ and a Σ p ˆδ(q,x) 9 of 32

Non-deterministic Finite State Automata,,, ε start s s 2 s 3 s 4 A non-deterministic finite state automaton (NFA) is a tuple A = (S, Σ, δ, s, F), where: S is a finite set called the states; Σ is a finite set called the alphabet; δ : S (Σ {ε}) 2 S is the transition function; s S is the start state; and F S is the set of accept states The language L(A) accepted by an NFA A = (S, Σ, δ, s, F) is defined as: L(A) = def {w : ˆδ(w) F } of 32

Computation or Run of an NFA,,, ε start s s 2 s 3 s 4 start s s s s 2 s 3 s s 2 s 3 A s 4 s 3 s 2 s A s 4 s 4 of 32

Non-deterministic Finite State Automata Semantics using extended transition function: The language L(A) accepted by an NFA A = (S, Σ, δ, s, F) is defined: L(A) = def {w : ˆδ(w) F } Semantics using accepting computation: A computation or a run of a NFA on a string w = a a a n is a finite sequence s, r, s, r 2,, r k, s n where s is the starting state, and s i+ δ(s i, r i ) and r r r k = a a a n A string w is accepted by an NFA A if the last state of some computation of A on w is an accept state s n F Language of an NFA A Proposition L(A) = {w : string w is accepted by NFA A} Both semantics define the same language Proof by induction 2 of 32

Why study NFA? NFA are often more convenient to design than DFA, eg: {w : w contains in the third last position} {w : : w is a multiple of 2 or a multiple of 3} Union and intersection of two DFAs as an NFA Exponentially succinct than DFA Consider the language of strings having n-th symbol from the end is DFA has to remember last n symbols, and hence any DFA needs at least 2 n states to accept this language 3 of 32

Why study NFA? NFA are often more convenient to design than DFA, eg: {w : w contains in the third last position} {w : : w is a multiple of 2 or a multiple of 3} Union and intersection of two DFAs as an NFA Exponentially succinct than DFA Consider the language of strings having n-th symbol from the end is DFA has to remember last n symbols, and hence any DFA needs at least 2 n states to accept this language And, surprisingly perhaps: Theorem (DFA=NFA) Every non-deterministic finite automaton has an equivalent (accepting the same language) deterministic finite automaton Subset construction 3 of 32

Computation of an NFA: An observation,,, ε start s s 2 s 3 s 4 start s s s s 2 s 3 s s 2 s 3 A s 4 s 3 s 2 s A s 4 s 4 4 of 32

ε-free NFA = DFA Let A = (S, Σ, δ, s, F) be an ε-free NFA Consider the DFA Det(A) = (S, Σ, δ, s, F ) where S = 2 S, Σ = Σ, δ : 2 S Σ 2 S such that δ (P, a) = s P δ(s, a), s = {s }, and F S is such that F = {P : P F } Theorem (ε-free NFA = DFA) L(A) = L(Det(A)) By induction, hint ˆδ(s, w) = ˆδ ({s }, w) Exercise (3) Extend the proof for NFA with ε transitions hint: ε-closure 5 of 32

Proof of correctness: L(A) = L(Det(A)) The proof follows from the observation that ˆδ(s, w) = ˆδ ({s }, w) We prove it by induction on the length of w Base case: Let the size of w be, ie w = ε The base case follows immediately from the definition of extended transition functions: ˆδ(s, ε) = ε and ˆδ ({s }, w) = ε Induction Hypothesis: Assume that for all strings w Σ of size n we have that ˆδ(s, w) = ˆδ ({s }, w) Induction Step: Let w = xa where x Σ and a Σ be a string of size n +, and hence x is of size n Now observe, ˆδ(s, xa) = δ(s, a), by definition of ˆδ = s ˆδ(s,x) s ˆδ ({s },x) δ(s, a), from inductive hypothesis = δ (ˆδ ({s }, x), a), from definition δ (P, a) = s P δ(s, a) = ˆδ ({s }, xa), by definition of ˆδ 6 of 32

Equivalence of NFA and DFA Exercise (In class) Determinize the following automaton:,,, start s s 2 s 3 s 4 7 of 32

Complementation of the Language of a DFA start E O computation string computation string start E start E E E O E E O Hint: Simply swap the accepting and non-accepting states! 8 of 32

Complementation of a DFA Theorem Complementation of the language of a DFA A = (S, Σ, δ, s, F) is the language accepted by the DFA A = (S, Σ, δ, s, S \ F) Proof L(A) = {w Σ : ˆδ(s, w) F}, Σ \ L(A) = {w Σ : ˆδ(s, w) F}, L(A ) = {w Σ : ˆδ(s, w) S \ F}, and transition function is total 9 of 32

Complementation of the language of an NFA,,, ε start s s 2 s 3 s 4 start s s s s 2 s 3 s s 2 s 3 A s 4 s 3 s 2 s A s 4 s 4 Question: Can we simply swap the accepting and non-accepting states? 2 of 32

Complementation of the language of a NFA Question: Can we simply swap the accepting and non-accepting states? Let the NFA A be (S, Σ, δ, s, F) and let the NFA A be (S, Σ, δ, s, S \ F) the NFA after swapping the accepting states L(A) = {w Σ : ˆδ(s, w) F }, L(A ) = {w Σ : ˆδ(s, w) (S \ F) } Consider, the complement language of A Σ \ L(A) = {w Σ : ˆδ(s, w) F = } = {w Σ : ˆδ(s, w) S \ F} Hence L(A ) does not quite capture the complement Moreover, the condition for Σ \ L(A) is not quite captured by either DFA or NFA 2 of 32

Nondeterminism Alternation 22 of 32

Universal Non-deterministic Finite Automata,,, ε start s s 2 s 3 s 4 A universal non-deterministic finite state automaton (UNFA) is a tuple A = (S, Σ, δ, s, F), where: S is a finite set called the states; Σ is a finite set called the alphabet; δ : S (Σ {ε}) 2 S is the transition function; s S is the start state; and F S is the set of accept states The language L(A) accepted by a UNFA A = (S, Σ, δ, s, F) is defined as: L(A) = def {w : ˆδ(w) F} 23 of 32

Computation or Run of an UNFA,,, ε start s s 2 s 3 s 4 start s s s s 2 s 3 s s 2 s 3 A s 4 s 3 s 2 s A s 4 s 4 24 of 32

Universal Non-deterministic Finite Automata Semantics using extended transition function: The language L(A) accepted by an NFA A = (S, Σ, δ, s, F) is defined as: L(A) = def {w : ˆδ(w) F} Semantics using accepting computation: A computation or a run of a NFA on a string w = a a a n is a finite sequence s, r, s, r 2,, r k, s n where s is the starting state, and s i+ δ(s i, r i ) and r r r k = a a a n A string w is accepted by an NFA A if the last state of all computations of A on w is an accept state s n F Language of an NFA A Proposition L(A) = {w : string w is accepted by NFA A} Both semantics define the same language Proof by induction 25 of 32

ε-free UNFA = DFA Let A = (S, Σ, δ, s, F) be an ε-free UNFA Consider the DFA Det(A) = (S, Σ, δ, s, F ) where S = 2 S, Σ = Σ, δ : 2 S Σ 2 S such that δ (P, a) = s P δ(s, a), s = {s }, and F S is such that F = {P : P F} Theorem (ε-free UNFA = DFA) L(A) = L(Det(A)) By induction, hint ˆδ(s, w) = ˆδ (s, w) 26 of 32

ε-free UNFA = DFA Let A = (S, Σ, δ, s, F) be an ε-free UNFA Consider the DFA Det(A) = (S, Σ, δ, s, F ) where S = 2 S, Σ = Σ, δ : 2 S Σ 2 S such that δ (P, a) = s P δ(s, a), s = {s }, and F S is such that F = {P : P F} Theorem (ε-free UNFA = DFA) L(A) = L(Det(A)) By induction, hint ˆδ(s, w) = ˆδ (s, w) Exercise (32) Extend the proof for UNFA with ε transitions 26 of 32

Complementation of an NFA Theorem Complementation of the language of an NFA A = (S, Σ, δ, s, F) is the language accepted by the UNFA A = (S, Σ, δ, s, S \ F) Exercise (33) Write a formal proof for this theorem 27 of 32

Alternating Finite State Automata start E O Ashok K Chandra Larry J Stockmeyer 28 of 32

Alternating Finite State Automata start E O An alternating finite state automaton (AFA) is a tuple A = (S, S, S, Σ, δ, s, F), where: S is a finite set called the states with a partition S and S ; Σ is a finite set called the alphabet; δ : S (Σ {ε}) 2 S is the transition function; s S is the start state; and F S is the set of accept states 29 of 32

Computation or Run of an AFA,,, ε start s s 2 s 3 s 4 start s s s s 2 s 3 s s 2 s 3 A s 4 s 3 s 2 s A s 4 s 4 3 of 32

Universal Non-deterministic Finite Automata A computation or a run of a AFA on a string w = a a a n is a game graph G(A, w) = (S {,, 2,, n }, E) where: Nodes in S {,, 2,, n } are controlled by Eva and nodes in S {,, 2,, n} are controlled by Adam; and ((s, i), (s, i + )) E if s δ(s, a i ) Initially a token is in (s, ) node, and at every step the controller of the current node chooses the successor node Eva wins if the node reached at level i is an accepting state node, otherwise Adam wins We say that Eva has a winning strategy if she can make her decisions no matter how Adam plays A string w is accepted by an AFA A if Eva has a winning strategy in the graph G(A, w) Language of an AFA A L(A) = {w : string w is accepted by AFA A} Example 3 of 32

ε-free AFA = NFA Let A = (S, S, S, Σ, δ, s, F) be an ε-free AFA Consider the NFA NDet(A) = (S, Σ, δ, s, F ) where S = 2 S, Σ = Σ, δ : 2 S Σ 2 2S such that Q δ (P, a) if for all universal states p P S we have that δ(p, a) Q and for all existential states p P S we have that δ(p, a) Q, s = {s }, and F S is such that F = 2 F \ Theorem (ε-free AFA = NFA) L(A) = L(Det(A)) 32 of 32