E.g. The set RE of regular expressions is given by the following rules:

Similar documents
Extended transition function of a DFA

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

Lecture 1: Finite State Automaton

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

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

Solutions. CS 2800 Fall 2017 Final exam Friday, December 8. NetID: 1. Modular arithmetic [9 pts]

Lecture 1s Isomorphisms of Vector Spaces (pages )

Languages, regular languages, finite automata

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

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

COMP4141 Theory of Computation

(Refer Slide Time: 0:21)

Nondeterministic finite automata

Finite Automata and Regular Languages

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

11-711: Algorithms for NLP Homework Assignment #1: Formal Language Theory Solutions

Strong Induction (Second Principle) Example: There are two piles of cards, players take turn: each turn: one player removes any number of cards from

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

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

Takeaway Notes: Finite State Automata

Theory of Computation

Introduction to Theoretical Computer Science. Motivation. Automata = abstract computing devices

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

CMPSCI 250: Introduction to Computation. Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013

A non-turing-recognizable language

Nondeterministic Finite Automata

CS481F01 Solutions 8

Introduction to Finite-State Automata

Lecture 2: Connecting the Three Models

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

CS173 Strong Induction and Functions. Tandy Warnow

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Lecture 5: Minimizing DFAs

Chapter Five: Nondeterministic Finite Automata

Exam Computability and Complexity

1 More finite deterministic automata

CSC236 Week 10. Larry Zhang

What we have done so far

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

CS 124 Math Review Section January 29, 2018

Math 300: Final Exam Practice Solutions

Notes on Pumping Lemma

Theory of Computation

Lecture 3: Nondeterministic Finite Automata

Computability Crib Sheet

Exercise 2. Prove that [ 1, 1] is the set of all the limit points of ( 1, 1] = {x R : 1 <

NP-Completeness and Boolean Satisfiability

Further discussion of Turing machines

Proof Techniques (Review of Math 271)

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Lecture Notes: The Halting Problem; Reductions

CSCE 551 Final Exam, April 28, 2016 Answer Key

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

Computability and Complexity

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

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

Math 31 Lesson Plan. Day 5: Intro to Groups. Elizabeth Gillaspy. September 28, 2011

1 Functions, relations, and infinite cardinality

Algorithms for NLP

CS1800: Mathematical Induction. Professor Kevin Gold

Lecture 11: Measuring the Complexity of Proofs

Nondeterministic Finite Automata

CSE 460: Computabilty and Formal Languages. S. Pramanik

Computational Models - Lecture 1 1

Boolean circuits. Lecture Definitions

CS 154 Introduction to Automata and Complexity Theory

Regular expressions and Kleene s theorem

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

One-to-one functions and onto functions

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

Math 308 Midterm Answers and Comments July 18, Part A. Short answer questions

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

Deterministic Finite Automaton (DFA)

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

Theory of Computation

Finite Automata and Languages

CS 361 Meeting 26 11/10/17

Automata and Languages

Johns Hopkins Math Tournament Proof Round: Automata

Writing proofs for MATH 51H Section 2: Set theory, proofs of existential statements, proofs of uniqueness statements, proof by cases

CS 154, Lecture 4: Limitations on DFAs (I), Pumping Lemma, Minimizing DFAs

CS 208: Automata Theory and Logic

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

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Error Detection and Correction: Hamming Code; Reed-Muller Code

Computability and Complexity

TURING MAHINES

Regular expressions and Kleene s theorem

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

Chapter Two: Finite Automata

Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem

HOW TO WRITE PROOFS. Dr. Min Ru, University of Houston

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

Lecture 4: Constructing the Integers, Rationals and Reals

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

Computational Models #1

Transcription:

1 Lecture Summary We gave a brief overview of inductively defined sets, inductively defined functions, and proofs by structural induction We showed how to prove that a machine is correct using induction on strings Note: I include regular expressions in the examples below, although we did not cover them until the lecture after this one. 2 Inductively defined sets To define a set inductively, you give a collection of rules for constructing elements in the set from other elements; the set then consists of all elements that can be constructed by applying the rules a finite number of times. E.g. The set Σ of strings is given by the two rules: 1. ɛ Σ 2. If x Σ and a Σ then xa Σ E.g. The set RE of regular expressions is given by the following rules: 1. RE 2. ɛ RE 3. if a Σ then a RE 4. if r 1 and r 2 are elements of RE then r 1 r 2 RE 5. if r 1 and r 2 are elements of RE then r 1 r 2 RE 6. if r RE then r RE E.g. The set N is given by the following rules: 1. 0 N 2. If n N then n + 1 N 3 Inductively defined functions If X is an inductively defined set, we can define a function f with domain X recursively (I will use the terms inductive and recursive interchangably) by explaining how to evaluate f for elements constructed with each rule. For the rules that say something like if x X then xa X we get to make use of the definition of f(x) in our definition of f(xa). E.g. we can define the length function l : Σ N by 1

1. l(ɛ) = 0 2. l(xa) = 1 + l(x) (note we can make use of l(x) when defining l(xa)) E.g. last lecture we defined ˆδ : Q Σ Q inductively by 1. ˆδ(q, ɛ) = q 2. ˆδ(q, xa) = δ(ˆδ(q, x), a) (note we used ˆδ(q, x)) E.g. we can define the language function L : RE 2 Σ by 1. L( ) = 2. L(ɛ) = {ɛ} 3. L(a) = {a} 4. L(r 1 r 2 ) = {xy x L(r1) and y L(r2)} (note the use of L(r 1 ) and L(r 2 )) 5. L(r 1 r 2 ) = L(r 1 )UL(r 2 ) (note use of L(r 1 ) and L(r 2 )) 6. L(r ) = {x 1 x 2 x 3 x n x i L(r)} (note use of L(r)) E.g. we can define the plus 3 function p 3 : N N by 1. p 3 (0) = 3 2. p 3 (n + 1) = p 3 (n) + 1 E.g. we can define the binary interpretation function b : {0, 1} N by 1. b(ɛ) = 0 2. (a) b(x0) = 2 b(x) (b) b(x1) = 2 b(x) + 1 (we implicitly use this function below when we say x represents n ; we really mean b(x) = n) 4 Proofs by structural induction If X is an inductively defined set, we can prove statements of the form for all x X, P (x) by giving a proof for each of the rules defining the set X. When giving proofs for the rules that build a new element (e.g. xa) from a pre-existing element (e.g. x), we can assume P (x) in the proof of P (xa). E.g. Claim: for all strings x Σ, l(x) 0. Proof by induction on the structure of x. We must consider two cases: 1. x is the empty string; we must show l(ɛ) 0. 2

2. x is of the form ya; we must show l(ya) 0 but we may assume l(y) 0 Case 1: by definition, l(ɛ) = 0, so since 0 0, we have l(ɛ) 0. Case 2: Assume that l(y) 0. We must show l(ya) 0. By definition, l(ya) = 1 + l(y), which by our assumption is non-negative. E.g. Claim: For all regular expressions r RE, there exists an NFA N such that L(r) = L(N) Proof: see future lectures 5 Proof of correctness of an automata In the previous lecture, we constructed an automata by associating a fact with each state, and checking that each transition maintained the truth of the fact. We considered the following problem: to draw an automata that accepts any string that represents a multiple of 3 in binary. We derived the following automata for the language (given here in table form; you are encouraged to check this with your own picture!) Set of states: State Invariant q 0 x represents a multiple of 3 q 1 x represents 3k + 1 for some k x represents 3k + 2 for some k q 2 Transition function: State Input New state q 0 0 q 0 q 0 1 q 1 q 1 0 q 2 q 1 1 q 0 q 2 0 q 1 q 2 1 q 2 We reasoned that the start state should be q 0, because the empty string represents 0, which is a multiple of 3. We alsu argued that the final state should be q 0, because we wish to accept exactly the strings that represent multiples of 3. How could we prove that this machine does actually accept the correct language? Claim: L(M) = {x x represents a multiple of 3 in binary} Proof:? If we expand the definition of L(M), it becomes clear that induction on the input might be a good approach: Claim: for all x Σ, ˆδ(q 0, x) = q 0 if and only if x represents a multiple of 3 in binary. To avoid writing that over and over again, let s define P (x) to be that statement: 3

Let P (x) be the statement ˆδ(q 0, x) = q 0 if and only if x represents a multiple of 3 in binary. Claim: for all x Σ, P (x) Proof: by induction on the structure of x. There are two cases: (1) we must show P (ɛ), and (2) We must show P (xa), under the assumption P (x). Case 1: We must show that if ˆδ(q 0, ɛ) = q 0, then ɛ represents a multiple of 3. By definition, ɛ represents 0, so this clearly holds. Note: this base case is exactly the reasoning we went through when deciding where to put the initial state. Case 2: Assume that (if ˆδ(q 0, x) = q 0 then x represents a multiple of 3); we must show that if ˆδ(q 0, xa) = q 0 then xa represents a multiple of 3. To show this, let s assume that ˆδ(q 0, xa) = q 0. We must now show that xa represents a multiple of 3. Unfortunately, we don t know enough to finish the proof. The problem is that we can only apply the inductive hypothesis if ˆδ(q 0, x) = q 0, but that might not be the case! For example, if x was the string 111 and a was the character 1, then the inductive hypothesis would tell us that if ˆδ(q 0, x) happened to be q 0, then x would be a multiple of 3, but that s not helpful because in fact ˆδ(q 0, x) = q 1. In our informal reasoning for this case, we would have said since ˆδ(q 0, x) is q 1, we know that x represents 3k + 1 for some k, so x1 must represent 2 (3k + 1) + 1 = 6k + 3 which is a multiple of 3. We d like to be able to use our inductive hypothesis to say since ˆδ(q 0, x) is q 1, x must represent 3k+1 for some k. In fact, we d like our inductive hypothesis to say that whenever we get to some state, the corresponding invariant holds. Let s try doing exactly this. Let P (x) be the following statement: (a) if ˆδ(q 0, x) = q 0, then x represents 3k for some k, AND (b) if ˆδ(q 0, x) = q 1, then x represents 3k + 1 for some k, AND (c) if ˆδ(q 0, x) = q 2, then x represents 3k + 2 for some k. Claim: For all x Σ, P (x) Proof: by induction on the structure of x. We must consider two cases: Case 1: We must show P (ɛ). By definition of ˆδ, ˆδ(q 0, ɛ) = q 0, so parts (b) and (c) are vacuously true. That is, they both say if (false) then (something), which is always true. Part (a) is true because ɛ represents 3 0. Case 2: We must show P (xa), assuming the inductive hypothesis P (x). We must show all three parts of P (xa). 4

(a) Suppose that ˆδ(q 0, xa) = q 0. We want to show that xa represents 3k for some k. By looking at the definition of ˆδ and δ, we see that there are two possible ways for ˆδ(q 0, xa) = q 0 ; either i. ˆδ(q 0, x) = q 0 and a = 0. In this case, our inductive hypothesis says that since ˆδ(q 0, x) = q 0, that x represents 3k for some k. Therefore, xa represents 2 3k = 6k = 3 (2k). Therefore xa represents 3k for some k. Or, ii. ˆδ(q 0, x) = q 1 and a = 1. In this case, our inductive hypothesis says that since ˆδ(q 0, x) = q 1, that x represents 3k + 1 for some k. Therefore, xa represents 2 (3k + 1) + 1 = 6k + 3 = 3 (k + 1). Therefore xa represents 3k for some k. In both cases we have shown that xa represents 3k for some k, which is what was required for part (a). (b) Suppose that ˆδ(q 0, xa) = q 1. We want to show that xa represents 3k + 1 for some k. Again the definition of ˆδ and δ shows us that there are two ways for this to happen, namely, i. ˆδ(q 0, x) = q 0 and a = 1. In this case, the inductive hypothesis says [completion of this case left as exercise] and therefore xa represents 3k + 1 for some k. Or, ii. ˆδ(q 0, x) = q 2 and a = 0. [left as exercise] In both cases we have shown that xa represents 3k + 1 for some k, which is what was required for part (b). (c) [this part is left as an exercise] Since we have shown parts (a), (b), and (c) of P (xa) hold, we conclude that P (xa) holds. Since we have shown P (ɛ) and P (xa), we conclude that for any string x, P (x) holds. And the proof works out! I ve left some of the details to you; I encourage you to work them out to make sure you see what s going on. Also note that this proof is just a careful encoding of the informal reaonsing we did as we were designing the machine in the first place. You ll find that the complete proof has 6 sub-cases in the inductive step; one for each of the 6 transitions in the machine, and that the proofs of each of these subcases is exactly like the reasoning we did while drawing the corresponding transition. Although this proof has lots of cases and details, it follows a very simple structure. The key ideas are: 1. for each state q, write down a fact that you know about x if ˆδ(q 0, x) = q. 5

2. Combine all of these facts into P (x) 3. Do an inductive proof of P (x). You ll find that this will force you to check that every possible transition is correct. 6