turing machines for dummies why representations do matter peter van emde boas illc-fnwi-univ. of...

92
Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM 2012 – Jan 25 2012 Špindlerúv Mlýn Czech Republic 1

Upload: wendy-chubb

Post on 29-Mar-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Turing Machines for DummiesWhy representations do matter

Peter van Emde BoasILLC-FNWI-Univ. Of Amsterdam

Bronstee.com Software & Services B.V.

SOFSEM 2012 – Jan 25 2012Špindlerúv MlýnCzech Republic

1

Page 2: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

2

Page 3: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Turing Machine

Finite Program : P

Tape

Read/Writehead

P (K ) (K {L,0,R}) :(q,s,q’,s’,m) P denotes the instruction:When reading s in state q print s’, performmove m and proceed to state q’ . Nondeterminism!

K: States: tape symbols

3

Page 4: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Transitions

Configuration c : finite string in *(K) * $ A B A A C <q,A> C B B A $

Transition c --> c’ obtained by performing instruction in P E.G., the instruction <q,A,r,B,R>

$ A B A A C <q,A> C B B A $ |-- $ A B A A C B <r,C> B B A $

Computation: sequence of transitions

4

Page 5: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Configurations

Three ingredients are required for describing a Configuration:

The Machine State : qThe contents of the tape (preferably with endmarkers) : $ A B A A C B C B B A $The position of the reading head : i

Available options

Mathematical Representation: < q , xj xj+1 …. xi …. xl-1 xl , i >

Intrinsic Representation: $ xj xj+1 …. q xi …. xl-1 xl $ or $ xj xj+1 …. <q xi > …. xl-1 xl $

Semi Intrinsic:< q , $ xj xj+1 …. xi …. xl-1 xl $ >

5

Page 6: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

6

Page 7: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Theme of this presentation

• The Convenience of the Intrinsic Representation

– Its History : who invented it, who saw its usefulness ?– Applications which are hard, if not impossible when the

Mathematical representation is used• Chomsky Hierarchy and Automata models

• Master reductions for NP: Cook-Levin and Tilings

• Stockmeyer on Regular Expressions

• Parallel Computation Thesis : the Second Machine Class

– Is there a real problem ?

7

Page 8: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

HISTORY

Turing Machine and their Use

8

Page 9: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

The teachings of our Master

Our textbooks present Turing Machine programs in the format of quintuples or quadruples.

What format did Turing use himself ?

Some fragments of the 1936 paper

Configuration means state in our terminology

Looks like quintuples….

9

Page 10: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

For Turing Composite transitions are allowed

10

Page 11: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

This is an example of the Intrinsic Representation

Complete Configuration means Configuration on our terminology

11

Page 12: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

A Macro language for Turing Machine programs

12

Page 13: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

This Macro Language supportsRecursion !

13

Page 14: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

The format of TM programs which today is conventional arises as a simplification introduced for the purpose of constructing the Universal Turing Machine

Turing operates as an Engineer(Programmer) rather than aMathematician / Logician

14

Page 15: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Nondeterminism

• Our concept of Nondeterminism (the applicable instruction is not necessarily unique) is for Turing a serious programming error

• Nondeterminism became accepted in the late 1950-ies as a consequence of the needs of Automata Theory

15

Page 16: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Using the model

• Initial configuration on some input• Final configuration

– No available instruction– By final state (accept , reject)– Evaporation of the state

• Complete Computation– From initial to final configuration (or infinity)

• Result of computation– Language recognition (always halting, condition on final

configuration)– Language acceptance (accept by termination)– Function evaluation (partial function/relation, requires termination)

• Non Terminating Computations – Stream Computing– Interactive computation

16

Page 17: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Example Turing Machine

K = {q,r,_}S = {0,1,B}P = { (q,0,q,0,R),

(q,1,q,1,R),(q,B,r,B,L),(r,0,_,1,0),(r,1,r,0,L),(r,B,_,1,0) }

q0 1 0 1 1 B 0 q1 0 1 1 B 0 1 q0 1 1 B 0 1 0 q1 1 B 0 1 0 1 q1 B 0 1 0 1 1 qB 0 1 0 1 r1 B 0 1 0 r1 0 B 0 1 r0 0 0 B 0 1 1 0 0 BSuccessor Machine;

Increments a number in binary._ represents the empty halting state. 11 + 1 = 12

17

Page 18: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Variants

Semi Infinite Tape

B B BBBB BA AAA OO OOO

BBB BAAO OO

BBB AA OO

q

q

Tape folding; remember which track you are on….

18

Page 19: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Multiple Tapes

B B BBBB BA AAA OO OOO

Z U XZYU XX YZX ZZ ZYU

q

19

Page 20: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Multiple Tapes

B B BBBB BA AAA OO OOO

Z U XZYU XX YZX ZZ ZYU

q

Tapes become tracks on a single tapeMarkers used for maintaining head positions on the tracks

20

Page 21: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Invariance Thesis

• Other variants– Multi dimensional tapes– Multi heads on a single tape– Jumps to other head positions

• All models of Turing Machines are equivalent– up to polynomial overhead in time and

constant factor overhead in space• First Machine Class– Includes RAM / RASP model as well

21

Page 22: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

How Turing Machines are used

• Marvelous TM algorithms do exist in the literature– Hennie Stearns: oblivious k-tapes on two tapes– Slisenko: Real-time Palindromes regognition and string

matching– Vitányi: Real-time Oblivious multi-counter simulation

• The main use of TM’s is for proving negative results (using reductions)– Undecidability– NP-hardness– Other hardness results

• Requires direct encoding of TM-computations in target formalisms: Master Reductions

22

Page 23: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Time-Space Diagram

q0 1 0 1 1 B 0 q1 0 1 1 B 0 1 q0 1 1 B 0 1 0 q1 1 B 0 1 0 1 q1 B 0 1 0 1 1 qB 0 1 0 1 r1 B 0 1 0 r1 0 B 0 1 r0 0 0 B 0 1 1 0 0 B

Master Reductions use this Time-Space Diagram as representation of the computation subject to the Reduction

The Intrinsic Representation is far more useful, if not required, for constructing these Master Reductions

WHY ??

Because validity of the Diagram can be checked Locally

23

Page 24: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Time for a new hero

Larry StockmeyerFOCS 1978, Ann Arbor

© Peter van Emde Boas ; 19781016 Thesis MIT 1974Rep. MAC-TR-133

24

Page 25: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Stockmeyer on representations

This is a Mathematical Representation

25

Page 26: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Stockmeyer on representations

For the Single Tape model the Intrinsic Representation is used

26

Page 27: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Stockmeyer’s Lemma

Validiy of transition becomes a local check on a 2 by 3 window in the Time-Space Diagram

NB: for Stockmeyer Functions are partial and multi-valued, I.E., Relations

Is this the first time the convenience of the Intrinsic Representation is mentioned explicitly ?

27

Page 28: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Applications

• Automata Theory

• Master reductions for NP– Cook/Levin reduction to SAT– Bounded Tiling

• Stockmeyer on Regular Expressions

• Parallel Computation Thesis

28

Page 29: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Automata Theory

• The Machine based characterization of the Chomsky Hierarchy– Regular grammars Finite Automata– Context Free grammars Push Down

Automata– Context Sensitive grammars Linear

Bounded Automata– Unrestricted grammars Turing Machines

29

Page 30: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

A Side Remark

Traditional Textbooks present Automata Theory in the order:REG , CF, CSL, Type 0 resp. FA, PDA, LBA, TM

Alternative: start with Turing Machines, treating the alternative models as restricted models

Advantage: the concepts involving Configurations and Computations don’t need a separate presentation for each model

The desired characterizations are obtained by correlating production steps in the grammar world and computation segments in the Machine world, observing the required restrictions on both sides

30

Page 31: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

A trivial Observation

• The production proces in the Grammar world can be simulated by a single Tape Turing Machine

• Turing Machines are after all perfect symbol manipulators

• Remains to show that restricted grammar classes can be simulated by restricted Machine models

31

Page 32: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

The Converse Direction

• Using the Intrinsic Representation, the transitions of a Turing Machine are described by Context Sensitive Rules:

<q,a> <p,b,R> corresponds to qaX bpX<q,a> <p,b,0> corresponds to qa pb<q,a> <p,b,L> corresponds to Xqa pXb

etcetera

32

Page 33: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

The context

• In the grammar world a production starts with the start symbol S, and terminates in a string of terminals

• In the machine world a computation starts with an initial ID with the terminal string on the input tape, and ends in an accepting configuration

• Hence: Mutual Simulations require some adaptations……

33

Page 34: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

TM simulation of a type 0 grammar

In the initial Configuration the TM writes the start symbol S in a second track of the tape.

The productions in the grammar are stepwise simulated in this second track (shifting the symbols left/right of the rewritten ones over the required distance)

When the production is completed the TM checks whether the two tracks contain the same string, and accepts accordingly

Hence: the language generated by a type 0 grammar can be recognized by a Turing Machine

34

Page 35: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

A type 0 grammar simulates a TM

From S generate the Initial Configuration in two tracks (this can be done using Regular productions only)

Simulate the TM computation using the CS rules in the first track, leaving the symbols in the second track invariant

If the machine accepts, erase the entire first track(this may require lenght reducing rules, hence type 0….)

Hence: The language accepted by a Turing Machine can be produced by a Type 0 grammar.

35

Page 36: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

CS grammars and LBA

• The same proof idea works• LBA simulates CS grammar: no

intermediate string exceeds the given input in lenght

• CS grammar simulates LBA: in previous proof erasing rules are only needed to remove extra workspace on the tape, and the LBA doesn’t use extra workspace

• Beware for the endmarkers: better have them printed as markers on the first and last input symbol….

36

Page 37: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

CF grammars and PDA

• Snag: the PDA is a two tape device• Solution: code configurations as

<processed input segment><state><reversed stack>

• Yields correspondence between leftmost derivation and PDA computations

37

Page 38: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

S

A B

A CAB

C

z

y

zx

CF Rules:S AB , A AC , B BA, A C,A x , B y, C z

Left Derivation:

*S *AB *ACB x*CB xz*B xz*BA xzy*A xzy*C xzyz*

PDA Instructions:

*,λ,S *,AB*,λ,A *,AC*,λ,B *,BA*,λ,A *,C*,x,A *, λ*,y,B *, λ*,z,S *, λ

Syntax tree

The Left derivation is equal to the time-space diagram of the PDA computation

Hence: a single state PDA can accept what the CF grammar produces

38

Page 39: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

PDA and CFG

• A single state PDA can simulate a CFG

• The PDA accepts by empty stack

• If the PDA has several states the CFG rules must encode these states

PDA Instructions:

q,λ,S r,ABr,λ,A s,ACq,λ,A s,Cr,x,A s, λ

CF Rules:

[qSα] [rAβ][βBα][rAα] [sAβ][βCα] [qAα] [sCα] [qAs] x

α , β , range over the state symbols

[rAr] means “in state r, with A on top of the stack, a computation starts after which in state s the symbol below A is exposed”

39

Page 40: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Regular Grammars and Finite Automata

The standard translation: q,a r q ar

instruction production rule

Machine configuration and partial derivation

abbaqacbac abbaq

For the computation the input already processed is irrelevant; all information resides in the state, and the unread input determines the computation.In the grammar the past symbols are produced and the future symbols are invisible.A matter of perspective: past vs. future

40

Page 41: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Master reductions for NP

• Cook-Levin reduction to SAT– Based on Mathematical representation– Based on Intrinsic representation

• What is the difference ?

• Tiling based reduction– Does it require an Intrinsic

representation ?

41

Page 42: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Time-Space Diagram

q0 1 0 1 1 B 0 q1 0 1 1 B 0 1 q0 1 1 B 0 1 0 q1 1 B 0 1 0 1 q1 B 0 1 0 1 1 qB 0 1 0 1 r1 B 0 1 0 r1 0 B 0 1 r0 0 0 B 0 1 1 0 0 B

0 1 0 1 1 B q 0 0 1 0 1 1 B q 1 0 1 0 1 1 B q 2 0 1 0 1 1 B q 3 0 1 0 1 1 B q 4 0 1 0 1 1 B q 5 0 1 0 1 1 B r 4 0 1 0 1 0 B r 3 0 1 0 0 0 B r 2 0 1 1 0 0 B - 2

Intrinsic Mathematical

42

Page 43: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Reduction to SAT (intrinsic)

The key idea is to introduce a family of propositional variables:

P[i,j,a] expressing at row i (time i) on position j (space j) the symbol a is written in the diagram

Conditions:I at every position some symbol is writtenII at no position more than one symbol is writtenIII the diagram starts with the initial configuration on the inputIV the diagram terminates with an accepting configurationV the transitions follow the Turing Machine program

Va : expressed using implications (beware for Nondeterminism)Vb : expressed by exclusion of illegal transitions

43

Page 44: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Reduction to SAT (mathematical)The key idea is to introduce a family of propositional variables:

P[i,j,a] expressing at row i (time i) on position j (space j) the symbol a is written in the diagramQ[i,q] expressing at time i the machine is in state qM[i,j] expressing at time i the head is in position j

Extra Conditions:VI at every time the machine is in some stateVII at no time the machine is in more than one stateVIII at every time the head is in some positionIX at no time the head is in more than one position

The correctness conditions III , IV and V are rephrased, somewhat easier to understand….

44

Page 45: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

What’s the difference ??

Assume that a computation of T steps is described, hence the height (but also the width) of the diagram is O(T)Assume that the number of symbols used is K K = O( # states * # tape symbols )

Investigate the size of the required propositional formulas.

Investigate whether these formulas are expressed as clauses.

45

Page 46: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Expressing the ConditionsConditions:I at every position some symbol is written O(T2K)II at no position more than one symbol is written O(T2K2)III the diagram starts with the initial configuration O(T)

on the inputIV the diagram terminates with an accepting O(1)

configurationV the transitions follow the Turing Machine program Va : expressed using implications O(T2K2) Vb : expressed by exclusion of illegal transitions O(T2K6)VI at every time the machine is in some state O(TK)VII at no time the machine is in more than one state O(TK2)VIII at every time the head is in some position O(T2)IX at no time the head is in more than one position O(T3)

All conditions (except Va) are easily expressed by clauses

46

Page 47: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Conclusion

• The standard proof (EG., Garey & Johnson) uses the Mathematical representation, yielding a cubic formula size blow-up

• However, a quadratic formula size blow-up is achievable when using the intrinsic representation

• Same overhead is obtained when taking the detour by the tiling based reduction (next)

47

Page 48: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Tiling based ReductionTile Type: square divided in 4coloured triangles.Infinite stock availableNo rotations or reflections allowed

Tiling: Covering of region of the plane such that adjacent tiles havematching colours

Boundary condition: colours given along (part of) edge of region, or some giventile at some given position.

48

Page 49: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Turing Machines and Tilings

Idea: tile a region and let successive color sequences along rows correspond tosuccessive configurations.....

s

s

symbol passing

tile

s

qs

state accepting

tilesq

s

qsq

s’

qs instruction steptiles

q’s’

qsq’

q’s’

qs

(q,s,q’,s’,0) (q,s,q’,s’,R) (q,s,q’,s’,L)

SNAG: Pairs of phantom heads appearing out of nowhere...Solution: Right and Left Moving States....

49

Page 50: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Example Turing Machine

K = {q,r,_}S = {0,1,B}P = { (q,0,q,0,R),

(q,1,q,1,R),(q,B,r,B,L),(r,0,_,1,0),(r,1,r,0,L),(r,B,_,1,0) }

q0 1 0 1 1 B 0 q1 0 1 1 B 0 1 q0 1 1 B 0 1 0 q1 1 B 0 1 0 1 q1 B 0 1 0 1 1 qB 0 1 0 1 r1 B 0 1 0 r1 0 B 0 1 r0 0 0 B 0 1 1 0 0 BSuccessor Machine;

adds 1 to a binary integer._ denotes empty halt state. 11 + 1 = 12

50

Page 51: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Reduction to Tilings

q0 1 0 1 1 B 0 q1 0 1 1 B 0 1 q0 1 1 B 0 1 0 q1 1 B 0 1 0 1 q1 B 0 1 0 1 1 qB 0 1 0 1 r1 B 0 1 0 r1 0 B 0 1 r0 0 0 B 0 1 1 0 0 B

© Peter van Emde Boas ; 19921029

51

Page 52: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Implementation in Hardware

© Peter van Emde Boas ; 19950310 © Peter van Emde Boas ; 19950310 © Peter van Emde Boas ; 19921031

htpp://www.squaringthecircles.com/turingtiles

52

Page 53: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Tiling reductions

initial configuration

accepting configuration/by construction unique

blank border

space

blank border

time

Program : Tile TypesInput: Boundary

condition

Space: Width regionTime: Height region

53

Page 54: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Tiling Problems

Square Tiling: Tiling a given square withboundary condition: Complete for NP.

Corridor Tiling: Tiling a rectangle withboundary conditions on entrance and exit(length is undetermined): Complete for PSPACE .

Origin Constrained Tiling: Tiling the entire planewith a given Tile at the Origin.Complete for co-RE hence Undecidable

Tiling: Tiling the entire plain without constraints. Still Complete for co-RE(Wang/Berger’s Theorem). Hard to Prove!

54

Page 55: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Detour to SAT

A reduction from Bounded Tiling to SAT requires propositional variables t[i,j,s] expressing at position (i,j) a tile of type s is placed

Conditions:I Everywhere some tile is placed O(T2K)II Nowhere more than one tile is placed O(T2K2)III Boundary conditions are observed O(TK)IV Adjacency conditions are observed O(T2K2)

T height and width of the tiled regionK number of tile types

All conditions are expressed as clauses

55

Page 56: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Is the intrinsic representation needed ?

• A tiling reduction is posible for the semi-intrinsic representation (state information can be transmitted through rows…)

• Translating numeric information into geometric info (without introducing a semi-intrinsic representation) seems hard if not impossible…

56

Page 57: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Stockmeyer on Regular Expressions

Thesis MIT 1974Rep. MAC-TR-133

57

Page 58: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Regular ExpressionsS finite alphabet (in our applications Σ U (K ˟ Σ) U { $ } )

REG(S) :0 REG(S) M(0) = empty language1 REG(S) M(1) = {λ} singleton empty worda REG(S) for a S M(a) = {a} singleton letter a word

If f, g REG(S) then f + g REG(S) M(f + g) = M(f) U M(g) union f.g REG(S) M(f.g) = M(f).M(g) concatenation f* REG(S) M(f*) = M(f)* Kleene star

f* = 1 + f + f.f + f.f.f. + ….

Extra operations:

f2 = f.f squaring f ∩ g M(f ∩ g) = M(f) ∩ M(g) intersection~ f M(~ f) = S* \ M(f) complementation

58

Page 59: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Regular Expressions

• Describe the Regular languages over S• Transformation expression Finite automaton is easy (construction

where the parentheses in the expression become the states in the Finite Automaton)

• Converse transformation more difficult but standard textbook material (induction over number of states)

• Other interpretations exist and are useful: Regular Algebra’s, EG., in programming logics (PDL)

• Complete axiomatizations exist• No direct algebraic expressions for intersection and complementation • Regular languages being closed under intersection and

complementation implies that these operations are expressible in all individual instances

• Extra operators yield succinctness

59

Page 60: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Stockmeyer’s Decision Problems

NEC(f,S) is M(f) a proper subset of S* ?

EQ(f,g) is M(f) = M(g) ?INEQ(f,g) is M(f) ≠ M(g) ?

NEC(f,S) is equivalent to INEQ(f,S*)EQ and INEQ are complementary problems

Stockmeyer (1974) characterizes the complexity of these problems, depending on the set of available operators

Considering complementary problems was meaninful: the Immerman-Szelepsényi result was discovered only 13 years later….

60

Page 61: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Stockmeyer’s Master Reduction

Given a TM program P and some input string ω, there doesn’t exist a regular expression denoting the (linearizations of) accepting time-space diagrams.

But Violations against representing such a diagram can be described by regular expressions

Syllabus Errorum approach: construct a Regular expression which enumerates all possible violations, and test whether there remains a string not covered by this expression (NEC problem)

61

Page 62: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Syllabus Errorum

A correct time-space diagram consists of configurations, all of equal lenght, separated by $ symbols

The first configuration must be the intitial configuration on the given input

The last configuration must be accepting (the unique accepting) configuration

The diagram may contain no illegal transitions

This condition is captured by the absense of forbidden 2 by 3 windows in the diagram, as expressed by Stockmeyer’s lemma;For this method to work the Intrinsic representation seems essential.

62

Page 63: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Yardstick expressions

Alphabet S used: Σ U (K ˟ Σ) U { $ } ; The width of the time space diagram (space consumed by the computation) is denoted M .Let V = Σ U (K ˟ Σ) , W = Σ

Given alphabet Z and number N we construct an regular expressionYa(Z,N) representing strings of length N of symbols from Z

Note that Ya(1+Z,N) now represents strings of lenght ≤ N

Using these yardstick expressions the various sources of errors can be described

63

Page 64: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Error Descriptions

There is a substring inbetween two $ symbols which is to short:

S*.$. Ya(1+V,M-1) .$.S*

There is a substring inbetween two $ symbols which is to long:

S*.$. Ya(V,M+1) .S*.$.S*

There is an incorrect transition in the diagram:

S*.xyz. Ya($+V,M-2) .uvw.S* where is a forbidden 2 by 3 window in the diagram

Similar (even more simple) expressions for the properties “starts wrong” and “ends wrong”

x y z u v w

64

Page 65: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

The reduction

• The regular expression which is the sum of all these error types represents the exact complement of the set of time space diagrams of accepting computations by P on input ω in space M

• Denote this expression by ER(P, ω, M)• Input is accepted iff NEC( ER(P, ω, M) , S)• Remains to estimate the lenght of this expression• Remember that we consider Nondeterministic

space bounded computations

65

Page 66: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

The size of the yardstick expressions

• Without extra operators Ya(Z,N) is of size O(N) yielding NPSPACE hardness for NEC

• With squaring 2 Ya(Z,N) is of size O(log(N)) yielding NEXPSPACE hardness for NEC

66

Page 67: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Expressions without *

• The same method also works without using * , but now the height of the diagram (time) must be restricted

• Yields reductions showing NP hardness and NEXPTIME hardness for the INEQ problem (without or with squaring)

• Nonelementary hardness if complementation is added

• Matching upper bounds are also obtained

67

Page 68: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Parallel Computation Thesis

// PTIME = // NPTIME = PSPACE

True for Computational Models which combineExponential Growth potential withUniform Behavior.

The Second Machine Class

68

Page 69: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Representative examplesSequential devices operating on huge objects

Vector machine Pratt & Stockmeyer 74,76MRAM Hartmanis & Simon 74MRAM without bit-logic Bertoni, Mauri, Sabadini 81EDITRAM Stegwee, Torenvliet, VEB 85ASMM Tromp, VEB 90,93

Alternating TM (RAM) Chandra, Stockmeyer & Kozen 81

Parallel DevicesParallel TM Savitch 77PRAM Savitch & Stimson 76,79SIMDAG Goldschlager 78,82Aggregate Goldschlager 78,82Array Proc. Machine v Leeuwen & Wiedermann 85

69

Page 70: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

How to prove it

• Inclusion //NPTIME PSPACE :– Guess computation trace– Verify that it accepts by means of

recursive procedure– Validate that the parameters are

polynomially bounded in size– Uniformity of behavior is essential

70

Page 71: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

How to prove it

• Inclusion PSPACE //PTIME :– Today’s authors show that

QBF //PTIME– Original proofs give direct simulations

of PSPACE computations, based on techniques originating from the proof of Savitch’ Theorem PSPACE = NPSPACE

71

Page 72: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Walter Savitch

Amsterdam; CWI, Aug 1976 San Diego, Oct 1983

© Peter van Emde Boas © Peter van Emde Boas© Peter van Emde Boas

Proved in 1970 PSPACE = NPSPACE

72

Page 73: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Understanding PSPACE

Acceptance = Reachability in Computation Graph

Solitaire Problem: finding an Accepting path in an Exponentially large, but highly Regular Graph

Matrix Powering Algorithm: Parallelism

Recursive Procedure: Savitch Theorem

Logic: QBF, Alternation, Games

73

Page 74: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Polynomial Space Configuration Graph

• Configurations & Transitions: – (finite) State, Focus of Interaction &

Memory Contents– Transitions are Local (involving State

and Memory locations in Focus only; Focus may shift). Only a Finite number of Transitions in a Configuration

– Input Space doesn´t count for Space Measure

74

Page 75: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Polynomial Space Configuration Graph

• Exponential Size Configuration Graph:– input length: |x| = k ; Space bound: S(k)– Number of States: q (constant)– Number of Focus Locations: k.S(k)t

(where t denotes the number of “heads”)– Number of Memory Contents: CS(k)

– Together: q.k.S(k)t. CS(k) = 2O(S(k))

(assuming S(k) = (log(k)) )

75

Page 76: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Polynomial Space Configuration Graph

• Uniqueness Initial & Final Accepting Configuration: – Before Accepting Erase Everything– Return Focus to Starting Positions– Halt in Unique Accepting State

Start Goal

76

Page 77: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Path Finding in Configuration Graph

77

Page 78: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Path Finding in Configuration Graph

Cycles in accepting path are irrelevant

Trash Nodes: Unreachable: or Useless78

Page 79: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Unreasonable Algorithm

• Step 1: generate this Exponentially large structure

• Step 2: Perform Exponentially long heavy computation on this structure

• Step 3: Extract a single bit of information from the result - the rest of the work is wasted.

• :‘• Which is just what the Parallel Models do.....

79

Page 80: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Unreasonable Algorithm

Transitive Closure of Adjacency Matrix byIterated squaring ==> // Models

Recursive approaches ==> // Models,Savitch' Theorem & Hardness QBF and Games

80

Page 81: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Adjacency Matrix

1 0 0 1 10 1 1 0 01 0 1 0 00 0 0 1 11 0 0 0 1

1

5

4

3

2

Matrix describes Presence of Edges in Graph;1 on diagonal: length zero paths

M :=

81

Page 82: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Adjacency Matrix

1 0 0 1 11 1 1 0 01 0 1 1 11 0 0 1 11 0 0 1 1

1

5

4

3

2

In Boolean Matrix AlgebraM2 : Paths up to length 2M4 : paths up to length 4

M2 =

1 0 0 1 11 1 1 1 11 0 1 1 11 0 0 1 11 0 0 1 1

1

5

4

3

2

M4 =

82

Page 83: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Matrix Squaring

M[i,j] := ( M[i,k] M[k,j] )k

On an N node graph, a single squaring requires O(N3) operations

Log(N) squarings are required to compute N-th Power of the Matrix

Remember that N = 2O(S)

83

Page 84: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Think Parallel

• O( N3 ) processors can compute these squarings in time– O( log(N)) if unbounded fan-in is allowed– O( log(N)2 ) if fan-in is bounded

• This is the basis for recognizing PSPACE in polynomial time on PRAM models

• More in Second Machine Class paper and/or chapter in Handbook of TCS; (both publications from the 1980-ies)

84

Page 85: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

How to obtain this Matrix ?

The row/column index is a binary numberwhich codes a configuration.

This code must be efficient in order that itis easy to recognize whether two configurationsare connected by a transition

"Locality" of the transitions is key: configurationonly changes at focus; everywhere else it remains the same.

85

Page 86: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

How to obtain this Matrix ?The intrinsic representation for Turing Machine has all desired properties.

We need some routine to extract from a binary bitstring a group of bits coding a single symbol.

On a RAM model your values are numbers - notbitstrings. Extracting these symbol codes requires number-to-binary conversion, whichpresupposes the availability of some "multiplicative" instruction which lacks in thestandard model (but which is always granted).

86

Page 87: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

The Problem ??!Is there a dragon out there ??

© Games Workshop

87

Page 88: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

What do actual authors Use ?

• Whenever TM computations are used in master reductions, the author will almost always chose either an intrinsic or a semi intrinsic representation

• This holds even if the formal definition for configurations is based on the mathematical representation

88

Page 89: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Representative authors

Author Title Mathematical Intrinsic Semi-Intrinsic

Reidel Ency of Math X

RI Soare RE sets and degrees 87

X

SC Kleene Intro to Metamath 52

X

Boolos & Jeffrey Computability & Logic 74

X

Börger Computability 89

X

Cohen Computability & Logic 87

X

M Davis Computability & Unsolv. 58

X

89

Page 90: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Representative authors

Author Title Mathematical Intrinsic Semi-Intrinsic

Hopcroft & Ullman

Formal Lang & Autom 69

X X

illustration

Hopcroft & Ullman

Formal Lang & Autom 79

X

F Hennie Intro to Comput 77

XWithout states

Harrison Intro Formal

Languages 78

X

Sudkamp Intro TCS

06

Xearlier eds as well

Lewis & Papadimitriou

Elts th of comp 81

X Xfor reductions

Mehlhorn EATCS mon 2 84

X

90

Page 91: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

Representative authors

Author Title Mathematical Intrinsic Semi-Intrinsic

Rudick & Wigderson

Comp Compl Theory 04

X

J Savage Models of Computation 98

X

For k tapes

X

Balcazar Diaz & Gabarro

Structural Complexity 88

X

H Rogers Th Recursive Functions 67

X

Odifreddi Classical Rec Theory 89

X

WJ Savitch Abstr Mach & Grammars 82

X X

J Martin Intr Lang & th of comp 97

X

91

Page 92: Turing Machines for Dummies Why representations do matter Peter van Emde Boas ILLC-FNWI-Univ. Of Amsterdam Bronstee.com Software & Services B.V. SOFSEM

We are Safe

• In practice, all authors on the basis of their intuition use the intrinsic representation

• Why then it seems that Stockmeyer is the unique author who makes the advantages explicit ??

92