======= Turing Machines ====== === Warmup === * Write a Turing Machine $math[M_1] such that $math[M(w) = 1] iff $math[w] is a binary encoding of the value $math[4]. Try not to use more than $math[5] states. * Write a Turing Machine $math[M_2] such that $math[M(w) = 1] iff $math[w] is a binary encoding of the value $math[4], and $math[M(w) = 0] otherwise; * What is the difference between $math[M_1] and $math[M_2] ? Let $$ f(w) = \left\{\begin{array}{cc}1 & w=0^*100 \\ 0 & \text{otherwise} \end{array}\right. $$ Observe the difference between a mathematical function such as $math[f], which is merely a mapping between entities, and a Turing Machine, which is a computational procedure illustrating how to determine an output value starting from an input value. The notation $0^*100$ is a [[https://en.wikipedia.org/wiki/Regular_expression|regular expression]]. An excellent reference for details on regular expressions is [[http://cdn.oreillystatic.com/oreilly/booksamplers/9780596528126_sampler.pdf|[1] ]]. We observe that $math[f] is the problem of establishing if a word is the binary encoding of the value $math[4]. The Turing Machine $math[M_1] accepts $math[f], while $math[M_2] decides $math[f]. The notions of acceptance and decision will be formally defined in the following lecture. Until then, we observe that: $$ \forall w\in\Sigma^*: M(w) = f(w) $$ captures the intuitive notion of '//solvability//'. A Turing Machine '//solves//' $math[f], if $math[M] always halts, and the output of $math[M] for any problem instance $math[w] coincides with the answer assigned to $math[w] by $math[f]. The informal notion of '//solvability//' will be replaced by **decision** and **acceptance**, in the following lecture. === More problems === - Checking if a binary string ends with $100$ - Checking if a binary string has the same number of ones and zeros (lecture) - Checking if a number is a palindrome (you may assume, for simplicity, that the $|w|$ is even) - **Identify a function whic h //cannot// be computed by a Turing Machine** {{## f(w) is 1 if sqrt(|w|) is a rational number and 0 otherwise ##}} - Reversing a string ==== References ==== - [[http://cdn.oreillystatic.com/oreilly/booksamplers/9780596528126_sampler.pdf|Mastering Regular Expressions]] - [[https://en.wikipedia.org/wiki/Regular_expression|Wikipedia entry on regular expressions]] ==== Links ==== - [[https://martinugarte.com/turingmachine/|Online Turing Machine simulator]] - [[https://www.youtube.com/watch?v=E3keLeMwfHY|Physical incarnation of a Turing Machine]]