160 likes | 491 Views
Finite Automata. Example 2: Can we build a finite automaton that accepts the language L = {a [n] b [n] | n > 0}? That is, the language of all words that start with a sequence of a’s followed by the same number of b’s.
E N D
Finite Automata Example 2: Can we build a finite automaton that accepts the language L = {a[n]b[n] | n > 0}? That is, the language of all words that start with a sequence of a’s followed by the same number of b’s. No, because with our finite number of states we have no way to memorize any number of a’s and determine whether it matches the number of b’s. But can we build such an automaton if we set an upper limit for n? Yes, we can! Introduction to Cognitive Science Lecture 14: Theory of Computation I
b a a b b a a q6 b a,b a,b Finite Automata Example 3: A finite automaton that accepts L = {a[n]b[n] | 0 < n 2} = {ab, aabb}: q2 q1 q3 q5 q4 Introduction to Cognitive Science Lecture 14: Theory of Computation I
Regular Languages The languages accepted by finite automata are called the regular languages. To understand the complexity of these languages, we need to introduce some string operations: Union: If A = {hello, world} and B = {here, I, am}, then A B = {hello, world, here, I, am} Concatenation: If A = {mouse, house} and B = {cat,hat}, then A B = {mousecat, mousehat, housecat, househat}. Star Closure: If A = {wow, cool}, then A* = {0, wow, cool, wowwow, wowcool, coolwow, coolcool, wowcoolwow, coolcoolcool, …} Introduction to Cognitive Science Lecture 14: Theory of Computation I
Regular Languages The class of regular languages is defined as follows: The empty language (containing no word) is a regular language. The language containing only the empty word (containing no letters) is a regular language. The language containing only a one-symbol word ({a}, {b}, …) is a regular language. If A and B are regular languages, then AB, AB, and A* are regular languages. No other languages are regular. Introduction to Cognitive Science Lecture 14: Theory of Computation I
Regular Languages: Examples What languages are specified by the following regular expressions: r = {1}* L(r) = {0, 1, 11, 111, …} r = {2}{1} L(r) = {21} r = ({2}{2}{1})({3}{1}) L(r) = {221, 31} r = (({3}{1})({1}{2}))* L(r) = {0, 31, 12, 3112, 1231, 3131, 121212, …} r = {1}({1}{2}{3})*{2} L(r) = {12, 132, 112, 122, 1312, 12232, …} Introduction to Cognitive Science Lecture 14: Theory of Computation I
Regular Languages: Examples Here is a difficult one: What language is described by the following regular expression? r = ({x}{y})*{x}{x}({x}{y})* L(r) = {xx, xxx, yxx, yxxy, xyxxyy, …} The language of all strings of xs and ys containing at least two consecutive xs. Introduction to Cognitive Science Lecture 14: Theory of Computation I
Turing Machines Now what happens if we remove the restriction on memory and its accessibility? This gives us Turing’s original theoretical concept of a computer, the Turing machine. Just like a finite automaton, the Turing machine’s next state is always determined by its current state and the current symbol under the head. However, each transition also includes printing a symbol or moving the head one square to the left or right. This way the tape serves as unlimited, freely accessible memory. Introduction to Cognitive Science Lecture 14: Theory of Computation I
a/R b/L B/c Languages Accepted by Turing Machines Notation: “If we are in state q1 and read symbol a, the head moves one position to the right, and the state changes to q2:” q1 q2 “If we are in state q4 and read symbol b, the head moves one position to the left, and the state changes to q3:” q4 q3 “If we are in state q3 and read symbol B, the head writes the symbol c and does not move, and the state changes to q1:” q3 q1 Introduction to Cognitive Science Lecture 14: Theory of Computation I
Turing Machines The input is written to the tape before the Turing machine is started. The tape head is set onto the leftmost symbol of the input string. All cells to the left and to the right of the input string are initialized with the blank symbol B. The Turing machine halts if there is no transition and accepts the input if its last state was an accepting one. Introduction to Cognitive Science Lecture 14: Theory of Computation I
a/R b/R b/R Languages Accepted by Turing Machines Now let us take a look at examples for Turing machines and the languages they accept. Example 1: Language L = {bb, bab, baab, baaab, …} on the alphabet {a, b}. q4 is the only accepting state. B/R q1 q2 q3 q4 Introduction to Cognitive Science Lecture 14: Theory of Computation I
a/R a/B B/R b/R B/R B/L a/L b/L B/L b/B b/L Languages Accepted by Turing Machines Example 2: Language L = {a[n]b[n] | n > 0} on the alphabet {a, b}. q1 q2 q3 q8 q6 q5 q4 B/B q7 Introduction to Cognitive Science Lecture 14: Theory of Computation I
TMs as Computers Church’s thesis: Any function that can be algorithmically computed can also be computed by a Turing machine. Why is it only a thesis? There is no general mathematical definition of algorithm – it is always specific to a particular scheme, i.e., a programming language. Therefore, Church’s thesis cannot be proved. However, no counterexample has been found, and no scientist seriously doubts that Church’s thesis is correct. Introduction to Cognitive Science Lecture 14: Theory of Computation I