1 / 35

Finite Automata (Finite State Machine)

Finite Automata (Finite State Machine). Lecture 4-5 Ref. Handout p18-24. Controlling Things. If x has happened then do something If in state y then do something change to new state If x happened while in state y do something change to new state. State Transition Table.

hilde
Télécharger la présentation

Finite Automata (Finite State Machine)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Finite Automata(Finite State Machine) Lecture 4-5 Ref. Handout p18-24

  2. Controlling Things ... If x has happened then do something If in state y then do something change to new state If x happened while in state y do something change to new state

  3. State Transition Table

  4. State Diagrams a state transition A x B when in state A if x happens then we change to state B

  5. cancelled start tomorrow Happy Anxious done next week State Transition Diagram

  6. cancelled tomorrow Happy Anxious done next week A Finite Automata

  7. Components input symbol starting state (one per machine) d transition halting state (one or more) non-halting state

  8. Sequence of Input Symbols What input sequences leave this FA in its halt state? a S1 S2 b ac ab abc abac yes no no yes c S3 { (ab)nac | n>=0 } { ac, abac, ababac, abababac, ... }

  9. cancelled tomorrow Happy Anxious done next week The Original Example ... Some acceptable inputs nnnntc ntd Λ nntcntd

  10. Recognising Strings the set of all strings accepted/recognised by an FA = the language accepted/recognised by the FA

  11. Rejecting Strings An FA rejects a string if with some symbols remaining there is no transition for the next symbol or with no symbols remaining the FA is not in a halt state

  12. c t Happy Anxious d n Rejected / Accepted Strings tdnnn yes/no tdnnt yes/no n yes/no ntc yes/no ntcd yes/no

  13. { Λ, a, aa, aaa, aaaa, ...} = { an | n >= 0 } { a, aa, aaa, aaaa, ...} = { an | n > 0 } { 00, 01, 10, 11 } Recall some simple languages ...Can you draw FA to recognise them?

  14. An Assignment Related Example Draw an FA to recognise non-negative integers Extend it to all integers (i.e. allowing +,- signs)

  15. Memo for In-class test 4 [ /5]

  16. Non-Deterministic Automata a 1 What happens here? 2 b c d cd cdacd 3 4 d

  17. Non-Deterministic Automata • In deterministic automata, there can never be two transitions to different state for the same input symbol. • If there are more than one transition to different states for the same input symbol, we call it a non-deterministic automata.

  18. Deterministic FAs and Non-Deterministic FAs For every non-deterministic FA (NFA) there is a deterministic FA (DFA) which accepts the same language

  19. A Simple Example NFA 2 a b 3 1 a DFA a b

  20. Step by Step (1) NFA 2 a b 3 1 a after ‘a’, must be in state 2 or 3 a { 1 } { 2,3 }

  21. Step by Step (2) NFA 2 a b 3 1 a from state 2, read ‘b’, move to state 3 a b {3} { 1 } { 2,3 }

  22. Last Step NFA 2 a b 3 1 a a b { 1 } { 2,3 } {3} 3 is a halt state

  23. A General Algorithm • Write down {1} as the start state of the DFA • Choose a state in the DFA which hasn’t been processed • Work out all transitions from it adding new states • Repeat from step 2 until all states have been processed • Mark halting states

  24. Building DFAs Machine A Language L start halt Machine B Language K start halt

  25. What does this do? Machine A Language L halt start Machine B Language K halt

  26. What does this do? Machine A Language L start Machine B Language K ?? halt

  27. What does this do? Machine A Language L start halt

  28. Using Building Blocks For example, you are asked to define a format for a collection of pictures’ file names G = { a1.gif, a2.gif, a3.gif, ... a33.gif, .... }

  29. Using Building Blocks Now you are asked to define a format for another collection of pictures’ file names P = { b1.jpg, b2.jpg, b3.jpg, ... b33.jpg, .... }

  30. What if we need an FA for the union of G and Pi.e. G U P a 1-9 1-9 . f i g b 1-9 1-9 . g p j

  31. Using Building Blocks Let’s change the language P to P = { a1.jpg, a2.jpg, a3.jpg, ... a33.jpg, .... } (replace ‘b’ by ‘a’) a 1-9 1-9 . g p j

  32. What happens now? If we need an FA for the union of G and P. i.e. G U P a 1-9 1-9 . f i g a 1-9 1-9 . It’s a NFA! g p j

  33. Limitations of FAs Can you draw an FA to accept this? { anbn | n > 0 }

  34. Memo for In-class test 5 [ /5]

More Related