capes mi - turing machines and decidable problems · 2018-10-18 · turing machines turing machine,...

25
CAPES MI Turing Machines and decidable problems Laure Gonnord Université Claude Bernard Lyon1 2017

Upload: others

Post on 10-Jul-2020

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

CAPES MITuring Machines and decidable problems

Laure Gonnordhttp://laure.gonnord.org/pro/teaching/

[email protected]

Université Claude Bernard Lyon1

2017

Page 2: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Motivation

1 Motivation

2 Turing Machines

3 Decidability - Complexity

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 2 / 25 �

Page 3: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Motivation

Un peu en vrac

Informatique fondamentaleFormalisation de ce qu’est un calcul (mais avant lesordinateurs)Notion d’impossibilité, de problème difficile

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 3 / 25 �

Page 4: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Motivation

Notion de Modèle de calcul

Les classes UML - les BDLes GraphcetLes automatesLes machines de Turing

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 4 / 25 �

Page 5: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

1 Motivation

2 Turing Machines

3 Decidability - Complexity

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 5 / 25 �

Page 6: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Turing Machine, def - 1

Turing Machine, Turing, 1935A tape (infinite in both sides) : the memory. (it has aworking alphabet which contains a blank symbol).A head : read/write symbols on the tape.A finite transition table (or function)

image credits : Wikipedia.org

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 6 / 25 �

Page 7: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Turing Machine, def - 2

Turing Machine elementsStates (Q), initial state (q0), final (accepting) states (F).One alphabet Γ for the tape.B ∈ Γ the blank letter.Transitions are finitely many : read the letter under thehead, and then :

Erase a symbol or write one under the headMove the head (Left, Right, or Stay)The “state” can be modified.

I The transition function is :

Q× Γ× → Q× Γ× {L,R, S}

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 7 / 25 �

Page 8: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

An Example

TM that decides if x is odd (impair) : (final State : q4)State/char 0 1 B

q1 (q1,0,R) (q1,1,R) (q2,B,L)q2 (q3,0,L) (q4,1,L) —

Play on BBBBBBB11BBBBB and BBBBBBB10BBBBB

I A configuration is a tuple (word on the tape, position of thehead, state).Adapted from : http://www.madchat.fr/coding/algo/algo_epfl.pdf slide 4

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 8 / 25 �

Page 9: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Another Example

Demo : https://turingmachinesimulator.com/

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 9 / 25 �

Page 10: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

General results 1

There exists Turing machines for the following languages :palindromesanbncn (non algebraic language)ai with i prime (non algebraic)an

2, with n > 0

I Turing machines are more powerful than all other models (wehave seen yet)

Decidable LanguagesA language that is recognised by a Turing Machine is said to bedecidable.

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 10 / 25 �

Page 11: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Accepting or computing

A TM can also compute functions

TM that writes 1 if x is odd, 0 else (q6 is final state) :State/char 0 1 B

q1 (q1,0,R) (q1,1,R) (q2,B,L)q2 (q3,B,L) (q4,B,L) —q3 (q3,B,L) (q3,B,L) (q5,1,R)q4 (q4,B,L) (q4,B,L) (q5,0,R)q5 — — (q6,B,R)

Play on BBBBBBB11BBBBB and BBBBBBB10BBBBB

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 11 / 25 �

Page 12: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Another Example

Demo of a TM computing the addition.

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 12 / 25 �

Page 13: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

General results 2 - extensions

infinite tape in both directionsmore than one tapemany heads per tapebidimensional tapenon determinismrandom access

All these extensions can be simulated by a standard machine.

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 13 / 25 �

Page 14: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Example : Infinite tape

(copyright S.Brandel)

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 14 / 25 �

Page 15: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Example : Infinite tape

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 15 / 25 �

Page 16: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Example : Infinite tape

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 16 / 25 �

Page 17: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Example : Infinite tape

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 17 / 25 �

Page 18: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

General results 3

There exists Turing machines for the computation of :x 7→ x + 1

(x, y) 7→ x + y

x 7→ x2

all the functions you are able to write on computers

Computable functionsA function (defined for all its input) that is computable by aTuring Machine is said to be TM computable

I A Model of what can be computed with machines. (ChurchThesis - see later)

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 18 / 25 �

Page 19: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Important result 1 - Universal MT

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 19 / 25 �

Page 20: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Turing Machines

Church

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 20 / 25 �

Page 21: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Decidability - Complexity

1 Motivation

2 Turing Machines

3 Decidability - Complexity

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 21 / 25 �

Page 22: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Decidability - Complexity

Decidable - Semi-decidable languages

If L is a language, L is decidable if there exists a TuringMachine (or an algorithm) that outputs for all w :

1 if w ∈ L

else 0.Semi-decidable :

1 if w ∈ L

else does not terminateI equivalent definition for problems.

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 22 / 25 �

Page 23: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Decidability - Complexity

Complexity

Link with computational complexity :The number of steps in the execution of a TM gives thecomplexity in time,The number of seen squares in the execution of a TMgives the complexity in space.

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 23 / 25 �

Page 24: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Decidability - Complexity

Examples of undecidable problems

The halting problem for TM or counter automata (for morethat 2 counters)Given a program, does it loops ?Is a given algebraic expression (with log, *, exp, sin, abs)equal to 0 ? (Richardson, 1968)The 10th Hilbert Problem (Diophantine equations) - 1900(23 non solved pbs 2017).Garbage CollectingAbsence of bugs

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 24 / 25 �

Page 25: CAPES MI - Turing Machines and decidable problems · 2018-10-18 · Turing Machines Turing Machine, def - 2 Turing Machine elements States (Q), initial state (q 0), final (accepting)

Conclusion

Summary

Turing Machines :A model closed to programming languages.Non deterministic.Acceptors for decidable languages. But some languagesare not decidable !(equivalently) Computes solutions to problems. But ...

Important factSome common problems are undecidable !

Laure Gonnord (UCB Lyon1) CAPES - MI 2017 - MEEF � 25 / 25 �