Download Presentation
## final project ideas and FSMs

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**Welcome!**April and May in IST380 4/21+28 ~ FSMs 5/5 ~ project work final project ideas and FSMs Final milestone due 5/7 Final project due 5/14 hw7-9 now graded! assignments 9 and 10 final project work sessions project: milestone + final**CS in the abstract… ?!**(1) define "computer" precisely (2) define "compute" precisely (3) see what computers provablycan't compute (4) go to step (1) and define things better (5) Or, head back to programming! Foundational Ideas…**In CS, the computer doesn't matter!**this may seem big-O(bvious) recently… Quantum interactions with DNA or RNA Silicon-based switching Mechanical computation Using marbles! We want to capture the fundamental processes of all of these machines...**The Mark 1**relay-based computer http://www-03.ibm.com/ibm/history/exhibits/markI/markI_reference.html Grace Hopper + Howard Aiken, Harvard ~ 1944 ran at 0.00001 MHz 5 tons 530 miles of wiring 765,299 distinct parts! Addition: 0.6 seconds Multiplication: 5.7 seconds Division: 15.3 seconds**Grace Hopper**Grace Murray Hopper ’28 taught math and physics at Vassar for 12 years before joining the Navy reserves in 1943. During the war she learned to program the Mark I, the world’s first large-scale computer, which was used to perform the calculations needed to position the Navy’s weaponry: guns, mines, rockets, and, eventually, the atomic bomb. In 1945, she coined the term “debugging” after finding a moth stuck in the computer’s machinery. Over the course of her career, Hopper invented the compiler to automate common computer instructions, became the first to start writing computer programs in English, and helped to develop the first “user-friendly” computer language, COBOL GMH dedications “In the days they used oxen for heavy pulling, when one ox couldn't budge a log, they didn't try to grow a larger ox. We shouldn't be trying for bigger and better computers, but for better systems of computers.”**The first bug?**I'm glad it's not called demothing.**Unifying idea: State**0 NEWx -> S 1 next state previous state next step external input literally! The state of a computation is all the internal information needed to take its next step**Computation is simply a deliberate sequence of state-changes**doesn't seem very meaningful 0110110101011010010001 0110110101000000001110 bits before bits after**A computer? FSMs**That's a 2-bit computer! “Finite State Machine” Deterministic 0 0 Every state has one transition for every possible character. 1 q0 q1 1 Finite start state transition final (accepting) state key resource is number of states “input funnel” “where to go” double circled 00101 Example Inputs: 100011 What is the language this FSM accepts?**Try it!**0 1 s1 1 s0 0 s2 0,1 List three different inputs that this FSM accepts: List three different inputs that this FSM rejects: In general, what English phrase describes the accepted inputs? This machine accepts strings that… s0 means the input… What does each state say about the current state of the input?!? s1 means the input… s2 means the input…**Draw a FSM accepting strings in which the number of zeros**(0s) is a multiple of 3, so there are 0, 3, 6, … zeros. 1s don't matter. Build-your-own FSMs Draw a FSM that accepts strings that don't contain the pattern 110 anywhere. Accepted: 110101110, 11, 0000010 Rejected: 101, 0000, 111011101111 Hint: modify the first FSM we considered! Accepted: 1010001 Rejected: 101001100 Hint: modify the previous FSM! Draw a FSM accepting strings in which the third digit (from the left) is a 1. Draw a FSM accepting strings whose third-to-last digit (from the right) is a 1. Accepted: 1010001 Rejected: 11000100 and 11 Accepted: 0100 and 01101 Rejected: 101001 and 11 Extra: Do your solutions use the minimum possiblenumber of states?**No occurrences of 110**Draw a FSM accepting strings that do NOT anywhere contain the pattern 110 0 start end w/1 end w/11 fail! 1 0 1 Minimum possiblenumber of states?**No occurrences of 110?**0,1 0 1 0 1 Why doesn't this machine work?**Number of 0s is div. by 3**Draw a FSM accepting strings in which the number of zeros (0s) is a multiple of 3, so there are 0, 3, 6, … zeros. 1s don't matter. Accepted: 110101110, 11, 0000010 Rejected: 101, 0000, 111011101111 Minimum possiblenumber of states?**Third character is a 1**Draw a FSM accepting strings in which the third digit (from the left) is a 1. Accepted: 1010001 Rejected: 11000100 and 11 Minimum possiblenumber of states?**Third-to-last character is a 1?**Draw a FSM accepting strings whose third-to-last digit (from the right) is a 1. Accepted: 0100 and 01101 Rejected: 101001 and 11 Minimum possiblenumber of states?**s**s110 s111 s000 s001 s010 s011 s100 s101 s11 s10 s01 s00 s0 s1 Third-to-last character is a 1 1 0 1 0 0 1 1 1 0 1 0 1 0 0 Something seems missing…**s111**s000 s001 s010 s011 s100 s101 s110 Third-to-last character is a 1 8 states? Can we do better than 8 states?**FSMs are everywhere!**qstart q1 q2 q3 q4 q5 Locks q12 q13 q14 q15 q23 q12,3 q12,4 q12,5 There’s a lot missing here! q12,5,34**FSMs are everywhere!**penny, fifty cent piece, silver dollar, Canadian currency, Euro, …. qstart nickel select drink dime quarter q5 cents q10 cents q25 cents nickel dime mechanical vending machine nickel nickel q15 cents q20 cents nickel (some transitions not shown)**FSM ~ Game AI**The state-machine that controls Quake's Shamblermonsters… I'm Quaking in my AstroBoots**Towel-folding?**singled out as a questionable use of dollars...**FSMs driving robots...**MIT's car, Talos**FSMs driving robots...**MIT's car, Talos- and its sensor suite**Final project FSM!**still works still broken it's broken stop adding features + start adding print statements comment out print statements + start adding more features it works**Simplest model of computation: FSMs**Finite State Machines 0 0 1 s0 s1 1 start state transitions accepting states “input funnel” “where to go” double circled labeled by input ! Are there limits to what FSMs can do?**State-machine limits?**Let's build a FSM that accepts bit strings with the SAME NUMBER of 0s as 1s 0 1 same # of 0s and 1s**State-machines are limited.**FSMs can't count at least, not arbitrarily high... We need a more powerful model than FSMs... so, "we" add memory ! where "we" == Turing**FSMs can't count...**So, let's build a better machine! Shiny! Turing Machine**Can TMs compute everything?**Alan Turing says yes... Turing called them Logical Computing Machines Turing’s Intelligent Machines, 1948 http://www.alanturing.net/turing_archive/archive/l/l32/L32-005.html**So far, all known computational devices can compute only**what Turing Machines can... some are faster than others… Quantum computation http://www.cs.virginia.edu/~robins/The_Limits_of_Quantum_Computers.pdf Molecular computation http://www.arstechnica.com/reviews/2q00/dna/dna-1.html Parallel computers Integrated circuits Electromechanical computation Water-based computation Tinkertoy computation**Alan Turing**AI! 1912-1954 WWII Enigma machine ~ The axis's encryption engine 2007 1946 Bletchley Park**Alan Turing**AI! 1912-1954 WWII Enigma machine ~ The axis's encryption engine 2007 1946 Bletchley Park**Alan Turing**AI! 1912-1954 WWII Enigma machine ~ The axis's encryption engine unfortunately, it's not Turing's Apple… 2007 1946 Bletchley Park**Turing Machine**A simple model of universal computation. Starts on the leftmost character The tape: an expandable amount of memory made of ofcells, each with exactly one character: 0, 1, blank… Read/write head for the tape The control: a finite state machine Ability to move left and right The control state The symbol now under the head The symbols to the right of the head The symbols to the left of the head The complete state of a TM is determined by:**the input**0 1 0 1 0 the tape R/W head "blanks" are everywhere else an accepting state always halts -- then basks in its success! if a transition is missing, the input FAILS! 0 ; 1 , R a Turing Machine rule: READ WRITE MOTION try it in JFLAP...**Try it!**Run this TM on this input: 0 0 1 1 1 Is thisinput accepted or rejected? What does this TM do in general? Change the input to one that does the opposite (reject/accept) as this!? Extra: How could you change this TM to accept palindromes? (extra!)