SHARIF UNIVERSITY OF TECHNOLOGY THEORY OF COMPUTATION FIRST WEEK February 13, 2016
1 COURSE DESCRIPTION Session 1 1 Course Description Welcome to "Theory of Computation" course. In this course we will introduce a variety of models of computation and discuss their "expressive power" which is their power to solve problems. We will then turn our attention to Turing machines, the problems they can solve and those that cannot be solved by any Turing machine. Finally, we will delve into the mathematical concepts behind computer science and computation. So if you desire to know where computer science came from (both historically and theoretically) or if you have ever wondered how far computers can go, then get ready to be happy! Instructors Instructor: Hadi Foroughmand: foroughmand@sharif.edu Teaching Assistants: Simin Oraee: simin1785@gmail.com Erfan Khaniki: e.khaniki@gmail.com Farzad Jafarrahmani: farzadhtg@gmail.com Aria Adibi: aria.a1995@gmail.com Amin Heydarshahi: amin.heydarshahi@yahoo.com Books John C. Martin, Introduction to Languages and the Theory of Computation 4th Edition Douglas S. Bridges, Computability: A Mathematical Sketchbook Grades Final Exam 8 Midterm Exam 5 Homework 4 Quiz 3 TA Classes 2 2
2 WHAT WE WILL LEARN 2 What we will learn We already know about some models of computations (such as DFAs, PDAs, etc) and the class of languages they accept (such as the class of regular languages, context-free languages, etc). This week we will introduce Turing machines and at the end of the week, we will be able to design Turing machines for different problems. 3
1 TURING MACHINE: BASICS Session 2 Reviewing Turing machines 1 Turing Machine: Basics Definition: A Turing machine is a 5-tuple T = (Q,Σ,Γ, q 0,δ) with the following observations: Q: A finite set of states (e.g. {q 0, q 1,..., q n }). Note that T has a halting state h which is NOT an element of Q. Σ: A finite set of characters. Σ is often referred as the input alphabet because any input that T takes must only contain the characters from Σ. Γ: A finite set of characters that T can use throughout the computation referred as tape alphabet. Note that Σ Γ. Also note that T contains an extra character, the blank symbol, which is NOT an element of Γ. q 0 : An element of Q. When T starts to do computation on an input, q 0 is the initial state. δ: Q (Γ { }) (Q {h}) (Γ { }) {R, L, S}: A function called the transition function of T that tells T : "Hey T! If you are in the state q and you see γ below your head, then go to state q, delete γ and write γ below your head, and then move your head to right, left, or stay still (R, L, S)." Definition: If T is in state q, the tape contains the string x = zbw and the head is on b, then the following notation: (q, zbw) is called a configuration of T. On input w, the initial configuration of T is (q 0, w) Notation: If C 1 and C 2 are two configurations of T, then C 1 T C 2 means that T can enter C 2 from C 1 according to its transition function. The notation C 1 C 2 means that C 2 can be derived from C 1 in a finite sequence of transitions. 4
2 CREATING A TURING MACHINE Accepting a Language Definition: We say the language L Σ is accepted by a Turing machine if and only if: x L (q 0, x) (h, zbw) For a Turing machine T, the language that T accepts is shown by the notation L(T ). 2 Creating a Turing Machine Why creating a Turing machine in the first place? The computation in today s computers is implemented based on variations of Turing machines. So in order to gain a deep understanding of how computers work, it is necessary to be familiar with how Turing machines work. One question we are curious about is "how limited are computers?", and to answer it, we should deal a lot with Turing machines so that we can have a general idea about what we are studying. How to make a TM Given a language L, to create an (abstract) Turing machine T with L(T ) = L, all we should do is to specify states of T (Q), its input alphabet (Σ), tape alphabet (Γ), initial state (q 0 ), and most importantly its transition function (δ). Note that in a TM, we do not have a memory that is, we do not have the direct option of "storing a character"; the only access we are given is the tape slot below our TM s head and the state our TM is in. So we should use the tape of TM, and the states to store a character. Frequently, the algorithm we present is a combination of some simpler "sub-algorithms". In order to combine the two Turing machines T 1 and T 2 so that on input w, T 2 starts computing the result of T 1 s computation on w, we create a Turing machine T with its states, input alphabet, tape alphabet, defined to be the union of those of T 1 and T 2, its initial state being the initial state of T 1 and changing the transition function of T 1 so that all the transitions to h 1 (halting state of T 1 ) become a transition to q 0 (initial state of T 2 ). How to show a TM We show a Turing machine with a diagram called "state diagram". You are probably familiar with this diagram from "Theory of Languages and Automata" course. 5
3 TRAINING 3 Training Please build Turing machines to solve the following problems: 1. A Turing machine to accept the language L: L = { ss s {0,1} } 2. DELETE: A Turing machine to transform the tape from configuration (q 0, yσz) to configuration (h, y z) 3. COPY: A Turing machine to transform the tape from configuration (q 0, x) to configuration (h, x x) 6