Computability and Complexity Introduction Tutorials and Exam Hints ...

28 downloads 53 Views 289KB Size Report
Book: Introduction to the Theory of Computation,. Second International Edition ... Read the corresponding text in the book before the tutorial. Print out the set of ...
Introduction

Computability and Complexity

Lecturer: Jiri Srba ([email protected], 1.2.32). Assistant: Claus Thrane ([email protected], 1.2.57). Book: Introduction to the Theory of Computation, Second International Edition by Michael Sipser.

Lecture 1 Introduction Turing machines Decidable and recognizable languages

Homepage: intranet.cs.aau.dk/education/courses/2010/cc/ Many thanks: to Hans H¨ uttel for sharing his experience and for allowing me to use many of his exercises.

given by Jiri Srba

Lecture 1

Computability and Complexity

1/17

Tutorials and Exam

Lecture 1

Computability and Complexity

2/17

Hints

Tutorials Tutorials will be in the lecture-room and before lectures. Read the corresponding text in the book before the tutorial.

Work hard during the semester and participate in the tutorials.

Print out the set of exercises and bring it with you!

Take notes during the lectures!

Work in groups of 2 or 3 on the exercises and request a help from the teaching assistant and the lecturer.

Read the recommended pages as soon as possible after the lecture.

Compulsary and optional exercises.

Prepare for the tutorials and bring the print out of exercises!

The regular exercises or their slightly modified versions will be a part of the exam!

Print the slides and use them for your preparation for the exam. Anonymous feedback form on the home-page.

Exam Written, standard danish scale, no reading material allowed. Based on the exercises done during the tutorial and on the material covered during the lectures. Lecture 1

Computability and Complexity

Lecture 1

3/17

Theory of Computation

Computability and Complexity

4/17

Course Content Computability Do algorithmic solutions to problems always exist?

The theory of computation studies whether (computability theory), and

What are the limitations of computational devices?

how efficiently (complexity theory)

Is there any insight to which problems are algorithmically solvable and which are not?

certain problems can be solved on a computer, or rather on a model of a computer.

Are the unsolvable problems somehow related? Several equivalent models of computational devices can be used:

Complexity How do we compare the efficiency of different algorithms?

Register machines. Lambda calculus.

How do we measure time/memory requirements?

Simple while programming language (pseudo-code).

What problems are efficiently solvable?

Turing machines.

Are there solvable problems which do not have efficient algorithms?

... We focus on Turing machines. Lecture 1

Computability and Complexity

5/17

Lecture 1

Computability and Complexity

6/17

Formal Languages — Repetition

Operations on Languages — Repetition Let L1 and L2 be two languages (L1 , L2 ⊆ Σ∗ ).

Let Σ be a finite, nonempty set called alphabet.

L1 ∪ L2 = {w ∈ Σ∗ | w ∈ L1 or w ∈ L2 }

A string or word w over Σ is a finite sequence of symbols from Σ.

L1 ∩ L2 = {w ∈ Σ∗ | w ∈ L1 and w ∈ L2 }

An empty string is denoted by . A concatenation of strings w1 and w2 is a string w1 w2 .

L1 = {w ∈ Σ∗ | w 6∈ L1 }

A length of a string w is the number of symbols in w and it is denoted by |w |.

L1 .L2 = {w ∈ Σ∗ | w = w1 w2 where w1 ∈ L1 and w2 ∈ L2 }

The set of all strings over Σ is denoted by Σ∗ .

A language L over Σ is any subset of Σ∗ , i.e., L ⊆ Σ∗ .

Lecture 1

Computability and Complexity

L∗1 = {w ∈ Σ∗ | w = w1 w2 . . . wk where k ≥ 0 and each wi ∈ L1 for all 1 ≤ i ≤ k}

7/17

Turing Machine

Lecture 1

Computability and Complexity

8/17

Turing Machine Formally Definition A Turing machine is a 7-tuple M = (Q, Σ, Γ, δ, q0 , qaccept , qreject ):

Devised in 1936 by English mathematician Alan Turing. computations can be done by writing symbols on sheets of paper

Q is a finite set of states,

we have a pen, an eraser, finitely many symbols we can write, and as many sheets of paper as we want

Γ is a finite tape alphabet, s.t. t ∈ Γ and Σ ⊆ Γ,

Σ is a finite input alphabet, s.t. t 6∈ Σ

δ : Q × Γ → Q × Γ × {L, R} is the transition function, q0 ∈ Q is the start state,

qaccept ∈ Q is the accept state, and

no thinking is required to execute a computation

qreject ∈ Q is the reject state, where qaccept 6= qreject .

essentially a finite-state automaton with unbounded memory

Lecture 1

δ(q, a) = (q 0 , b, R) Notation:

Computability and Complexity

@ABC GFED q

a→b,R

Configuration of a Turing Machine (TM)

GFED / @ABC q’

Lecture 1

9/17

δ(q, a) = (q 0 , a, R) @ABC GFED q

a→R

GFED / @ABC q’

Computability and Complexity

10/17

Computation of a Turing Machine

Let M = (Q, Σ, Γ, δ, q0 , qaccept , qreject ) be a TM. Informally, a configuration consists of

Let M = (Q, Σ, Γ, δ, q0 , qaccept , qreject ) be a TM. Informally, a configuration C1 yields a configuration C2 if

the current control-state, the current tape content, and

in configuration C1 the machine M performs one computational step and moves to C2 .

the current head position. Definition (Configuration)

Definition (C1 yields C2 )

A configuration of a TM is a string uqv where

Let u, v ∈ Γ∗ , a, b ∈ Γ, and q, q 0 ∈ Q. We say that

u ∈ Γ∗ is the initial part of the tape, q ∈ Q is the current state,

v ∈ Γ∗ is the final part of the tape and the head points at the first symbol of v .

C1 = uaqbv yields uq 0 acv = C2

if δ(q, b) = (q 0 , c, L), and

C1 = uqbv yields ucq 0 v = C2

if δ(q, b) = (q 0 , c, R), and

C1 = qbv yields

q 0 cv

= C2

if δ(q, b) = (q 0 , c, L).

Remark: if v =  then the head points at the first blank symbol t after u, i.e., uq ≡ uqt. Lecture 1

Computability and Complexity

11/17

Lecture 1

Computability and Complexity

12/17

Acceptance of a String by a TM

Three Possible Outcomes of a TM Computation, Decider

Let M = (Q, Σ, Γ, δ, q0 , qaccept , qreject ) be a TM. Informally, a TM M accepts a string w ∈ Σ∗ if

Assume that a TM M computes from the initial configuration C1 = q0 w (note that this computation is deterministic).

from the initial configuration q0 w there is a computation which ends in a configuration of the form uqaccept v .

There are three possible outcomes of running M on w :

Definition (M accepts a string w ) A TM M accepts an input string w if there is a sequence of configurations C1 , C2 , . . . , Ck such that C1 = q0 w is the initial (start) configuration, Ci yields Ci+1 for all i, 1 ≤ i < k, and

C1 , C2 , . . . , Ck

ends in accept configuration Ck , or ends in reject configuration Ck , or

3

C1 , C2 , . . .

does not terminate (loops).

A TM M which for any input string w always halts (either in accept or reject configuration) is called a decider.

Similarly, M rejects w if there is such a sequence ending in Ck which is a reject configuration (contains qreject ). Computability and Complexity

C1 , C2 , . . . , Ck

2

Definition (Decider)

Ck is an accept configuration (contains qaccept ).

Lecture 1

1

13/17

Recognizable and Decidable Languages

Lecture 1

Computability and Complexity

14/17

Example

Definition (Language of M) The language recognized by a TM M, or simply the language of M is L(M) = {w ∈ Σ∗ | M accepts w }.

def

Consider the language L = {an b n c n | n ≥ 0}. Facts:

Definition (Recognizable Language)

L is not regular,

A language L ⊆ Σ∗ is recognizable if there exists a TM M such that M recognizes L, i.e., L = L(M).

L is not context-free, but L is recognizable and even decidable language.

Definition (Decidable Language) A language L ⊆ Σ∗ is decidable if there exists a TM M such that M is a decider and M recognizes L, i.e., L = L(M). Lecture 1

Computability and Complexity

15/17

Exam Questions

Definition of a Turing machine, configuration, computation, acceptance of a string by a TM. Definition of a decider. Definition of recognizable and decidable languages.

Lecture 1

Computability and Complexity

17/17

Lecture 1

Computability and Complexity

16/17

Suggest Documents