CS 503 Spring semester 2015 WPI Most of the slides below are due to Jeffrey Ullman (one of our textbok’s authors). They are slides from a course he gave.

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Chapter Three: Closure Properties for Regular Languages
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.
Representation Application and Examples
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture3: Regular Expressions 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 Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
Finite Automata Motivation An Example.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Normal forms for Context-Free Grammars
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Definitions Equivalence to Finite Automata
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
What Are They? Who Needs ‘em? An Example: Scoring in Tennis Finite Automata 11.
Relations Chapter 9.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Regular Expressions. Notation to specify a language –Declarative –Sort of like a programming language. Fundamental in some languages like perl and applications.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
REGULAR LANGUAGES.
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Chapter 1 Introduction to the Theory of Computation.
Lecture 1 Computation and Languages CS311 Fall 2012.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Introduction to Finite Automata
CHAPTER 1 Regular Languages
Theory of Computation, Feodor F. Dragan, Kent State University 1 TheoryofComputation Spring, 2015 (Feodor F. Dragan) Department of Computer Science Kent.
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
CS 203: Introduction to Formal Languages and Automata
Introduction to Finite Automata
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
1 Decision Properties of Regular Languages General Discussion of “Properties” The Pumping Lemma Minimizing DFA.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Deterministic Finite Automata
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 Example: Graph of a DFA Start 1 0 ACB 1 0 0,1 Previous string OK, does not end in 1. Previous String OK, ends in a single 1. Consecutive 1’s have been.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Nondeterminism Subset Construction ε -Transitions.
  An alphabet is any finite set of symbols.  Examples: ASCII, Unicode, {0,1} ( binary alphabet ), {a,b,c}. Alphabets.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
Non Deterministic Automata
Copyright © Cengage Learning. All rights reserved.
Regular Expressions.
Finite Automata a b A simplest computational model
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Jaya Krishna, M.Tech, Assistant Professor
Finite Automata Motivation An Example.
REGULAR LANGUAGES AND REGULAR GRAMMARS
Hierarchy of languages
Non-Deterministic Finite Automata
Introduction to Finite Automata
Closure Properties of Regular Languages
Deterministic Finite Automaton (DFA)
AUTOMATA THEORY.
Turing Machines Everything is an Integer
CSCE 355 Foundations of Computation
Presentation transcript:

CS 503 Spring semester 2015 WPI Most of the slides below are due to Jeffrey Ullman (one of our textbok’s authors). They are slides from a course he gave … downloaded by me, and rearranged a bit, from spr10.html 1

Extended Example Thanks to Jay Misra for this example. On a distant planet, there are three species, a, b, and c. Any two different species can mate. If they do: 1.The participants die. 2.Two children of the third species are born. 2

Strange Planet – (2) Observation: the number of individuals never changes. The planet fails if at some point all individuals are of the same species. – Then, no more breeding can take place. State = sequence of three integers – the numbers of individuals of species a, b, and c. 3

Strange Planet with 2 Individuals acb

Strange Planet with 3 Individuals ac b a c bb a c State 111 has several transitions.

Strange Planet – Questions In a given state, must the planet eventually fail? In a given state, is it possible for the planet to fail, if the wrong breeding choices are made? 6

Questions – (2) These questions mirror real ones about protocols. –“ Can the planet fail? ” is like asking whether a protocol can enter some undesired or error state. –“ Must the planet fail ” is like asking whether a protocol is guaranteed to terminate. Here, “ failure ” is really the good condition of termination. 7

Strange Planet – Transitions An a-event occurs when individuals of species b and c breed and are replaced by two a ’ s. Analogously: b-events and c-events. Represent these by symbols a, b, and c, respectively. 8

Strange Planet with 2 Individuals acb Notice: all states are “ must-fail ” states.

Strange Planet with 3 Individuals ac b Notice: four states are “ must-fail ” states. The others are “ can ’ t-fail ” states a c bb a c State 111 has several transitions.

Strange Planet with 4 Individuals 11 Notice: states 400, etc. are must-fail states. All other states are “ might-fail ” states a cb bc a b ac ca b c ba ab c

Taking Advantage of Symmetry The ability to fail depends only on the set of numbers of the three species, not on which species has which number. Let ’ s represent states by the list of counts, sorted by largest-first. Only one transition symbol, x. 12

The Cases 2, 3, x x x x x x x Notice: for the case n = 4, there is nondeterminism : different transitions are possible from 211 on the same input.

5 Individuals Notice: 500 is a must-fail state; all others are might-fail states.

6 Individuals Notice: 600 is a must-fail state; 510, 420, and 321 are can ’ t-fail states; 411, 330, and 222 are “ might-fail ” states

7 Individuals Notice: 700 is a must-fail state; All others are might-fail states

Questions for Thought 1.Without symmetry, how many states are there with n individuals? 2.What if we use symmetry? 3.For n individuals, how do you tell whether a state is “ must-fail, ” “ might-fail, ” or “ can ’ t- fail ” ? 17

Introduction to Finite Automata Languages Deterministic Finite Automata Representations of Automata 18

Alphabets An alphabet is any finite set of symbols. Examples: ASCII, Unicode, {0,1} (binary alphabet ), {a,b,c}. 19

Strings The set of strings over an alphabet Σ is the set of lists, each element of which is a member of Σ. – Strings shown with no commas, e.g., abc. Σ * denotes this set of strings. ε stands for the empty string (string of length 0). 20

Example: Strings {0,1}* = { ε, 0, 1, 00, 01, 10, 11, 000, 001,... } Subtlety: 0 as a string, 0 as a symbol look the same. – Context determines the type. 21

Languages A language is a subset of Σ * for some alphabet Σ. Example: The set of strings of 0 ’ s and 1 ’ s with no two consecutive 1 ’ s. L = { ε, 0, 1, 00, 01, 10, 000, 001, 010, 100, 101, 0000, 0001, 0010, 0100, 0101, 1000, 1001, 1010,... } 22 Hmm… 1 of length 0, 2 of length 1, 3, of length 2, 5 of length 3, 8 of length 4. I wonder how many of length 5?

Deterministic Finite Automata A formalism for defining languages, consisting of: 1.A finite set of states (Q, typically). 2.An input alphabet ( Σ, typically). 3.A transition function ( δ, typically). 4.A start state (q 0, in Q, typically). 5.A set of final states (F ⊆ Q, typically).  “ Final ” and “ accepting ” are synonyms. 23

The Transition Function Takes two arguments: a state and an input symbol. δ (q, a) = the state that the DFA goes to when it is in state q and input a is received. 24

Graph Representation of DFA ’ s Nodes = states. Arcs represent transition function. – Arc from state p to state q labeled by all those input symbols that have transitions from p to q. Arrow labeled “ Start ” to the start state. Final states indicated by double circles. 25

Example: Graph of a DFA 26 Start 1 0 ACB 1 0 0,1 Previous string OK, does not end in 1. Previous String OK, ends in a single 1. Consecutive 1 ’ s have been seen. Accepts all strings without two consecutive 1 ’ s.

Alternative Representation: Transition Table AABBACCCCAABBACCCC Rows = states Columns = input symbols Final states starred * * Arrow for start state

Extended Transition Function We describe the effect of a string of inputs on a DFA by extending δ to a state and a string. Induction on length of string. Basis: δ (q, ε ) = q Induction: δ (q,wa) = δ ( δ (q,w),a) – w is a string; a is an input symbol. 28

Extended δ : Intuition Convention: – … w, x, y, x are strings. – a, b, c,… are single symbols. Extended δ is computed for state q and inputs a 1 a 2 …a n by following a path in the transition graph, starting at q and selecting the arcs with labels a 1, a 2,…,a n in turn. 29

Example: Extended Delta AABBACCCCAABBACCCC δ (B,011) = δ ( δ (B,01),1) = δ ( δ ( δ (B,0),1),1) = δ ( δ (A,1),1) = δ (B,1) = C

Delta-hat In book, the extended δ has a “ hat ” to distinguish it from δ itself. Not needed, because both agree when the string is a single symbol. δ (q, a) = δ ( δ (q, ε ), a) = δ (q, a) 31 ˄˄ Extended deltas

Language of a DFA Automata of all kinds define languages. If A is an automaton, L(A) is its language. For a DFA A, L(A) is the set of strings labeling paths from the start state to a final state. Formally: L(A) = the set of strings w such that δ (q 0, w) is in F. 32

33

Example: String in a Language 34 Start 1 0 ACB 1 0 0,1 String 101 is in the language of the DFA below. Start at A.

Example: String in a Language 35 Start 1 0 ACB 1 0 0,1 String 101 is in the language of the DFA below. Start at A.

Example: String in a Language 36 Start 1 0 ACB 1 0 0,1 Follow arc labeled 1. String 101 is in the language of the DFA below.

Example: String in a Language 37 Start 1 0 ACB 1 0 0,1 Then arc labeled 0 from current state B. String 101 is in the language of the DFA below.

Example: String in a Language 38 Start 1 0 ACB 1 0 0,1 Finally arc labeled 1 from current state A. Result is an accepting state, so 101 is in the language. String 101 is in the language of the DFA below.

Example – Concluded The language of our example DFA is: {w | w is in {0,1}* and w does not have two consecutive 1 ’ s} 39 Read a set former as “ The set of strings w… Such that… These conditions about w are true.

Proofs of Set Equivalence Often, we need to prove that two descriptions of sets are in fact the same set. Here, one set is “ the language of this DFA, ” and the other is “ the set of strings of 0 ’ s and 1 ’ s with no consecutive 1 ’ s. ” 40

Proofs – (2) In general, to prove S=T, we need to prove two parts: S ⊆ T and T ⊆ S. That is: 1.If w is in S, then w is in T. 2.If w is in T, then w is in S. As an example, let S = the language of our running DFA, and T = “ no consecutive 1 ’ s. ” 41

Part 1: S ⊆ T To prove: if w is accepted by then w has no consecutive 1 ’ s. Proof is an induction on length of w. Important trick: Expand the inductive hypothesis to be more detailed than you need. 42 Start 1 0 ACB 1 0 0,1

The Inductive Hypothesis 1.If δ (A, w) = A, then w has no consecutive 1 ’ s and does not end in 1. 2.If δ (A, w) = B, then w has no consecutive 1 ’ s and ends in a single 1. Basis: |w| = 0; i.e., w = ε. – (1) holds since ε has no 1 ’ s at all. – (2) holds vacuously, since δ (A, ε ) is not B. 43 “ length of ” Important concept: If the “ if ” part of “ if..then ” is false, the statement is true.

Inductive Step Assume (1) and (2) are true for strings shorter than w, where |w| is at least 1. Because w is not empty, we can write w = xa, where a is the last symbol of w, and x is the string that precedes. IH is true for x. 44 Start 1 0 ACB 1 0 0,1

Inductive Step – (2) Need to prove (1) and (2) for w = xa. (1) for w is: If δ (A, w) = A, then w has no consecutive 1 ’ s and does not end in 1. Since δ (A, w) = A, δ (A, x) must be A or B, and a must be 0 (look at the DFA). By the IH, x has no 11 ’ s. Thus, w has no 11 ’ s and does not end in Start 1 0 ACB 1 0 0,1

Inductive Step – (3) Now, prove (2) for w = xa: If δ (A, w) = B, then w has no 11 ’ s and ends in 1. Since δ (A, w) = B, δ (A, x) must be A, and a must be 1 (look at the DFA). By the IH, x has no 11 ’ s and does not end in 1. Thus, w has no 11 ’ s and ends in Start 1 0 ACB 1 0 0,1

Part 2: T ⊆ S Now, we must prove: if w has no 11 ’ s, then w is accepted by Contrapositive : If w is not accepted by then w has Start 1 0 ACB 1 0 0,1 Start 1 0 ACB 1 0 0,1 Key idea: contrapositive of “ if X then Y ” is the equivalent statement “ if not Y then not X. ” X Y

Using the Contrapositive Every w gets the DFA to exactly one state. – Simple inductive proof based on: Every state has exactly one transition on 1, one transition on 0. The only way w is not accepted is if it gets to C. 48 Start 1 0 ACB 1 0 0,1

Using the Contrapositive – (2) The only way to get to C [formally: δ (A,w) = C] is if w = x1y, x gets to B, and y is the tail of w that follows what gets to C for the first time. If δ (A,x) = B then surely x = z1 for some z. Thus, w = z11y and has Start 1 0 ACB 1 0 0,1

Regular Languages A language L is regular if it is the language accepted by some DFA. – Note: the DFA must accept only the strings in L, no others. Some languages are not regular. – Intuitively, regular languages “ cannot count ” to arbitrarily high integers. 50

Example: A Nonregular Language L 1 = {0 n 1 n | n ≥ 1} Note: a i is conventional for i a ’ s. – Thus, 0 4 = 0000, e.g. Read: “ The set of strings consisting of n 0 ’ s followed by n 1 ’ s, such that n is at least 1. Thus, L 1 = {01, 0011, ,…} 51

Another Example L 2 = {w | w in {(, )}* and w is balanced } – Note: alphabet consists of the parenthesis symbols ’ ( ’ and ’ ) ’. – Balanced parens are those that can appear in an arithmetic expression. E.g.: (), ()(), (()), (()()),… 52

But Many Languages are Regular Regular Languages can be described in many ways, e.g., regular expressions. They appear in many contexts and have many useful properties. Example: the strings that represent floating point numbers in your favorite language is a regular language. 53

Example: A Regular Language L 3 = { w | w in {0,1}* and w, viewed as a binary integer is divisible by 23} The DFA: – 23 states, named 0, 1,…,22. – Correspond to the 23 remainders of an integer divided by 23. – Start and only final state is 0. 54

Transitions of the DFA for L 3 If string w represents integer i, then assume δ (0, w) = i%23. Then w0 represents integer 2i, so we want δ (i%23, 0) = (2i)%23. Similarly: w1 represents 2i+1, so we want δ (i%23, 1) = (2i+1)%23. Example: δ (15,0) = 30%23 = 7; δ (11,1) = 23%23 = Key idea: design a DFA by figuring out what each state needs to remember about the past.

Another Example L 4 = { w | w in {0,1}* and w, viewed as the reverse of a binary integer is divisible by 23} Example: is in L 4, because its reverse, is 46 in binary. Hard to construct the DFA. But theorem says the reverse of a regular language is also regular. 56