One Minute To Learn Programming: Finite Automata



Similar documents
Homework 3 Solutions

Regular Sets and Expressions

flex Regular Expressions and Lexical Scanning Regular Expressions and flex Examples on Alphabet A = {a,b} (Standard) Regular Expressions on Alphabet A

Reasoning to Solve Equations and Inequalities

FORMAL LANGUAGES, AUTOMATA AND THEORY OF COMPUTATION EXERCISES ON REGULAR LANGUAGES

Regular Languages and Finite Automata

Appendix D: Completing the Square and the Quadratic Formula. In Appendix A, two special cases of expanding brackets were considered:

Binary Representation of Numbers Autar Kaw

Solution to Problem Set 1

Example 27.1 Draw a Venn diagram to show the relationship between counting numbers, whole numbers, integers, and rational numbers.

Solving the String Statistics Problem in Time O(n log n)

Unambiguous Recognizable Two-dimensional Languages

Polynomial Functions. Polynomial functions in one variable can be written in expanded form as ( )

A Visual and Interactive Input abb Automata. Theory Course with JFLAP 4.0

FAULT TREES AND RELIABILITY BLOCK DIAGRAMS. Harry G. Kwatny. Department of Mechanical Engineering & Mechanics Drexel University

Automated Grading of DFA Constructions

CS99S Laboratory 2 Preparation Copyright W. J. Dally 2001 October 1, 2001

2 DIODE CLIPPING and CLAMPING CIRCUITS

MATH 150 HOMEWORK 4 SOLUTIONS

Protocol Analysis / Analysis of Software Artifacts Kevin Bierhoff

Geometry 7-1 Geometric Mean and the Pythagorean Theorem

How fast can we sort? Sorting. Decision-tree model. Decision-tree for insertion sort Sort a 1, a 2, a 3. CS Spring 2009

Basic Research in Computer Science BRICS RS Brodal et al.: Solving the String Statistics Problem in Time O(n log n)

Mathematics. Vectors. hsn.uk.net. Higher. Contents. Vectors 128 HSN23100

LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES

Angles 2.1. Exercise Find the size of the lettered angles. Give reasons for your answers. a) b) c) Example

Bayesian Updating with Continuous Priors Class 13, 18.05, Spring 2014 Jeremy Orloff and Jonathan Bloom

Java CUP. Java CUP Specifications. User Code Additions You may define Java code to be included within the generated parser:

APPLICATION NOTE Revision 3.0 MTD/PS-0534 August 13, 2008 KODAK IMAGE SENDORS COLOR CORRECTION FOR IMAGE SENSORS

Vectors Recap of vectors

Integration by Substitution

Section 5-4 Trigonometric Functions

and thus, they are similar. If k = 3 then the Jordan form of both matrices is

PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY

DlNBVRGH + Sickness Absence Monitoring Report. Executive of the Council. Purpose of report

Brillouin Zones. Physics 3P41 Chris Wiebe

Treatment Spring Late Summer Fall Mean = 1.33 Mean = 4.88 Mean = 3.

Unit 6: Exponents and Radicals

Graphs on Logarithmic and Semilogarithmic Paper

Lec 2: Gates and Logic

0.1 Basic Set Theory and Interval Notation

Solutions for Selected Exercises from Introduction to Compiler Design

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall Final Exam

Chapter. Contents: A Constructing decimal numbers

Babylonian Method of Computing the Square Root: Justifications Based on Fuzzy Techniques and on Computational Complexity

Math 135 Circles and Completing the Square Examples

A.7.1 Trigonometric interpretation of dot product A.7.2 Geometric interpretation of dot product

Example A rectangular box without lid is to be made from a square cardboard of sides 18 cm by cutting equal squares from each corner and then folding

Quick Reference Guide: One-time Account Update

Lecture 3 Gaussian Probability Distribution

Words Symbols Diagram. abcde. a + b + c + d + e

WHAT HAPPENS WHEN YOU MIX COMPLEX NUMBERS WITH PRIME NUMBERS?

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 16 th May Time: 14:00 16:00

String Searching. String Search. Spam Filtering. String Search

EQUATIONS OF LINES AND PLANES

Welch Allyn CardioPerfect Workstation Installation Guide

Automata theory. An algorithmic approach. Lecture Notes. Javier Esparza

Learning Outcomes. Computer Systems - Architecture Lecture 4 - Boolean Logic. What is Logic? Boolean Logic 10/28/2010

NQF Level: 2 US No: 7480

1. In the Bohr model, compare the magnitudes of the electron s kinetic and potential energies in orbit. What does this imply?

Concept Formation Using Graph Grammars

AntiSpyware Enterprise Module 8.5

1.2 The Integers and Rational Numbers

Multiplication and Division - Left to Right. Addition and Subtraction - Left to Right.

License Manager Installation and Setup

Algebra Review. How well do you remember your algebra?

19. The Fermat-Euler Prime Number Theorem

5.2. LINE INTEGRALS 265. Let us quickly review the kind of integrals we have studied so far before we introduce a new one.

Use Geometry Expressions to create a more complex locus of points. Find evidence for equivalence using Geometry Expressions.

Factoring Polynomials

A Network Management System for Power-Line Communications and its Verification by Simulation

Pentominoes. Pentominoes. Bruce Baguley Cascade Math Systems, LLC. The pentominoes are a simple-looking set of objects through which some powerful

Operations with Polynomials

Helicopter Theme and Variations

P.3 Polynomials and Factoring. P.3 an 1. Polynomial STUDY TIP. Example 1 Writing Polynomials in Standard Form. What you should learn

SPECIAL PRODUCTS AND FACTORIZATION

FUNCTIONS AND EQUATIONS. xεs. The simplest way to represent a set is by listing its members. We use the notation

5 a LAN 6 a gateway 7 a modem

Second Term MAT2060B 1. Supplementary Notes 3 Interchange of Differentiation and Integration

SE3BB4: Software Design III Concurrent System Design. Sample Solutions to Assignment 1

. At first sight a! b seems an unwieldy formula but use of the following mnemonic will possibly help. a 1 a 2 a 3 a 1 a 2

Outline of the Lecture. Software Testing. Unit & Integration Testing. Components. Lecture Notes 3 (of 4)

Data Compression. Lossless And Lossy Compression

Lecture 5. Inner Product

Quick Guide to Lisp Implementation

Review guide for the final exam in Math 233

Or more simply put, when adding or subtracting quantities, their uncertainties add.

New Internet Radio Feature

The remaining two sides of the right triangle are called the legs of the right triangle.

, and the number of electrons is -19. e e C. The negatively charged electrons move in the direction opposite to the conventional current flow.

Physics 43 Homework Set 9 Chapter 40 Key

Transcription:

Gret Theoreticl Ides In Computer Science Steven Rudich CS 15-251 Spring 2005 Lecture 9 Fe 8 2005 Crnegie Mellon University One Minute To Lern Progrmming: Finite Automt

Let me tech you progrmming lnguge so simple tht you cn lern it in less thn minute.

Meet ABA The Automton! Input String ε Result Accept Reject Accept Accept

The Simplest Interesting Mchine: Finite Stte Mchine OR Finite Automton

Finite Automton Finite set of sttes o 1 2 A strt stte Q = { q, q, q,, q } q o k A set of ccepting sttes A finite lphet Stte trnsition instructions # qi x 1 q j { } i i i F = q, q,, q 1 2 r : Q ( q, ) = i Σ q j Q

How Mchine M opertes. M reds one letter t time from the input string (going from left to right) M strts in stte q 0. If M is in stte q i reds the letter then If δ(q i. ) is undefined then CRASH. Otherwise M moves to stte δ(q i,)

Let M=(Q,S,F,d) e finite utomton. M ccepts the string x if when M reds x it ends in n ccepting stte. M rejects the string x if when M reds x it ends in nonccepting stte. M crshes on x if M crshes while reding x.

The set (or lnguge) ccepted y M is: M { * } L = x M ccepts x k All length k strings over the lphet * 0 1 2 3... Notice tht this is {ε}

Wht is the lnguge ccepted y this mchine?, L = {,}* = ll finite strings of s nd s

Wht is the lnguge ccepted y this mchine?,, L = ll even length strings of s nd s

Wht mchine ccepts this lnguge? L = ll strings in {,}* tht contin t lest one,

Wht mchine ccepts this lnguge? L = strings with n odd numer of s nd ny numer of s

Wht is the lnguge ccepted y this mchine? L = ny string ending with

Wht is the lnguge ccepted y this mchine?, L = ny string with t lest two s

Wht mchine ccepts this lnguge? L = ny string with n nd,

Wht mchine ccepts this lnguge? L = strings with n even numer of pirs

L = ll strings contining s consecutive sustring, ε Invrint: I m stte s exctly when s is the longest suffix of the input (so fr) tht forms prefix of.

The grep Prolem Input: text T of length t string S of length n Nïve method: Prolem: Does the string S pper inside the text T? n symols,,,, 1 2 3 t Cost: O(nt) comprisons

Automt Solution Build mchine M tht ccepts ny string with S s consecutive sustring. Feed the text to M. Cost: t comprisons + time to uild M. As luck would hve it, the Knuth, Morris, Prtt lgorithm uilds M quickly. By the wy, it cn e done with fewer thn t comprisons in the worst cse!

Rel-life uses of finite stte mchines grep coke mchines thermostts (fridge) elevtors trin trck switches lexicl nlyzers for prsers

Any L Σ is defined to e lnguge. L is just set of strings. It is clled lnguge for historicl resons.

Let L Σ e lnguge. L is clled regulr lnguge if there is some finite utomton tht ccepts L. In this lecture we hve seen mny regulr lnguges. Σ even length strings strings contining

Theorem: Any finite lngge is regulr. Proof: Mke mchine with pth for ech string in the lnguge. Exmple: L = {, cd, c, } c c d

Are ll lnguges regulr?

Consider the lnguge n n = { ε,,,, } i.e., unch of s followed y n equl numer of s No finite utomton ccepts this lnguge. Cn you prove this?

n n is not regulr. No mchine hs enough sttes to keep trck of the numer of s it might encounter.

Tht is firly wek rgument. Consider the following exmple

L = strings where the # of occurrences of the pttern is equl to the numer of occurrences of the pttern Cn t e regulr. No mchine hs enough sttes to keep trck of the numer of occurrences of.

Rememer ABA? ABA ccepts only the strings with n equl numer of s nd s!

Let me show you professionl strength proof tht n n is not regulr.

Professionl Strength Proof Theorem: n n is not regulr. Proof: Assume tht it is. Then M with k sttes tht ccepts it. For ech 0 i k, let S i e the stte M is in fter reding i. i,j k s.t. S i = S j, ut i j M will do the sme thing on i i nd j i. But vlid M must reject j i nd ccept i i.

MORAL: Finite utomt cn t count.

Advertisement You cn lern much more out these cretures in the FLAC course. Forml Lnguges, Automt, nd Computtion There is unique smllest utomton for ny regulr lnguge It cn e found y fst lgorithm.

Cellulr Automt Line up unch of identicl finite utomt in stright line. qi q k q j Trnsitions re sed on the sttes of the mchine s two neighors or n indictor tht neighor is missing. (There is no other input.) Q Q Q Q ( q, q, q ) k i j l = q qk q, q i j ql All cells move to their Steven next Rudich: sttes t the sme time: synchronous trnsition

The Firing Squd Prolem Five soldiers ll strt in the stte. You chnge the one on the left to the wke stte. All five must get to the fire stte t the sme time (for the first time). wke fire wke fire wke fire wke fire wke fire wke fire wke fire wke fire wke fire wke fire

Shorthnd { d} Q,,, Mens use this trnsition when your left neighor is in ny stte t ll nd your right neighor is in stte,, or d.

{,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! 1 2 3 4 5

{,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! 1 2 3 4 5 wke

{,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! 1 2 3 4 5 wke wke2 wke2

{,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! 1 2 3 4 5 wke wke2 wke2 wke3 wke3 wke3

{,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! 1 2 3 4 5 wke wke2 wke2 wke3 wke3 wke3 wke4 wke4 wke4 wke4

{,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! 1 2 3 4 5 wke wke2 wke2 wke3 wke3 wke3 wke4 wke4 wke4 wke4 fire fire fire fire fire

Question Cn you uild the soldier s finite utomton rin efore you know how mny soldiers will e in the line? No. Finite utomt cn t count!

Don t jump to conclusions! It is possile to design single cellulr utomton tht works for ny numer of soldiers!