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

Similar documents
COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

Theory of Computation (I) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

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

Intro to Theory of Computation

September 7, Formal Definition of a Nondeterministic Finite Automaton

Nondeterministic Finite Automata

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Equivalence of DFAs and NFAs

Computational Models Lecture 2 1

Context-Free Languages

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

CSE 105 THEORY OF COMPUTATION

CS 455/555: Finite automata

Inf2A: Converting from NFAs to DFAs and Closure Properties

Finite Automata and Regular languages

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Computability Theory

Chapter Five: Nondeterministic Finite Automata

Nondeterministic Finite Automata

Computational Models Lecture 2 1

Theory of Computation Lecture 1. Dr. Nahla Belal

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CS 154 Introduction to Automata and Complexity Theory

CSE 105 THEORY OF COMPUTATION

CS 154, Lecture 3: DFA NFA, Regular Expressions

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

CSC173 Workshop: 13 Sept. Notes

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture 17: Language Recognition

Finite Automata Part Two

Finite Automata and Languages

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

2017/08/29 Chapter 1.2 in Sipser Ø Announcement:

CS 208: Automata Theory and Logic

UNIT-VIII COMPUTABILITY THEORY

CPS 220 Theory of Computation REGULAR LANGUAGES

CSE 105 THEORY OF COMPUTATION

CS21 Decidability and Tractability

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

Lecture 3: Nondeterministic 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,

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

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

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Final exam study sheet for CS3719 Turing machines and decidability.

Lecture 1: Finite State Automaton

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Computational Models - Lecture 5 1

Computational Models: Class 5

CSE 105 Theory of Computation Professor Jeanne Ferrante

Uses of finite automata

CPSC 421: Tutorial #1

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

Announcements. Problem Set Four due Thursday at 7:00PM (right before the midterm).

Fooling Sets and. Lecture 5

Theory of Computation

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CS243, Logic and Computation Nondeterministic finite automata

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Non-deterministic Finite Automata (NFAs)

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

DM17. Beregnelighed. Jacob Aae Mikkelsen

Sri vidya college of engineering and technology

Nondeterminism. September 7, Nondeterminism

3515ICT: Theory of Computation. Regular languages

Computational Models - Lecture 4

Decidability (intro.)

Chapter 6: NFA Applications

CSE 105 THEORY OF COMPUTATION

Computational Models - Lecture 1 1

Theory of Languages and Automata

Nondeterministic finite automata

Automata: a short introduction

CSE 105 THEORY OF COMPUTATION

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Computer Sciences Department

Non-Deterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

Nondeterministic Finite Automata

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

Closure under the Regular Operations

Theory of Computation (IX) Yijia Chen Fudan University

CSE 105 THEORY OF COMPUTATION

Lecture 4 Nondeterministic Finite Accepters

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

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

Kleene Algebras and Algebraic Path Problems

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Languages, regular languages, finite automata

Nondeterministic Finite Automata and Regular Expressions

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

Finite Automata. Mahesh Viswanathan

Foundations of Informatics: a Bridging Course

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Transcription:

INF28 1. Introduction and Regular Languages Daniel Lupp Universitetet i Oslo 18th January 218 Department of Informatics University of Oslo INF28 Lecture :: 18th January 1 / 33

Details on the Course consists of two parts: computability theory (first half of semester) and complexity theory (second half, held by Evgenij Thorstensen) INF28 Lecture :: 18th January 2 / 33

Details on the Course consists of two parts: computability theory (first half of semester) and complexity theory (second half, held by Evgenij Thorstensen) closely follows Michael Sipser s book An Introduction to the Theory of Computation (3rd International Edition) both in course content and exercises INF28 Lecture :: 18th January 2 / 33

Details on the Course consists of two parts: computability theory (first half of semester) and complexity theory (second half, held by Evgenij Thorstensen) closely follows Michael Sipser s book An Introduction to the Theory of Computation (3rd International Edition) both in course content and exercises prerequisites are INF18/IN115 and chapter of the book (very brief and incomplete refresher soon) INF28 Lecture :: 18th January 2 / 33

Details on the Course consists of two parts: computability theory (first half of semester) and complexity theory (second half, held by Evgenij Thorstensen) closely follows Michael Sipser s book An Introduction to the Theory of Computation (3rd International Edition) both in course content and exercises prerequisites are INF18/IN115 and chapter of the book (very brief and incomplete refresher soon) as always: lectures are useful, but doing exercises yourself is the most important! group exercises INF28 Lecture :: 18th January 2 / 33

Setup for Computability Theory For the first half of the course: Thursday lecture: new theory and material Friday lecture: new theory and material, but mostly reserved for in-depth discussion, examples, open Q&A INF28 Lecture :: 18th January 3 / 33

So what s it all about? INF28 Lecture :: 18th January 4 / 33

So what s it all about? Alan Turing (1912-1954) INF28 Lecture :: 18th January 4 / 33

So what s it all about? Alan Turing (1912-1954) Father of modern computing very interesting (and sad) story INF28 Lecture :: 18th January 4 / 33

So what s it all about? Alan Turing (1912-1954) Father of modern computing very interesting (and sad) story Turing machines INF28 Lecture :: 18th January 4 / 33

So what s it all about? Alan Turing (1912-1954) Father of modern computing very interesting (and sad) story Turing machines INF28 Lecture :: 18th January 4 / 33

So what s it all about? Alan Turing (1912-1954) Noam Chomsky (1928-) Father of modern computing Father of modern linguistics very interesting (and sad) story Turing machines INF28 Lecture :: 18th January 4 / 33

So what s it all about? Alan Turing (1912-1954) Noam Chomsky (1928-) Father of modern computing Father of modern linguistics very interesting (and sad) story classification of formal languages Turing machines INF28 Chomsky hierarchy Lecture :: 18th January 4 / 33

So what s it all about? Automata and formal languages (e.g., programming languages: programs considered as words in a language) INF28 Lecture :: 18th January 5 / 33

So what s it all about? Automata and formal languages (e.g., programming languages: programs considered as words in a language) What is an algorithm? INF28 Lecture :: 18th January 5 / 33

So what s it all about? Automata and formal languages (e.g., programming languages: programs considered as words in a language) What is an algorithm? Turing machines INF28 Lecture :: 18th January 5 / 33

So what s it all about? Automata and formal languages (e.g., programming languages: programs considered as words in a language) What is an algorithm? Turing machines Does a solver for a given problem always terminate? INF28 Lecture :: 18th January 5 / 33

So what s it all about? Automata and formal languages (e.g., programming languages: programs considered as words in a language) What is an algorithm? Turing machines Does a solver for a given problem always terminate? If yes, how expensive is it? ( complexity) INF28 Lecture :: 18th January 5 / 33

The Basics Set: an unordered collection of distinct objects called elements {a, b} = {a, a, b} = {b, a} Set union: A B = {x x A or x B} Set intersection: A B = {x x A and x B} Set complement: Ā = {x x A} de Morgan s laws: A B = Ā B and A B = Ā B Power Set: P(A) = {S S A} INF28 Lecture :: 18th January 6 / 33

The Basics Set: an unordered collection of distinct objects called elements {a, b} = {a, a, b} = {b, a} Set union: A B = {x x A or x B} Set intersection: A B = {x x A and x B} Set complement: Ā = {x x A} de Morgan s laws: A B = Ā B and A B = Ā B Power Set: P(A) = {S S A}, example: P({, 1}) = {, {}, {1}, {, 1}}. INF28 Lecture :: 18th January 6 / 33

The Basics Tuple: ordered collection of objects (a, a, b) (a, b) Cartesian product: A B = {(a, b) a A, b B} Function: f : A B. Assigns to each element a A a unique element f (a) B. INF28 Lecture :: 18th January 7 / 33

Finite Automata computational model of a computer with finite memory INF28 Lecture :: 18th January 8 / 33

Finite Automata computational model of a computer with finite memory Takes an input w and decides whether to accept or reject INF28 Lecture :: 18th January 8 / 33

Finite Automata computational model of a computer with finite memory Takes an input w and decides whether to accept or reject Can be used to answer such questions as Is w a palindrome? or Is w a valid program in a given programming language? INF28 Lecture :: 18th January 8 / 33

Finite Automata computational model of a computer with finite memory Takes an input w and decides whether to accept or reject Can be used to answer such questions as Is w a palindrome? or Is w a valid program in a given programming language? usual depicted as a graph for ease of reading: nodes represent states in which the automaton can be INF28 Lecture :: 18th January 8 / 33

Finite Automata computational model of a computer with finite memory Takes an input w and decides whether to accept or reject Can be used to answer such questions as Is w a palindrome? or Is w a valid program in a given programming language? usual depicted as a graph for ease of reading: nodes represent states in which the automaton can be edges between nodes represent the transition between states given a parsed input INF28 Lecture :: 18th January 8 / 33

Finite Automata computational model of a computer with finite memory Takes an input w and decides whether to accept or reject Can be used to answer such questions as Is w a palindrome? or Is w a valid program in a given programming language? usual depicted as a graph for ease of reading: nodes represent states in which the automaton can be edges between nodes represent the transition between states given a parsed input always exactly one start node: start INF28 Lecture :: 18th January 8 / 33

Finite Automata computational model of a computer with finite memory Takes an input w and decides whether to accept or reject Can be used to answer such questions as Is w a palindrome? or Is w a valid program in a given programming language? usual depicted as a graph for ease of reading: nodes represent states in which the automaton can be edges between nodes represent the transition between states given a parsed input always exactly one start node: start as well as some accept states: INF28 Lecture :: 18th January 8 / 33

Finite Automata Example: 1 start INF28 Lecture :: 18th January 9 / 33

Finite Automata What does it mean for a finite automaton to accept an input w? 1 start INF28 Lecture :: 18th January 1 / 33

Finite Automata What does it mean for a finite automaton to accept an input w? 1 starting at the start state, for each symbol in the input, follow a corresponding transition edge to the next state; start INF28 Lecture :: 18th January 1 / 33

Finite Automata What does it mean for a finite automaton to accept an input w? 1 starting at the start state, for each symbol in the input, follow a corresponding transition edge to the next state; the entire input must be parsed; start INF28 Lecture :: 18th January 1 / 33

Finite Automata What does it mean for a finite automaton to accept an input w? start 1 starting at the start state, for each symbol in the input, follow a corresponding transition edge to the next state; the entire input must be parsed; the final state must be an accepting state. INF28 Lecture :: 18th January 1 / 33

Finite Automata What does it mean for a finite automaton to accept an input w? start 1 starting at the start state, for each symbol in the input, follow a corresponding transition edge to the next state; the entire input must be parsed; the final state must be an accepting state. the example automaton accepts all inputs, words, that start and end with, with only 1 s in between. INF28 Lecture :: 18th January 1 / 33

Deterministic Finite Automata Definition A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q, F ), where 1 Q is a finite set of states INF28 Lecture :: 18th January 11 / 33

Deterministic Finite Automata Definition A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q, F ), where 1 Q is a finite set of states 2 Σ is a finite set called the alphabet INF28 Lecture :: 18th January 11 / 33

Deterministic Finite Automata Definition A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q, F ), where 1 Q is a finite set of states 2 Σ is a finite set called the alphabet 3 δ : Q Σ Q the transition function INF28 Lecture :: 18th January 11 / 33

Deterministic Finite Automata Definition A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q, F ), where 1 Q is a finite set of states 2 Σ is a finite set called the alphabet 3 δ : Q Σ Q the transition function 4 q the start state INF28 Lecture :: 18th January 11 / 33

Deterministic Finite Automata Definition A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q, F ), where 1 Q is a finite set of states 2 Σ is a finite set called the alphabet 3 δ : Q Σ Q the transition function 4 q the start state 5 F Q the set of accept states. INF28 Lecture :: 18th January 11 / 33

Finite Automata What does it mean for a finite automaton to accept an input w? start 1 starting at the start state, for each symbol in the input, follow a corresponding transition edge to the next state; the entire input must be parsed; the final state must be an accepting state. the example automaton accepts all inputs, words, that start and end with, with only 1 s in between. INF28 Lecture :: 18th January 12 / 33

Deterministic Finite Automata Definition A DFA (Q, Σ, δ, q, F ) accepts an input w = w 1 w 2 w n if there exists a sequence of states s s n such that 1 s is the start state q 2 δ(s i, w i+1 ) = s i+1 (a valid transition is chosen for the currently parsed input symbol) 3 s n F, i.e., is an accept state. INF28 Lecture :: 18th January 13 / 33

Deterministic Finite Automata Definition A DFA (Q, Σ, δ, q, F ) accepts an input w = w 1 w 2 w n if there exists a sequence of states s s n such that 1 s is the start state q 2 δ(s i, w i+1 ) = s i+1 (a valid transition is chosen for the currently parsed input symbol) 3 s n F, i.e., is an accept state. Example: 1 B For w = w 1 w 2 w 3 w 4 w 5 = 111, start A C INF28 Lecture :: 18th January 13 / 33

Deterministic Finite Automata Definition A DFA (Q, Σ, δ, q, F ) accepts an input w = w 1 w 2 w n if there exists a sequence of states s s n such that 1 s is the start state q 2 δ(s i, w i+1 ) = s i+1 (a valid transition is chosen for the currently parsed input symbol) 3 s n F, i.e., is an accept state. Example: 1 B For w = w 1 w 2 w 3 w 4 w 5 = 111, s = s s 1 s 2 s 3 s 4 s 5 = ABBBBC start A C INF28 Lecture :: 18th January 13 / 33

Regular Languages Given an alphabet Σ a language L is a set of words w = w 1 w n such that each w i Σ. INF28 Lecture :: 18th January 14 / 33

Regular Languages Given an alphabet Σ a language L is a set of words w = w 1 w n such that each w i Σ. Definition A language L is a regular language if there exists a DFA M that accepts each word in L, i.e., L = {w M accepts w}. INF28 Lecture :: 18th January 14 / 33

Regular Languages Given an alphabet Σ a language L is a set of words w = w 1 w n such that each w i Σ. Definition A language L is a regular language if there exists a DFA M that accepts each word in L, i.e., L = {w M accepts w}. 1 describes B L 1 = {w w starts and ends with, with only 1 s in between}. start A C L 1 is regular INF28 Lecture :: 18th January 14 / 33

Regular languages Since languages are sets, we can apply various operations on them: Union: the union of two languages L 1 and L 2 is L 1 L 2 = {w w L 1 or w L 2 } INF28 Lecture :: 18th January 15 / 33

Regular languages Since languages are sets, we can apply various operations on them: Union: the union of two languages L 1 and L 2 is L 1 L 2 = {w w L 1 or w L 2 } Intersection: similarly, L 1 L 2 = {w w L 1 and w L 2 }. INF28 Lecture :: 18th January 15 / 33

Regular languages Since languages are sets, we can apply various operations on them: Union: the union of two languages L 1 and L 2 is L 1 L 2 = {w w L 1 or w L 2 } Intersection: similarly, L 1 L 2 = {w w L 1 and w L 2 }. Concatanation: L 1 L 2 = {w w = w 1 w 2, w 1 L 1, w 2 L 2 } INF28 Lecture :: 18th January 15 / 33

Regular languages Since languages are sets, we can apply various operations on them: Union: the union of two languages L 1 and L 2 is L 1 L 2 = {w w L 1 or w L 2 } Intersection: similarly, L 1 L 2 = {w w L 1 and w L 2 }. Concatanation: L 1 L 2 = {w w = w 1 w 2, w 1 L 1, w 2 L 2 } Kleene star: L 1 = {x 1x 2 x k k, each x i L 1 } INF28 Lecture :: 18th January 15 / 33

Regular Languages Theorem The class of regular languages is closed under union [intersection], i.e., the union [intersection] of two regular languages is regular. INF28 Lecture :: 18th January 16 / 33

Regular Languages Theorem The class of regular languages is closed under union [intersection], i.e., the union [intersection] of two regular languages is regular. Proof idea: We multitask! Construct product automaton that runs both DFA s in parallel: (Q 1 Q 2, Σ, δ, F ) where δ((s 1, s 2 ), w i ) := (δ 1 (s 1, w i ), δ 2 (s 2, w i )) INF28 Lecture :: 18th January 16 / 33

Regular Languages Theorem The class of regular languages is closed under union [intersection], i.e., the union [intersection] of two regular languages is regular. Proof idea: We multitask! Construct product automaton that runs both DFA s in parallel: (Q 1 Q 2, Σ, δ, F ) where δ((s 1, s 2 ), w i ) := (δ 1 (s 1, w i ), δ 2 (s 2, w i )) F = {(s 1, s 2 ) s 1 or s 2 is an accepting state} for union, F = {(s 1, s 2 ) s 1 and s 2 is an accepting state} for intersection INF28 Lecture :: 18th January 16 / 33

Regular Languages Theorem The class of regular languages is closed under union [intersection], i.e., the union [intersection] of two regular languages is regular. Proof idea: We multitask! Construct product automaton that runs both DFA s in parallel: (Q 1 Q 2, Σ, δ, F ) where δ((s 1, s 2 ), w i ) := (δ 1 (s 1, w i ), δ 2 (s 2, w i )) F = {(s 1, s 2 ) s 1 or s 2 is an accepting state} for union, F = {(s 1, s 2 ) s 1 and s 2 is an accepting state} for intersection INF28 Lecture :: 18th January 16 / 33

Union of regular languages: Example 1 B1 B2 1 with implicit sink states S 1, S 2. start A1 C1 start A2 C2 INF28 Lecture :: 18th January 17 / 33

Union of regular languages: Example 1 B1 B2 1 with implicit sink states S 1, S 2. start A1 C1 start A2 C2 B1, C2 B1, S2 C1, S2 start A1, A2 B1, B2 C1, B2 S1, B2 S1, C2 INF28 Lecture :: 18th January 17 / 33

Union of regular languages: Example 1 B1 B2 1 with implicit sink states S 1, S 2. start A1 C1 start A2 C2 B1, C2 1 B1, S2 C1, S2 1 1 start A1, A2 B1, B2 C1, B2 S1, B2 1 S1, C2 INF28 Lecture :: 18th January 18 / 33

Union of regular languages: Example 1 B1 B2 1 with implicit sink states S 1, S 2. start A1 C1 start A2 C2 B1, C2 1 B1, S2 C1, S2 1 1 start A1, A2 B1, B2 C1, B2 S1, B2 1 S1, C2 INF28 Lecture :: 18th January 19 / 33

Nondeterministic Finite Automata So far, the transition function δ gave for a given state and input symbol precisely one following state. determinism INF28 Lecture :: 18th January 2 / 33

Nondeterministic Finite Automata So far, the transition function δ gave for a given state and input symbol precisely one following state. determinism Now we allow for multiple possible next states. nondeterminism INF28 Lecture :: 18th January 2 / 33

NFA - An example, 1 q 1 start q q 2 INF28 Lecture :: 18th January 21 / 33

NFA - An example, 1 q 1 start q q 2 Language consists of all,1 sequences starting and ending with. INF28 Lecture :: 18th January 21 / 33

NFA - Another example,1 q 1,1,1 start q 1 q 2 q 3 INF28 Lecture :: 18th January 22 / 33

NFA - Another example,1 q 1,1,1 start q 1 q 2 q 3 Language consists of all,1 sequences with a 1 in the third position from the end. INF28 Lecture :: 18th January 22 / 33

NFA - an example with empty transitions start 1 a ε a b 2 a, b 3 INF28 Lecture :: 18th January 23 / 33

Nondeterministic Finite Automata Definition A nondeterministic finite automaton (NFA) is a 5-tuple (Q, Σ, δ, q, F ) where 1 Q is a finite set of states, 2 Σ is a finite alphabet, 3 δ : Q Σ ε P(Q) is the transition function, and 4 F Q is the set of accepting states. INF28 Lecture :: 18th January 24 / 33

NFA First notice that DFA s are special cases of NFA s. INF28 Lecture :: 18th January 25 / 33

NFA First notice that DFA s are special cases of NFA s. DFA s accept regular languages, but what languages do NFA s accept? INF28 Lecture :: 18th January 25 / 33

NFA First notice that DFA s are special cases of NFA s. DFA s accept regular languages, but what languages do NFA s accept? As it turns out: regular languages! In other words, in a sense, DFA=NFA. INF28 Lecture :: 18th January 25 / 33

DFA=NFA Theorem Every NFA N = (Q, Σ, δ, q, F ) has an equivalent DFA M = (Q, Σ, δ, q, F ). INF28 Lecture :: 18th January 26 / 33

DFA=NFA Theorem Every NFA N = (Q, Σ, δ, q, F ) has an equivalent DFA M = (Q, Σ, δ, q, F ). Proof: Each state in the NFA has multiple possible following states. We need to simultaneously keep track of all these possible following states in one state in the DFA. INF28 Lecture :: 18th January 26 / 33

DFA=NFA Theorem Every NFA N = (Q, Σ, δ, q, F ) has an equivalent DFA M = (Q, Σ, δ, q, F ). Proof: Each state in the NFA has multiple possible following states. We need to simultaneously keep track of all these possible following states in one state in the DFA. Since the set of possible following states in the NFA could be any subset of the state set Q, the DFA s state set Q must be P(Q). INF28 Lecture :: 18th January 26 / 33

DFA=NFA Theorem Every NFA N = (Q, Σ, δ, q, F ) has an equivalent DFA M = (Q, Σ, δ, q, F ). Proof: Each state in the NFA has multiple possible following states. We need to simultaneously keep track of all these possible following states in one state in the DFA. Since the set of possible following states in the NFA could be any subset of the state set Q, the DFA s state set Q must be P(Q). Let us first assume there are no ε transitions. INF28 Lecture :: 18th January 26 / 33

DFA=NFA: Example 2 1 start 1 1 1 3 INF28 Lecture :: 18th January 27 / 33

DFA=NFA: Example 2 1 {2, 3} start 1 1 start {1} 1 1 3 {1, 2, 3} INF28 Lecture :: 18th January 27 / 33

NFA=DFA Then q = {q }. What about the transition function δ? INF28 Lecture :: 18th January 28 / 33

NFA=DFA Then q = {q }. What about the transition function δ? a state R in the DFA M corresponds to a set of states in the NFA N. So for an input w i at state R, we need to consider all possible following states to the set of possible states R. INF28 Lecture :: 18th January 28 / 33

NFA=DFA Then q = {q }. What about the transition function δ? a state R in the DFA M corresponds to a set of states in the NFA N. So for an input w i at state R, we need to consider all possible following states to the set of possible states R. Or, more formally, δ (R, w i ) = δ(r, w i ) r R = {q Q q δ(r, w i ) for some r R} INF28 Lecture :: 18th January 28 / 33

NFA=DFA Then q = {q }. What about the transition function δ? a state R in the DFA M corresponds to a set of states in the NFA N. So for an input w i at state R, we need to consider all possible following states to the set of possible states R. Or, more formally, δ (R, w i ) = δ(r, w i ) r R = {q Q q δ(r, w i ) for some r R} 2 1 {2, 3} start 1 1 start {1} 1 1 3 {1, 2, 3} INF28 Lecture :: 18th January 28 / 33

NFA=DFA Since an NFA accepts an input if any of the possible computations ends in an accept state, F = {R Q R contains a state r F }. INF28 Lecture :: 18th January 29 / 33

NFA=DFA Since an NFA accepts an input if any of the possible computations ends in an accept state, F = {R Q R contains a state r F }. Almost done! Now we need to adjust what we did in order to take ε transitions into account. To that end, let E(R) = {q q can be reached from R with or more ε transitions} for R Q. INF28 Lecture :: 18th January 29 / 33

NFA=DFA Since an NFA accepts an input if any of the possible computations ends in an accept state, F = {R Q R contains a state r F }. Almost done! Now we need to adjust what we did in order to take ε transitions into account. To that end, let E(R) = {q q can be reached from R with or more ε transitions} for R Q. Then q = E({q }). INF28 Lecture :: 18th January 29 / 33

NFA=DFA Since an NFA accepts an input if any of the possible computations ends in an accept state, F = {R Q R contains a state r F }. Almost done! Now we need to adjust what we did in order to take ε transitions into account. To that end, let E(R) = {q q can be reached from R with or more ε transitions} for R Q. Then q = E({q }). Transition function δ : δ (R, w i ) = E(δ(r, w i )) r R = {q Q q E(δ(r, w i )) for some r R} INF28 Lecture :: 18th January 29 / 33

NFA=DFA In other words, we have just proven: Theorem A language is regular iff (if and only if) there exists an NFA that accepts it. INF28 Lecture :: 18th January 3 / 33

Concatanation of regular languages So what about concatanation of languages? Given two regular languages L 1, L 2, is L 1 L 2 = {w 1 w 2 w 1 L 1, w 2 L 2 } a regular language? INF28 Lecture :: 18th January 31 / 33

Concatanation of regular languages So what about concatanation of languages? Given two regular languages L 1, L 2, is L 1 L 2 = {w 1 w 2 w 1 L 1, w 2 L 2 } a regular language? an automaton gets an input w and must guess how to split it w = w 1 w 2 in order to check L 1 and L 2 membership. INF28 Lecture :: 18th January 31 / 33

Concatanation of regular languages So what about concatanation of languages? Given two regular languages L 1, L 2, is L 1 L 2 = {w 1 w 2 w 1 L 1, w 2 L 2 } a regular language? an automaton gets an input w and must guess how to split it w = w 1 w 2 in order to check L 1 and L 2 membership. Example: L 1 = {w w begins and ends with 1} and L 2 = {w w begins and ends with } How to split the word w = 1111? Multiple options INF28 Lecture :: 18th January 31 / 33

Concatanation of regular languages So what about concatanation of languages? Given two regular languages L 1, L 2, is L 1 L 2 = {w 1 w 2 w 1 L 1, w 2 L 2 } a regular language? an automaton gets an input w and must guess how to split it w = w 1 w 2 in order to check L 1 and L 2 membership. Example: L 1 = {w w begins and ends with 1} and L 2 = {w w begins and ends with } How to split the word w = 1111? Multiple options This guessing is done by using nondeterminism: NFA s try out all computational branches and accept if one leads to an accepting state. INF28 Lecture :: 18th January 31 / 33

Concatanation of regular languages So what about concatanation of languages? Given two regular languages L 1, L 2, is L 1 L 2 = {w 1 w 2 w 1 L 1, w 2 L 2 } a regular language? an automaton gets an input w and must guess how to split it w = w 1 w 2 in order to check L 1 and L 2 membership. Example: L 1 = {w w begins and ends with 1} and L 2 = {w w begins and ends with } How to split the word w = 1111? Multiple options This guessing is done by using nondeterminism: NFA s try out all computational branches and accept if one leads to an accepting state. for concatanation: after having M 1 parse a part of the input that led to an accept state, nondeterministically hop into the second automaton M 2. INF28 Lecture :: 18th January 31 / 33

Concatanation of regular languages, 1, 1 B 1 B 2 1 1 start A 1 C 1 start A 2 C 2 INF28 Lecture :: 18th January 32 / 33

Concatanation of regular languages, 1, 1 B 1 B 2 1 1 start A 1 C 1 ε A 2 C 2 INF28 Lecture :: 18th January 33 / 33