announcement
play

Announcement RIT is looking for a few good Deterministic Finite - PDF document

Announcement RIT is looking for a few good Deterministic Finite Automata programmers! ACM Programming Contest 3 people teams Tryouts Tues, Sept 23 rd at 5pm (ICL3) FREE FOOD! Contact Paul Tyman (ptt@cs.rit.edu) by Sept 22


  1. Announcement  RIT is looking for a few good Deterministic Finite Automata programmers!  ACM Programming Contest  3 people teams  Tryouts Tues, Sept 23 rd at 5pm (ICL3)  FREE FOOD!  Contact Paul Tyman (ptt@cs.rit.edu) by Sept 22 nd . Scholarship Announcement Computer Science Community  Women in Computing Scholarship  CS Networking and Social Group  Attend the 2008 Grace Hopper Celebration of Women in Computing (Keystone, CO)  First Meeting  http://gracehopper.org/2008/  Wednesday, Sept 10 th  6-8pm  Contact instructor for more info if  CS Student Center interested.  Puzzles, pizza, soda, and prizes. Logistics First things  Homework #1  E-mail  From textbook  Should have received mail from me.  Page 47 -- Exercise 2b, d, e ( use JFLAP )  If not:  Page 48 -- Exercise 9b, c, e ( use JFLAP )  Page 48 -- Exercise 19  Check RIT forwarding  Page 55 -- Exercise 7 ( use JFLAP )  Page 62 -- Exercise 3  Due 9/16 1

  2. Finite Automata Visualization Submitting JFLAP files  JFLAP  Via mycourses dropbox  Java Formal Language and Automata Package  Use obvious file names  By Susan Rodger at Duke University  Eg. 2b.jff, 2c.jff, etc.  http://www.jflap.org  Need jff extension!  Available on mycourses (Content).  UNIX: tar file  Running JFLAP  Windows: zip file  UNIX  java –jar JFLAP.jar  Mac: sit/zip file  java –jar ~jmg/JFLAP.jar  Include a README with name(s)  Windows/Mac: double click on JFLAP.jar Questions Languages  Any questions before we start?  Recall.  What is a language? String Recognition machine Language Classes  Recall, we will be looking at classes of  Given a string and a definition of a languages: language (set of strings), is the string a  Each class will have its own means for member of the language? describing the language YES, string is  Each class will have its own machine model in Language for string recognition Language Input string recognition  Languages and machines get more machine complex as we move forward in the NO, string is course. not in Language 2

  3. Languages Regular Languages  A language is a set of strings.  Today we start looking at our first class of languages: Regular languages  Machine for accepting: Finite Automata  A class of languages is nothing more  Means of defining: Regular Expressions than a set of languages  Grammar: Regular Grammars  We’ll be studying different aspects of regular languages for the next 3-4 weeks Deterministic Finite Automata Deterministic Finite Automata  A deterministic finite automata (DFA) consists of Input tape  A read tape  A machine that can be in one or more “states” 1 2  Start state – The state the machine is in at the 3 beginning of execution 5 4  Accepting states – The state(s) the machine has to be in after execution in order for a string to be “accepted” State machine Deterministic Finite Automata Deterministic Finite Automata  How the automaton works  Testing a string for membership  Read a character on the tape  Place the string to be tested on the read tape  Based on the character read and the current “state” of the machine, put your  Place the machine into the start “state” machine into another “state”  Let the machine run to completion  Move the read head to the right  If, upon completion, the machine is in an accepting “state”, the string is accepted,  Repeat the above until all characters have been read. otherwise it is not. 3

  4. Deterministic Finite Automata Deterministic Finite Automata  Transition function  L = {x ∈ {0,1} * | x contains an odd number of 0s and an even number of 1s}  Defines what state the machine will move into given: 1  The current machine state 0 # 0s #1s 1  The character read off the tape 1 0 even even 0 0 2 1 odd even  Sometimes illustrated as directed graph 1 0 where nodes represent states and edges 2 odd odd 1 represent transitions. 3 0 3 even odd Deterministic Finite Automata Deterministic Finite Automata  This transition can also be given by a  Another example character table.  L = {x ∈ {0,1} * | x contains 01 as a 0 1 substring} → 0 1 3 s 1 0 0,1 *1 0 2 t a 0 1 2 t 2 3 1 0 1 e 3 2 0 Deterministic Finite Automata Deterministic Finite Automata  Consists of  Another example  A set of states  L = {x ∈ {0,1} * | x does not contains 01  A start state as a substring}  A set of accepting states  Read symbols  Transition function  Let’s see in JFLAP  Let’s define an automata formally 4

  5. Deterministic Finite Automata Transition Function  A deterministic finite automaton (finite-state  The transition function machine) is a 5-tuple ( Q , Σ , δ , q o , F ) where  δ is a function from Q x Σ to Q  Q is a finite set (of states)  δ ( q, a ) = q’ where  Σ is a finite alphabet of symbols  q, q’ ∈ Q  q o ∈ Q is the start state  a ∈ Σ  F ⊆ Q is the set of final states  δ defines, given a current state q and  δ is a function from Q x Σ to Q (transition reading character a , to which state the function) DFA will move. Transition Function on Strings Transition Function on Strings  Applying the transition function to a string. Recursive definition of  Let A = ( Q , Σ , δ , q o , F ) be an FA.   δ * is a function from Q x Σ * to Q Define δ * : Q x Σ * → Q   δ * ( q, x ) = q’ where For any q ∈ Q, δ * ( q , λ ) = q  q, q’ ∈ Q 1.  x ∈ Σ * For any y ∈ Σ * , a ∈ Σ , and q ∈ Q 2.  δ * defines, given a current state q and reading a δ * ( q, ya ) = δ ( δ * ( q, y ) , a ) string x , to which state the DFA will move once all characters of x are read. Transition Function on Strings Language accepted by a DFA  Example δ * ( q , λ ) = q  Let A = ( Q , Σ , δ , q o , F ) be a DFA. δ * ( q, ya ) = δ ( δ * ( q, y ) , a ) c a b q q 1 q 2 q 3  A string x ∈ Σ * is accepted by A if (q, abc) = δ ( δ * (q,ab), c)  δ * (q 0 , x) ∈ F = δ ( δ ( δ * (q, a), b), c)  In other words, = δ ( δ ( δ * (q, λ a), b), c)  Starting in your start state q 0 = δ ( δ ( δ ( δ * (q, λ ), a), b), c)  Run the machine with input x = δ ( δ ( δ (q, a), b), c)  The machine ends up in a final state = δ ( δ (q 1 , b), c)  If a string x is not accepted by A it is said = δ (q 2 , c) to be rejected by A. = q 3 5

  6. Language accepted by a DFA Regular Languages  The language accepted or recognized  Definition: by A is:  A Language L is regular if and only if there  L(A) = { x ∈ Σ * | x is accepted by A } exists a finite automata M such that L = L (M)  If L is a language over Σ , L is accepted by A iff L = L(A).  All regular languages are accepted by  For all x ∈ L, x is accepted by A. some finite automata  For all x ∉ L, x is rejected by A. Reality Check Reality Check  What we’ve learned so far  Questions?  An DFA can be expressed by ( Q , Σ , δ , q o , F )  Transition function: δ : Q x Σ → Q  Let’s take a break.  Transition function on strings  δ * : Q x Σ * → Q  Defined recursively  DFA accepting a string  The language accepted by an DFA  All languages accepted by a DFA are regular. 6

Recommend


More recommend