Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +

Similar presentations


Presentation on theme: "Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +"— Presentation transcript:

1 Computabilty jeanine.meyer@purchase.edu Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos + classwork/homework on FSMs

2 Computabilty jeanine.meyer@purchase.edu Overview Define different types of machines. –abstract machines Machines are fed (my term) strings in a specified alphabet. Machines scan the strings and say yes or no (accept or reject) Each machine accepts strings in a certain pattern. We call the set of strings in that pattern a language.

3 Computabilty jeanine.meyer@purchase.edu Overview Repeat: a language is a set of strings. This set may be finite or infinite.

4 Computabilty jeanine.meyer@purchase.edu Example The [written, formal] English language is an infinite set of sentences made up of valid words, spaces and punctuation. Why infinite?

5 Computabilty jeanine.meyer@purchase.edu Example The set of all legal (acceptable, no syntax errors) Processing programs is a language. It also is infinite.

6 Computabilty jeanine.meyer@purchase.edu Overview, cont. Each machine  a language Each type of machine  set of languages Presumably, more powerful machines (machines with more capability) could accept a larger set of languages. It will turn out that some changes are less powerful than you would think…

7 Computabilty jeanine.meyer@purchase.edu Aside When we get to Turing Machines, we also will talk about machines computing functions: –get input, produce output: an answer. For now, the input is a string of symbols in a fixed alphabet. The output is yes or no –or some other indication of yes, this is a string in the language; or no it is not.

8 Computabilty jeanine.meyer@purchase.edu Alphabets 2 symbols 0 and 1 or abcdefghijklmnopqrstuvwxyz or subset of the alphabet, say {a, b, c} or all symbols used in languages such as JavaScript, Processing, etc. It will turn out that alphabets can be represented by strings of 0 and 1…

9 Computabilty jeanine.meyer@purchase.edu Finite State Machine also called finite state automaton. Plural is automata. A FSM has a finite number of states! –express by writing out s0, s1, s2, etc. or drawing circles. –One state is specified as the initial state. –One or MORE states are specified as Final or Accepting states.

10 Computabilty jeanine.meyer@purchase.edu FSM, cont. For each state, there is a state transition table: for each symbol in the alphabet, there is a switch to another state or to stay in the same state. Draw this by a graph: representing the states by nodes and the edges by the state transition table.

11 Computabilty jeanine.meyer@purchase.edu Exercise Draw the graph –Initial state s0: 0 go to s1, 1 go to s2 –s1: 0 go to s1, 1 go to s3 –s2: 0 go to s3, 1 go to s2 –s3: 0 go to s3, 1 go to s3 –s1 and s2 are accepting states. What strings does it accept?

12 Computabilty jeanine.meyer@purchase.edu Problem Let's design a FSM that will accept strings over {0,1} of length 3 and nothing else.

13 Computabilty jeanine.meyer@purchase.edu Approach Take problem and think about different conditions that could arise and you need to keep track of… These will be the different states, or at least a first guess at the different states. For the "length 3" problem –start –length 1 –length 2 –length 3 –more than length 3

14 Computabilty jeanine.meyer@purchase.edu Problem Alphabet {a, b, c, d}. Language is all strings with at least one instance inside the string of abc. What are possible states?

15 Computabilty jeanine.meyer@purchase.edu Start of approach for abc States start a ab abc a and then something not a b. But maybe that can put us back at the start. ab and then something not a c. But maybe that can put us back at the start abc and anything else. But that can just keep us at the abc stage.

16 Computabilty jeanine.meyer@purchase.edu Finish the problem For the language containing all strings that have at least one abc inside. States: –start –a –ab –abc What are the accepting state(s)? What are the edges?

17 Computabilty jeanine.meyer@purchase.edu Your turn Each student draw a FSM over {0,1} Find a partner and try each other's FSM on sample strings.

18 Computabilty jeanine.meyer@purchase.edu Tricky but important The empty string is a string! Some languages may contain it, some may not. Design a FSM that accepts the empty string and only the empty string.

19 Computabilty jeanine.meyer@purchase.edu Approach What are the states? starting state state after any symbol scanned. What are edges? What is the accepting state?

20 Computabilty jeanine.meyer@purchase.edu Looking ahead The empty string, sometimes written kind of like the Euro € Extra credit opportunity for anyone who finds a better symbol… Some languages include the empty string and some don't. For the empty string to be in the language the starting state must be an accepting state!

21 Computabilty jeanine.meyer@purchase.edu Caution Empty set is not the empty string. The set consisting of one string, the empty string, is NOT empty. The set with no members, that is, consists of no strings, is a regular language. What is a FSM for this language?

22 Computabilty jeanine.meyer@purchase.edu Definition A language is called a regular language if there is a finite state automaton that accepts it. –feed in a string in the language L and the FSM ends in an accepting state. –feed in a string that is NOT in the language and the FSM ends in a non-accepting state. You will need to check both things.

23 Computabilty jeanine.meyer@purchase.edu Preview We will develop an alternative definition of regular languages and show they are equivalent. – Any language defined by regular expressions (to be defined later) is a regular language (can be accepted by a FSM). We will show a way of proving that certain languages are not regular. We will prove that no FSM exists that would accept that language. –It is possible (sometimes) to prove a negative…

24 Computabilty jeanine.meyer@purchase.edu Preview: Regular operations Suppose we have 2 languages A and B –remember these are sets. Consider the following languages –A union B: all strings in either A or B –A concatenate B: all strings made up of a string in A followed by a string in B. Note: may include all of A and/or all of B depending on whether or not the empty string is in A or in B –A star: finite strings in A, concatenated together

25 Computabilty jeanine.meyer@purchase.edu Preview We can (and will) prove that if A and B are regular languages, then so are A union B, AB, and A* From the machine M that accepts A and N that accepts B, build/design/specify machines for those 3 languages.

26 Computabilty jeanine.meyer@purchase.edu Game of crap Some of you remember from Programming Games The dice game (craps) had 2 states. –first turn –follow-up turn You start the game in the state of being a first turn. If you roll, –7, 11, you win and you stay in 'first turn'. –2, 3, 12, you lose and you stay in 'first turn' –Otherwise, you go to follow-up (remembering the value of your roll as 'the point'. Followup: –point: you win. (Go back to first turn.) –7: you lose. (Go back to first turn.)

27 Computabilty jeanine.meyer@purchase.edu Exercise Construct a FSM-like machine for the craps game. –Finishing states labeled win –Finishing states labeled lose

28 Computabilty jeanine.meyer@purchase.edu Next class Monday is Labor Day Thursday, I will be away for Rosh Hashanah. I have identified a video lecture series with 4 ten- minute segments and created questions. You should come to class and view and do as a group if you are not observing the holiday. –input using moodle Q&A forums. People observing the holiday should do on their own over BEFORE the next class on Monday, 9/13.


Download ppt "Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +"

Similar presentations


Ads by Google