Formal Language and Automata Theory (CS21004)

Similar documents
a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular expressions, Finite Automata, transition graphs are all the same!!

Deterministic Finite Automata

Minimal DFA. minimal DFA for L starting from any other

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Chapter 2 Finite Automata

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

CISC 4090 Theory of Computation

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Fundamentals of Computer Science

NFAs continued, Closure Properties of Regular Languages

Formal Languages and Automata

Finite-State Automata: Recap

Designing finite automata II

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

More on automata. Michael George. March 24 April 7, 2014

Lexical Analysis Finite Automate

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

Some Theory of Computation Exercises Week 1

CMSC 330: Organization of Programming Languages

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

Java II Finite Automata I

CHAPTER 1 Regular Languages. Contents

Non-Deterministic Finite Automata

Worked out examples Finite Automata

Nondeterminism and Nodeterministic Automata

Lecture 08: Feb. 08, 2019

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Non-deterministic Finite Automata

Non-deterministic Finite Automata

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Theory of Computation Regular Languages

Harvard University Computer Science 121 Midterm October 23, 2012

Finite Automata-cont d

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

input tape head moves current state

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Formal languages, automata, and theory of computation

Homework 3 Solutions

GNFA GNFA GNFA GNFA GNFA

Let's start with an example:

CS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power

State Minimization for DFAs

Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1

Convert the NFA into DFA

In-depth introduction to main models, concepts of theory of computation:

CSC 311 Theory of Computation

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

1 Nondeterministic Finite Automata

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

CS375: Logic and Theory of Computing

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Lecture 9: LTL and Büchi Automata

FABER Formal Languages, Automata and Models of Computation

CS375: Logic and Theory of Computing

NFAs continued, Closure Properties of Regular Languages

First Midterm Examination

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

Lecture 09: Myhill-Nerode Theorem

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

Languages & Automata

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

Introduction to ω-autamata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

ɛ-closure, Kleene s Theorem,

CS 330 Formal Methods and Models

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

1.4 Nonregular Languages

CS 275 Automata and Formal Language Theory

SWEN 224 Formal Foundations of Programming WITH ANSWERS

Thoery of Automata CS402

CS 573 Automata Theory and Formal Languages

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Tutorial Automata and formal Languages

Transcription:

Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt

Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt

Forml Lnguge nd Automt Khrgpur The slide is just short summry Follow the discussion nd the ordwork Solve prolems (prt from those we dish out in clss) Khrgpur Forml Lnguge nd Automt

Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt

A finite utomt is mthemticl model of system with discrete inputs nd outputs system cn hve finite no. of internl configs / sttes Simple Ex : Elevtor controller : does not rememer requests tht re lredy serviced. Rememers 1) current floor, 2) current direction of motion, 3) set of requests to e serviced Complex Ex: digitl computer infinite memory version is the Turing mchine Dy to dy use y you : think of text editor progrm (modes of opertion : sve file, open file, updte user input with file in memory) Forml Lnguge nd Automt Khrgpur Khrgpur Forml Lnguge nd Automt

Forml Lnguge nd Automt Khrgpur M = Q,Σ,δ,q,F Q : finite set of internl sttes Σ : finite set of input lphet δ : Q Σ Q : is the trnsition function q Q : initil stte F Q is the set of finl/ccept sttes Khrgpur Forml Lnguge nd Automt

FA exmple Forml Lnguge nd Automt Khrgpur, 1 2 3 4 Figure: A smple FA Σ = {,}, Q = {1,2,3,4}, q = 1 δ(1,) = 2,δ(1,) = 1,δ(2,) = 3, i/p is processed left to right Khrgpur Forml Lnguge nd Automt

Acceptnce y FA Given δ : Q Σ Q, define ˆδ : Q Σ Q inductively s follows ˆδ(q,λ) = q For x Σ, Σ, ˆδ(q,x) = δ(ˆδ(q,x),) ˆδ is nothing ut the multistep version of δ Forml Lnguge nd Automt Khrgpur A string σ is ccepted y M = Q,Σ,δ,q 0,F, if ˆδ(q,σ) F L(M) = {σ Σ ˆδ(q,σ) F} A lnguge A is regulr iff it is ccepted y some FA Regulr sets re closed under,,,, Khrgpur Forml Lnguge nd Automt

Product Mchines Given M 1 = Q 1,Σ,δ 1,q 1,F 1, M 2 = Q 2,Σ,δ 2,q 2,F 2 let M 3 = Q 3,Σ,δ 3,q 3,F 3 e defined s follows. Q 3 = Q 1 Q 2, δ 3 : Q 3 Σ Q 3 where δ 3 ((p,q),) = (δ 1 (p,),δ 2 (q,)). F 3 = F 1 F 2 q 3 = (q 1,q 2 ) L(M 3 ) = L(M 1 ) L(M 2 ) : Prove tht σ Σ, (p,q) Q 3, ˆδ 3 ((p,q),σ) = (ˆδ 1 (p,σ),ˆδ 2 (q,σ)) y induction on length of input string σ Σ. Use ˆδ 3 to define L(M 3 ) s desired. With F 3 = (F 1 Q 2 ) (Q 1 F 2 ), we hve n utomt for Forml Lnguge nd Automt Khrgpur Khrgpur Forml Lnguge nd Automt

Product Exmple Forml Lnguge nd Automt s0 t0 Khrgpur s1 t2 t1 s0t0 s1t0 s0t2 s0t1 s1t2 s1t1 Figure: M 1 : even no. of, M 2 : no of is 3n. Techniclly they re sensitive to different lphets, self loops highlight tht Khrgpur Forml Lnguge nd Automt

DFA for L = {w w {,} } Forml Lnguge nd Automt q 0 q 2 q 3 Khrgpur q 1 ; Khrgpur Forml Lnguge nd Automt

DFA for L 2 With L = {w w {,} }, L 2 = {w 1 w 2 w 1,w 2 {,} } Forml Lnguge nd Automt Khrgpur q 1 q 0 ; q 2 q 3 q 5 q 4 L n = {(w i ) n w 1,,w n {,} } Khrgpur Forml Lnguge nd Automt

DFA for L Forml Lnguge nd Automt Khrgpur q 0 q 2 q 3 q 1 ; q 4 Khrgpur Forml Lnguge nd Automt

Smller DFA for L Forml Lnguge nd Automt q 0 q 2 q 3 Khrgpur q 1 ; Why? Note L n L n 1 L 3 L 2 L. So, L = L 0 L 1 L 2 = L 0 L = {ǫ} L. Just mke initil stte s ccept stte in mchine for L Khrgpur Forml Lnguge nd Automt

Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt

NFA Forml Lnguge nd Automt Khrgpur DFA is deterministic y construction since δ is function, (for ll situtions/sttes, how the mchine will exctly rect is uniquely specified) My e cumersome to specify for complex systems My even e unknown NFA provides nice wy of strction of informtion - concept pplied in so mny spects of computing Khrgpur Forml Lnguge nd Automt

NFA Consider L = {x {0,1} 2nd symol from the right is 1} 0, 1 1 0, 1 s 1 s 2 f Figure: NFA for L Forml Lnguge nd Automt Khrgpur the movement from s 1 when input is 1 is nondeterministic For n input string, NFA will crete computtion tree rther thn computtion sequence in cse of DFA An NFA ccepts string if ny one of the pths in the tree leds to some ccept stte Khrgpur Forml Lnguge nd Automt

Computtion tree for σ = 11010 s 1 1 1 Forml Lnguge nd Automt Khrgpur s 2 1 s 1 s 2 s 1 1 1 f 0 0 0? f s 1 1 1? s 2 0 f Khrgpur Forml Lnguge nd Automt

NFA to DFA Compute ll possile susets : {{},{s 1 },{s 2 },{f},{s 1,s 2 },{s 2,f},{s 1,f},{s 1,s 2,f}} compute single step rechility mong susets for i/p-s 0,1 with sme initil stte δ 0 1 {} {} {} {s 1 } {s 1 } {s 1,s 2 } {s 2 } {f} {f} {f} {} {} {s 1,s 2 } {s 1,f} {s 1,s 2,f} {s 1,f} {s 1 } {s 1,s 2 } {s 2,f} {f} {f} {s 1,s 2,f} {s 1,f} {s 1,s 2,f} Forml Lnguge nd Automt Khrgpur Sttes {s 2,f}, {s 2 }, {f}, {}, re unrechle Khrgpur Forml Lnguge nd Automt

NFA to DFA Reduced trnsition tle with unrechle sttes removed δ 0 1 {s 1 } {s 1 } {s 1,s 2 } {s 1,s 2 } {s 1,f} {s 1,s 2,f} {s 1,f} {s 1 } {s 1,s 2 } {s 1,s 2,f} {s 1,f} {s 1,s 2,f} Forml Lnguge nd Automt Khrgpur DFA should hve 4 sttes : { 1, 2, 3, 4 } = {{s 1 },{s 1,s 2 },{s 1,f},{s 1,s 2,f}} Initil stte is sme. Khrgpur Forml Lnguge nd Automt

NFA to DFA δ 0 1 {s 1 } {s 1 } {s 1,s 2 } {s 1,s 2 } {s 1,f} {s 1,s 2,f} {s 1,f} {s 1 } {s 1,s 2 } {s 1,s 2,f} {s 1,f} {s 1,s 2,f} Forml Lnguge nd Automt Khrgpur δ 0 1 1 1 2 2 3 4 3 1 2 4 3 4 Khrgpur Forml Lnguge nd Automt

NFA to DFA Forml Lnguge nd Automt δ 0 1 1 1 2 2 3 4 3 1 2 4 3 4 Khrgpur 0 1 2 1 1 1 0 1 4 0 0 3 Khrgpur Forml Lnguge nd Automt

NFA forml definition (Q,Σ,,S,F) Q : set of sttes Σ : Alphet : trnsition reltion (function) defined s Forml Lnguge nd Automt Khrgpur : Q 2 Q 2 Q = {A A Q} : cptures multiple possile rections to n input S Q : set of initil sttes Khrgpur Forml Lnguge nd Automt