Machines That Can’t Count CS 15-251 Lecture 15 b b a b a a a b a b.

Slides:



Advertisements
Similar presentations
Lecture 24 MAS 714 Hartmut Klauck
Advertisements

THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
Deterministic Finite Automata (DFA)
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.
CS21 Decidability and Tractability
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CS5371 Theory of Computation
Great Theoretical Ideas in Computer Science.
1 Module 15 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
1 Languages and Finite Automata or how to talk to machines...
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Chapter 9 Turing Machine (TMs).
Great Theoretical Ideas in Computer Science.
Cantor’s Legacy: Infinity And Diagonalization Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 25Apr 13, 2004Carnegie.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Section 14.2 A Hierarchy of Languages Context-Sensitive Languages A context-sensitive grammar has productions of the form xAz  xyz, where A is a nonterminal.
Does not Compute 4: Finite Automata In which we temporarily admit defeat with cellular automata (we will face them again, in the epic final “Does Not Compute”
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
Great Theoretical Ideas in Computer Science.
Languages Given an alphabet , we can make a word or string by concatenating the letters of . Concatenation of “x” and “y” is “xy” Typical example: 
Regular Grammars Chapter 7. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
D E C I D A B I L I T Y 1. 2 Objectives To investigate the power of algorithms to solve problems. To explore the limits of algorithmic solvability. To.
CS 203: Introduction to Formal Languages and 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.
Deterministic Finite Automata COMPSCI 102 Lecture 2.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 10Sept Carnegie Mellon University b b a b a a a b a b One.
Lecture Notes 
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2006 Lecture 22 November 9, 2006Carnegie Mellon University b b a b a a a b a b.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Great Theoretical Ideas in Computer Science for Some.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
To Infinity And Beyond! CS Lecture 11 The Ideal Computer: no bound on amount of memory Whenever you run out of memory, the computer contacts the.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2005 Lecture 9Feb Carnegie Mellon University b b a b a a a b a b One Minute.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Languages.
Chapter 2 Finite Automata
Pushdown Automata.
Pushdown Automata.
Hierarchy of languages
CS 154, Lecture 3: DFANFA, Regular Expressions.
Non Deterministic Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Great Theoretical Ideas in Computer Science
CS21 Decidability and Tractability
Formal Languages, Automata and Models of Computation
One Minute To Learn Programming: Finite Automata
Recap lecture 18 NFA corresponding to union of FAs,example, NFA corresponding to concatenation of FAs,examples, NFA corresponding to closure of an FA,examples.
Decidability continued….
Presentation transcript:

Machines That Can’t Count CS Lecture 15 b b a b a a a b a b

Let me teach you a programming language so simple that you can learn it in less than a minute.

Meet “ABA” The Automaton! b b a b a a a b a b Input String Result abaAccept aabbReject aabbaAccept Accept

The Simplest Interesting Machine: Finite State Machine OR Finite Automaton

Finite set of states A start state A set of accepting states A finite alphabet a b # x 1 x 1 State transition instructions Finite Automaton

How it works At any point in time, it’s in one of its states (or it has crashed). It starts in its start state. It “reads” one letter at a time from the input string (going from left to right).

If it is in state q i and reads a then If it has the transition Then it changes to state q j Else it crashes

M accepts the string x if when M reads x it ends in an accepting state. M rejects the string x if when M reads x it ends in a non- accepting state. M crashes on x if M crashes while reading x. Let M=(Q, ,F,  ) be a finite automaton.

The set (or language) accepted by M is: Notice that this is 

What is the language accepted by this machine? L = {a,b}* = all finite strings of a ’s and b ’s a,b

What is the language accepted by this machine? L = all even length strings of a ’s and b ’s a,b

What machine accepts this language? L = all strings in {a,b}* that contain at least one a a a,b b

What machine accepts this language? L = strings with an odd number of b ’s and any number of a ’s b a a b

What is the language accepted by this machine? L = any string ending with a b b b a a

What is the language accepted by this machine? L = any string with at least two a ’s b b a,b a a

What machine accepts this language? L = any string with an a and a b b b a,b a a b a

What machine accepts this language? L = strings with an even number of ab pairs a b b a a b a b

L = all strings containing ababb as a consecutive substring b a,b a a b b b b a a a a ab aba abab  If I am in state “ aba ” then the longest prefix of ababb that forms a suffix of the string I have read until now is aba.

Problem: Does the string S appear inside the text T ? The “grep” Problem Input: text T of length t string S of length n Cost: O(nt) comparisons Naïve method:

Automata Solution Build a machine M that accepts any string with S as a consecutive substring. Feed the text to M. Cost: t comparisons + time to build M. As luck would have it, the Knuth, Morris, Pratt algorithm builds M quickly. By the way, it can be done with fewer than t comparisons in the worst case!

Real-life uses of finite state machines grep coke machines thermostats (fridge) elevators train track switches lexical analyzers for parsers

Let L    be a language. L is called a regular language if there is some finite automaton that accepts L. In this lecture we have seen many regular languages.   even length strings strings containing ababb

Theorem: Any finite langage is regular. Proof: Make a machine wth a “path” for each string in the language. Example: L = {a, bcd, ac, bb} b d a c b c

Are all languages regular?

NO! Counting Argument There are uncountably many L    There are countably many automata (each automaton can be specified by a finite string)

NO! Halting Argument K = { P | P(P)  } is undecidable for ideal computers with unlimited memory, i.e., K is not recursive. Finite automata can be simulated by computers. (they are a weak sub-class)

The fact that not all languages are regular can be argued more directly (without resorting to macho techniques).

Consider the language i.e., a bunch of a ’s followed by an equal number of b ’s No finite automaton accepts this language. Can you prove this?

APE 0835 a n b n is not regular. No machine has enough states to keep track of the number of a ’s it might encounter.

That is a fairly weak argument. Consider the following example…

Can’t be regular. No machine has enough states to keep track of the number of occurrences of ab. L = strings where the # of occurrences of the pattern ab is equal to the number of occurrences of the pattern ba

Remember “ABA”? b b a b a a a b a b ABA accepts only the strings with an equal number of ab ’s and ba ’s!

Professional Strength Proof Theorem: a n b n is not regular. Proof: Assume that it is. Then  M with k states that accepts it. For each 0  i  k, let S i be the state M is in after reading a i.  i,j  k s.t. S i = S j, but i  j M will do the same thing on a i b i and a j b i. (to S i  ) (to S i  ) But a valid M must reject a j b i and accept a i b i. 

MORAL: Finite automata can’t count.

Advertisement You can learn much more about these creatures in the FLAC course. Formal Languages, Automata, and Computation There is a unique smallest automata for any regular language It can be found by a fast algorithm. ……

Cellular Automata Line up a bunch of identical finite automata in a straight line. Transitions are based on the states of the machine’s two neighbors or an indicator that a neighbor is missing. (There is no other input.) All cells move to their next states at the same time: synchronous transition

The Firing Squad Problem Five “soldiers” all start in the sleep state. You change the one on the left to the wake state. All five must get to the fire state at the same time (for the first time). sleep wake fire sleep wake fire sleep wake fire sleep wake fire sleep wake fire sleep wake fire sleep wake fire sleep wake fire sleep wake fire sleep wake fire

Shorthand Means use this transition when your left neighbor is in any state at all and your right neighbor is in state a, b, or d.

wakesleepsleepsleepsleep 2wake2sleepsleepsleepsleep 3wake3wake3wake3sleepsleep 4wake4wake4wake4wake4sleep 5firefirefirefirefire sleep wake wake2 wake3 wake4 fire! {w2},Q {w},Q {w3},Q Q,Q {w4},Q {sleep,fire,end},Q Q,Q

Question No. Finite automata can’t count! Can you build the soldier’s finite automaton brain before you know how many soldiers will be in the line?

Don’t jump to conclusions! It is possible to design a single cellular automaton that works for any number of soldiers!

Useful subroutine: method to find the center after leftmost soldier is awakened. Define the center of the line to be: The guy in the middle if the # of soldiers is odd. The two guys in the middle if the the # of soldiers is even.

Your neighbor “notices” that you are in a signaling state. An automaton can “signal” to its neighbors. Certain subsets of its states will correspond to signaling. signal normal operation

A Method to Find the Center Send a signal back and forth from “end” to “end”. Each time it gets to an “end”, send it back, but tell the neighbor of the “end” that it is the “new end”. The center(s) will get a “new end” signal from both sides. # of steps:

Slick Center Algorithm Use two signals: one fast and one slow When you get the fast signal, pass it on (or bounce it back) on the next time step. When you get the slow signal, hold it for two steps, then pass it on the next time step. When you wake and you are leftmost, consider yourself to hold both the slow and fast signal. If you get one signal from each side, shout, “I am the center!”

Firing Squad Problem Keep finding the middle recursively: If you’re the center, mark yourself as an “end” and find the centers on each side of you. If you are an “end” and your neighbor is starting both signals, send back a “fire next step”.

Firing Squad Analysis How many steps to find the center? How many steps to fire?

Lowed Bound Can you see why any solution must use at least 2n steps? There is a clever way to do it in 2n steps.

Other Research Different topologies Self-stabilizing clocks all cells fire simultaneously at regular intervals even if you mess with the states of all the cells they get back on schedule (eventually)