Instructor: Aaron Roth

Slides:



Advertisements
Similar presentations
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Advertisements

Lecture 24 MAS 714 Hartmut Klauck
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
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 Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
CS5371 Theory of Computation
Transparency No. 2-1 Formal Language and Automata Theory Chapter 2 Deterministic Finite Automata (DFA) (include Lecture 3 and 4)
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
1 Languages and Finite Automata or how to talk to machines...
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Introduction Chapter 0. Three Central Areas 1.Automata 2.Computability 3.Complexity.
By: Er. Sukhwinder kaur.  What is Automata Theory? What is Automata Theory?  Alphabet and Strings Alphabet and Strings  Empty String Empty String 
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Prof. Busch - LSU1 NFAs accept the Regular Languages.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
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.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Theory of Computation Automata Theory Dr. Ayman Srour.
CIS 262 Automata, Computability, and Complexity Fall Instructor: Aaron Roth
Non Deterministic Automata
Busch Complexity Lectures: Reductions
CSE 105 theory of computation
CSE 311 Foundations of Computing I
Single Final State for NFA
Chapter 2 FINITE AUTOMATA.
Introduction to Automata Theory
Hierarchy of languages
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Non Deterministic Automata
Introduction to Finite Automata
Principles of Computing – UFCFA3-30-1
Discrete Math II Howon Kim
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
CSE 105 theory of computation
Instructor: Aaron Roth
Instructor: Aaron Roth
CSCI 2670 Introduction to Theory of Computing
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Instructor: Aaron Roth
Presentation transcript:

Instructor: Aaron Roth aaroth@cis.upenn.edu CIS 262 Automata, Computability, and Complexity Spring 2019 http://www.seas.upenn.edu/~cse262/ Instructor: Aaron Roth aaroth@cis.upenn.edu Lecture: January 28, 2019

Administrivia Registration: Nick Mancuso should be in the process of granting permits to everyone on the waitlist in “category 2” Recitation: First Recitation is today after class (4:30-5:30) in the Wu and Chen auditorium in Levine. DFA review/practice before the first problem set is due (Weds)

Recap DFA M = (states Q, alphabet S, initial state q0, final states F, transition function d : Q x S  Q ) Extended transition function: d* : Q x S*  Q L(M) = { w | d*(q0, w) is in F }

Syntax vs Semantics Syntax of DFA M: listing of its states, alphabet symbols, transitions, initial state, and final states Syntactic questions: How many states does M have? Is the set of final states empty? Semantics of DFA: the language L(M) Mathematical set that captures what it computes/solves Semantic questions: Is a particular string w in L(M)? Is the set L(M) empty? Is the set L(M) finite? Such distinction holds in all of computer science: Syntax of a program: text corresponding to its code Semantics of a program: Mathematical function it computes

Regular Languages A language L is called regular if there exists a DFA M such that L(M)=L That is: the problem encoded by the language L can be solved by a finite-state machine Examples of regular languages: { w | w contains an even number of a’s } { w | w ends with the symbol a } { w | w contains the substring “ACC” } Examples of non-regular languages: { w | count(w, a) = count(w, b) } { w | w encodes a graph where m has max number of connections }

Why Study DFAs and Regular Languages ? Introduction to mathematical theory of computation Precise definition of syntax and semantics Operations on models, variations, extensions Beautiful and robust theory dating back to 1960s Solvable decision problems Questions such as “are two machines semantically equivalent” are solvable for DFAs, but are unsolvable for general programs Applications Regular expressions for pattern matching in documents (supported by all modern programming languages) Modeling and verification of finite-state controllers/protocols

Another Example What language does this DFA accept? DFA M: L(M) = { w | w contains at least two a’s } q0 q1 a b q2 a,b

Does your DFA accept the correct language ? S = { a, b }, L = { w | w contains an even number of a’s } DFA M: How do you prove that M is correct, that is, M accepts exactly L ? b b a q0 q1 a

Proof of Correctness S = { a, b }, L = { w | count(w,a) is even } DFA M: To prove: For all strings w, M accepts w if and only if count(w,a) is even To prove: For all strings w, d*(q0, w) = q0 iff count(w,a) is even b b a q0 q1 a

Proof of Correctness q0 q1 a b To prove: For all strings w, d*(q0, w) = q0 iff count(w,a) is even Proof by induction on string length/structure: Base case : Prove the claim for w = e Inductive case: Assume that claim holds for an arbitrary string x Prove the claim for w = x.s, where s is a symbol (either a or b) Recall: d*(q, e) = q d*(q, x. s) = d ( d* (q, x), s)

Proof of Correctness: Base Case q0 q1 a b To prove: For all strings w, d*(q0, w) = q0 iff count(w,a) is even Base case : Prove the claim for w = e By definition of d*, d*(q0, e) = q0 The empty string has 0 number of a’s, which is an even number So the claim holds

Proof of Correctness: Inductive Case q0 q1 a b To prove: For all strings w, d*(q0, w) = q0 iff count(w,a) is even Assume that the claim holds for an arbitrary string x: that is, assume: d*(q0, x) = q0 iff count(x,a) is even Need to show the claim for w = x. s, where s is a symbol in { a, b } d*(q0, x) can be q0 or q1, and s can be a or b Gives four cases to consider. Let us consider the case d*(q0, x) = q0 and s = b, rest three are similar

Proof of Correctness: Inductive Case q0 q1 a b By induction hypothesis, d*(q0, x) = q0 iff count(x,a) is even To prove, for s in {a,b}, d*(q0, x. s) = q0 iff count(x. s,a) is even Case d*(q0, x) = q0 and s = b: In this case, by induction hypothesis, count(x,a) is even To prove: d*(q0, x.b) = q0 iff count(x.b,a) is even d*(q0, x.b) = d ( d* (q0, x), b) by defn. of d* = d (q0, b) = q0 by defn. of transition function of M Adding b to a string does not change the number of a’s it contains, so count(x.b, a) equals count(x, a), which is even in this case. QED

Another Example What language does this DFA accept? DFA M: Claim: L(M) = { w | w contains at least two a’s } q0 q1 a b q2 a,b

Proof of Correctness q0 q1 a b q2 a,b To prove: For all strings w, d*(q0, w) = q2 iff count(w,a) is at least 2 Proof by induction on string w: Base case : To prove: d*(q0, e) = q2 iff count(e,a) is at least 2 d*(q0, e) = q0 by definition of d* count(e,a) is 0 Thus, both “d*(q0, e) = q2 “ and “count(e,a) is at least 2” are false, and claim holds

Proof: Inductive Case q0 q1 a b q2 a,b Induction hypothesis, d*(q0, x) = q2 iff count(x,a) is at least 2 To prove, for s in {a,b}, d*(q0, x. s) = q2 iff count(x. s,a) is at least 2 Case d*(q0, x) = q0 and s = a: In this case, by induction hypothesis, count(x,a) < 2 To prove: d*(q0, x.a) = q2 iff count(x.a,a) is at least 2 The proof fails!! count(x,a)=1 and d*(q0, x) = q0 is consistent with the assumptions In such a case, count(x.a,a) = 2 but d*(q0, x.a) = d(q0, a) = q1 Claim does not hold. How to fix the proof ??

Stronger Claim For all strings w, d*(q0, w) = q0 if count(w,a) = 0 b q2 a,b For all strings w, d*(q0, w) = q0 if count(w,a) = 0 = q1 if count(w,a) = 1 = q2 if count(w,a) >= 2 This claim is stronger than the original claim: if we prove this, it follows that d*(q0, w) = q2 iff count(w,a) >= 2 Instead of just saying “strings in L lead to a final state and strings not in L lead to a non-final state”, we have strengthened the claim by identifying, for each state, which strings lead to that state

Correctness Proof q0 q1 a b q2 a,b To prove: For all strings w, d*(q0, w) = q0 if count(w,a) = 0 = q1 if count(w,a) = 1 = q2 if count(w,a) >= 2 Proof by induction on string w Base case: prove claim for w = e d*(q0, e) = q0 and count(e,a) is 0. The claim follows

Correctness Proof: Inductive case q0 q1 a b q2 a,b Assume that d*(q0, x) equals q0 if count(x,a) = 0, equals q1 if count(x,a) = 1, and equals q2 if count(x,a) >= 2 Prove that, for each s in {a, b}, d*(q0, x. s) equals q0 if count(x. s,a) = 0, equals q1 if count(x. s,a) = 1, and equals q2 if count(x. s,a) >= 2 Proof by cases: d*(q0, x) can be q0 or q1 or q2, and s can be a or b Case d*(q0, x) = q0 and s=a: count(x,a)=0 by induction hypothesis. count(x.a, a) = 1 d*(q0, x.a) = d(q0, a) by definition of d* = q1 by definition of d for the machine Remaining five cases are similar

Recipe for Proving Correctness of Automata Given a language L described by a mathematical constraint and a DFA M = ({q0, q1, … qn }, S, q0, F, d ), to prove that L(M) = L: Find a precise descriptions of the sets T0, T1, … Tn of strings that take the machine from initial state to the corresponding states Language L should match sets corresponding to final states Prove by induction on string w: For all w, d*(q0, w) = qi if w is in set Ti, for i=0, 1, … n Base case: prove claim for w = e Assume: d*(q0, x) = qi if x is in set Ti, for i=0, … n To prove: for each s in S, d*(q0, x.s) = qi if x.s is in set Ti, for i=0, … n Proof by case analysis on what s is and what d*(q0, x) is

Another Example = { a, b }, L = { w | either count(w,a) is even or w ends with b } DFA M: Prove: M accepts w if and only if w is in L q0 q1 a b q3 q2

Correctness Proof To prove: For all strings w, q0 q1 a b q3 q2 Correctness Proof To prove: For all strings w, d*(q0, w) = q0 if count(w,a) is even and w does not end with b = q1 if count(w,a) is odd and w does not end with b = q2 if count(w,a) is even and w ends with b = q3 if count(w,a) is odd and w ends with b The cases corresponding to final states cover the language L: that is, above claim implies that d*(q0, w) is in F iff either count(w,a) is even or w ends with b Prove the claim by induction on string w

Correctness Proof To prove: For all strings w, q0 q1 a b q3 q2 Correctness Proof To prove: For all strings w, d*(q0, w) = q0 if count(w,a) is even and w does not end with b = q1 if count(w,a) is odd and w does not end with b = q2 if count(w,a) is even and w ends with b = q3 if count(w,a) is odd and w ends with b Base Case: d*(q0, e) = q0 Count(e,a) = 0, which is even and e Does not end in a b.

Correctness Proof To prove: For all strings w, q0 q1 a b q3 q2 Correctness Proof To prove: For all strings w, d*(q0, w) = q0 if count(w,a) is even and w does not end with b = q1 if count(w,a) is odd and w does not end with b = q2 if count(w,a) is even and w ends with b = q3 if count(w,a) is odd and w ends with b Inductive case (one example): w = x.a and d*(q0, x) = q2 Count(x,a) is even and x ends in a b. d*(q0, x.a) = d(q2, a) = q1. Count(x.a,a) is odd and x.a does not end in a b.