Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Finite Automata and Regular Languages

Tom Stuart
January 27, 2014

Finite Automata and Regular Languages

Tom Stuart

January 27, 2014
Tweet

More Decks by Tom Stuart

Other Decks in Programming

Transcript

  1. F I N I T E & R E G

    U L A R A U T O M A T A L A N G U A G E S @tomstuart / London JS / 2014-01-27
  2. 1 2 3 a b b , a a b

    a b bb aa 1
  3. 2 3 a b b , a a b a

    b bb aa 2 1
  4. 1 2 3 a b b , a a b

    a b bb aa 2
  5. 1 3 a b b , a a b a

    b bb aa 3 2
  6. 1 2 3 a b b , a a b

    a b bb aa 3
  7. 1 2 3 a b b , a a b

    a b bb aa 3
  8. 1 3 a b b , a a b a

    b bb aa 3 2
  9. 1 2 3 a b b , a a b

    a b bb aa 1
  10. 2 3 a b b , a a b a

    b bb aa 2 1
  11. 1 2 3 a b b , a a b

    a b bb aa 2
  12. 1 3 a b b , a a b a

    b bb aa 3 2
  13. 1 2 3 a b b , a a b

    a b bb aa 3
  14. 1 2 3 a b b , a a b

    a b bb aa 3
  15. 1 3 a b b , a a b a

    b bb aa 3 2
  16. 1 3 a b b , a a b a

    b bb aa 3 2 ✔
  17. a a 1 2 3 a b b , a

    a b b b bb 1
  18. a a 1 2 3 1 a b , a

    a b b b bb b
  19. a a 1 2 3 1 a b , a

    a b b b bb b
  20. a a 1 2 3 1 a b , a

    a b b b bb b
  21. a a 1 2 3 a b b , a

    a b b b bb 2
  22. a a 1 2 3 a b b , a

    a b b b bb 2
  23. a a 1 2 3 a b b , a

    a b b b bb 2
  24. a a 1 2 3 a b b , a

    a b b b bb ✘ 2
  25. bbbbaa baabba ✔ ✘ ab baba aaaab a baaaa b

    bbbbbb abbbb bbbbab bba ✔ ✔ ✔ ✔ ✔ ✘ ✘ ✘ ✘ ✘
  26. 1 2 3 a b b , a a b

    accepts strings containing "ab"
  27. 1 1,2,4 1,3,4 1,3 b a a 1,2 1,4 1,2,3,4

    1,2,3 b a b a b b a b a b a b a
  28. bbbbaa baabba ✔ ✘ ab baba aaaab a baaaa b

    bbbbbb abbbb bbbbab bba ✔ ✔ ✔ ✔ ✔ ✘ ✘ ✘ ✘ ✘
  29. baabba ab baba aaaab abbbb bbbbab this is part of

    the language that the machine recognises
  30. some regular languages: • the strings "one", "two" and "three"

    • all strings that contain "ab" • all strings whose third character is "b" • all strings whose third-from-last character is "b" • all strings that start and end with "a"
  31. some non-regular languages: • all strings that are palindromes •

    all strings that contain equal numbers of "a" and "b" characters • all strings of brackets that are balanced • all strings that are valid JSON • all strings that contain equal numbers of "a", "b" and "c" characters • all strings whose length is prime • all strings that contain a halting JavaScript program
  32. ( () ✔ ✘ (()) (()(())) ()()()()() (( (() )

    (((())))) ((((())))) (()((()))) (()))() ✔ ✔ ✔ ✔ ✔ ✘ ✘ ✘ ✘ ✘
  33. /a/

  34. a

  35. a b

  36. a b

  37. a b

  38. a b

  39. or

  40. a

  41. b c