COMP2600 — Formal Methods for Software Engineering

Katya Lebedeva

Australian National University Semester 2, 2016

Slides created by Katya Lebedeva

COMP 2600 — Turing Machines 1 Definition of “Computability”

Church-Turing Thesis

The “Church-Turing thesis” is the general belief that the notion of “computable in principle” can be expressed in terms of

• Turing’s Machines

• Church’s Lambda Calculus

• Godel’s¨ Recursive Functions

• Kleene’s Formal Systems

• Markov’s

• ...

COMP 2600 — Turing Machines 2 Definition of computability in terms of TMs: A computable function is a function that can be implemented by a TM.

Definition of computability in terms of λ-calculus: A computable function is a function that can be implemented as a λ-term.

These definitions are equivalent because

• for every TM, we can write a λ-term that simulates it

• for every λ-term, we can build a TM that simulates it

We could also give definitions of computable function in terms of other models of computation.

Thus, the “Church-Turing thesis” is the belief that any of these definitions is an adequate characterisation of “computability in principle”.

COMP 2600 — Turing Machines 3 Why TMs?

TMs are a terrible model for thinking about fast computation.

But when talking about computability, we are not interested in finding fast algorithms, or even finding algorithms at all!

We are interested to prove that some problems cannot be solved by any com- putational device, i.e. that they are undecidable.

TM is an extremely simple model, but powerful enough to describe arbitrary algorithms.

Importantly, TMs are powerful enough to simulate other TMs and simple enough to build up this simulation from scratch.

COMP 2600 — Turing Machines 4 Definition

A has the form (Q,q0,F, Γ,Σ,Λ, δ), where

• Q is the finite of states

q0 ∈ Q is the initial state F ⊆ Q is the set of final/accepting states

• Γ is the tape alphabet (the finite set of tape symbols) Σ ⊆ Γ is the input alphabet (the finite set of input symbols) Λ ∈ Γ/Σ is the blank

• δ is a (partial) transition function δ : Q × Γ → Q × Γ × {L,R,S}

COMP 2600 — Turing Machines 5 Halting

A state q is halting for a symbol x ∈ Γ if δ(q,x) is not defined.

A state q is halting if it is halting for all symbols in Γ.

We can assume without loss of generality that all final states are halting.

COMP 2600 — Turing Machines 6 Recursively Enumerable Languages

The language recognised by a TM M

∗ ∗ ∗ L(M) = {w ∈ Σ | q0w ` α1 pα2 with p ∈ F,α1,α2 ∈ Γ }

A language L is recursively enumerable if there exists a TM M such that L = L(M) and:

• for a string w ∈ L, M halts in an accepting state

• for a string w ∈/ L, M – either halts in a non-accepting state – or loops forever

COMP 2600 — Turing Machines 7 Recursive Languages

A language L is recursive if there is a TM M such that L = L(M) and M always halts, i.e.

• if w ∈ L, then M halts in an accepting state

• if w ∈/ L, then M eventually halts, although it never enters an accepting state

A TM of this type corresponds to an : a well defined finite sequence of steps that always finishes and produces an answer. It is a “decider” of the recursive language.

If we think of a language L as a “problem”, then problem L is called decidable if it is a recursive language.

COMP 2600 — Turing Machines 8 Recursive Languages and

All recursive languages are also recursively enumerable.

All regular, context-free and context-sensitive languages are recursive.

The class of recursive languages is not a member of Chomsky’s Hierarchy: this class would be properly between Type-0 and Type-1.

COMP 2600 — Turing Machines 9 Reducing One Problem to Another

Given two problems A and B.

We say problem A reduces to problem B if we can construct a decider MA for problem A using a decider MB for problem B

A ≤ B

This informally means

• problem A is “easier” than problem B

• the decider MB of B is at least as powerful as the decider MA of A

COMP 2600 — Turing Machines 10 Proving Undecidability

Assume we have a problem Lhalt and we know that Lhalt is undecidable.

We want to prove the undecidability of another problem L.

We just need to reduce Lhalt to L.

Then if L were decidable, Lhalt would necessarily be decidable too!

But we know that Lhalt is undecidable. Therefore L cannot be decidable.

Thus, to prove that some problem is undecidable, we assume that we have a “decider” for this problem, and show that this implies the existence of a “decider” for a known .

COMP 2600 — Turing Machines 11

We can construct a TM U that first reads a description of some other TM M and then simulates it. This is a universal TM.

Given hhMi,wi where

•h Mi is an encoding of a TM M

• w is a string

The universal TM U simulates M on w and accepts hhMi,wi iff M accepts w

hhMi,wi ∈ L(U) iff w ∈ L(M)

TMs can simulate other TMs (and hence any conventional computer). TMs can simulate themselves.

COMP 2600 — Turing Machines 12 Turing Completeness

Any machine that can simulate a universal TM is also called universal or Tur- ing Complete.

Universal Language

Language LU recognized by the universal TM U is called Universal Lan- guage.

LU = {hhMi,wi | w ∈ L(M)}

LU is recursively enumerable!!!

COMP 2600 — Turing Machines 13