CS30 - Spring 2016 - Class 23

Lecture notes

  • admin
       - NIM tournament in class next Tuesday

  • midterm
       - can hand in revised solutions for any of the problems and receive up to half of the points back
          - For T/F and circle the answer questions, must also provide an explanation!
       - must work on it on your own, but may use any of the normal resources you use for an assignment (i.e. the book, wing/python, the class notes, etc.)
       - hand me back your original final and a separate set of clearly labeled revisions
       - due by beginning of class on Tuesday, 4/26

  • talk at a high level about theoretical models of computation

  • models of computation
       - going to look at some very simple models of computation
          - much simpler than modern computers
       
       - why simple models?
          - they're much easier to understand
          - allow us to reason and think about them
          
       - even though they're simple models, many of them can be shown to have similar capabilities as modern computers (just not as fast :)
          - therefore, reasoning about these simplified models will (in some cases) allow us to reason about things

       - answer questions like:
          - What are the capabilities and limitations of computers?
          - E.g. are there problems that we could NEVER (even given an infinite amount of time, memory, etc.) answer with a computer?
          
       - slightly different then complexity theory and reasoning about big-O

  • languages
       - a language (L) is a set of strings (possibly infinite in size)

       - strings in that language are build up from an alphabet of characters, often denoted \sigma

       - we want to ask a simple question:
          - given a string of character in \sigma does it belong to the language L

  • deterministic finite automata (DFA)
       - basic idea
          - we have a set of states (indicated by circles)
          - we have a start state where computation starts (indicated by an triangle/arrow next to the state)
          - we have a collection of final state(s) (indicated by states with an inner circle)
          - for each state and each letter in our alphabet, we have a transition to another state

       - computing
          - we have a string as input on a tape
          - we start at the beginning of the string
          - read a symbol from the tape and transition to the state indicated by the model
          - if:
             - we end in a final state (i.e. get to the end of the string) we accept the string
             - otherwise, if when we get to the end of the string/tape we're in a non-final state we reject

       - the strings accepted by a DFA define a language

  • some DFA examples (found in DFA_examples)
       - no_a (1): Strings of a's and b's with no a's
          - b*
       
       - even_a (2): Strings of a's with an even number of a's
          - (aa)*

       - 5a (3): Strings with a's that are multiples of 5
          - (aaaaa)*

       - one_a (4): Strings with only one a
          - b*ab*

       - start_a (5): all strings that start with a
          - a(a|b)*

       - start_end: Strings that start and end with the same letter
          - (a(a|b)*a)|(b(a|b)*b)|a|b

       - odd: odd length strings
          - (a|b)((a|b)(a|b))*

       - two_a: strings with two or more a's
          - (a|b)*a(a|b)*a(a|b)*

       - two_exact_a: strings with exactly two a's
          - b*ab*ab*

       - ab: some number of repetitions of ab
          - (ab)*

  • formal definition of DFAs
       - defined by 5 things
          - \sigma: alphabet
          - Q: set of states
          - q_start: starting state
          - F \subset Q: final states
          - \delta: state transition function
             - Q x \sigma -> Q
             - transitions for each state for each letter in the alphabet to some other state
             - often written as a table