• Aucun résultat trouvé

Decidability results for primitive recursive algorithms

N/A
N/A
Protected

Academic year: 2021

Partager "Decidability results for primitive recursive algorithms"

Copied!
28
0
0

Texte intégral

(1)

HAL Id: hal-00384668

https://hal.archives-ouvertes.fr/hal-00384668

Submitted on 15 May 2009

HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Decidability results for primitive recursive algorithms

René David

To cite this version:

René David. Decidability results for primitive recursive algorithms. Theoretical Computer Science, Elsevier, 2003, 300 (1-3), pp.477-504. �hal-00384668�

(2)

algorithms

R.David

January 30,2002

Abstract

InthispaperIusethenotionoftracedenedin[9]toextendT.Coquand's

constructive proof[6]oftheultimateobstinationtheoremofL.Colsontothe

case whenmutualrecursionisallowed. As aby productI get analgorithm

thatcomputes thevalue ofaprimitiverecursive combinatorappliedto lazy

integers(inniteorpartiallyundenedargumentsmayappear). Ialsoget,as

T.Coquandgotfromhisproof,that,evenwhenmutualrecursionisallowed,

thereisnoprimitiverecursivedenitionfsuchthatf(S n

(?))=S n

2

(?).

1 Introduction

In [3], Colsonproved theso-called"ultimate obstination theorem". This theorem

asserts that a primitiverecursive algorithm always reads,and so locks, ona par-

ticularinputargumenttocompleteitscomputation.Thisbehaviourdoesnotallow

the computation toshift from oneargumentto another onein orderto eÆciently

computeafunction,asforexampletheinf function studiedoriginallybyColson.

In[9],byusingthesyntacticnotionoftracewhichisasimpliedversionofthese-

quentialalgorithmsofBerryandCurien(see[2]or[1],chapter14)areformulation

of thistheorem isgivenandproved.

Theproofofthistheorem,asgivenin[3]or[9],isnotconstructive: itdoesnot

giveawaytodetermineonwhichparticularinputargumentthealgorithmlocks.

In this paper, I show that this can be done in a constructive way. This was

proved by T.Coquand in [6] for primitive recursivealgorithms. This is extended

hereinthecasewheremutualoralternaterecursionisallowed. Alternaterecursion

(seedenition2)hasbeenintroducedbyP.Valarcher[17]togiveagoodalgorithm

to computetheinf function.

TheproofofthemaintheoremneedsadiÆcultcombinatorialresult(proposition

18)whichhassomeinterestbyitself.

Decidability results : I show that, even when mutual or alternate recursion is

allowed, various problems are decidable. For example, it is possible to compute

the intentional behaviour of aprimitiverecursive combinatorf, i.e. the valueof

f when applied to lazy integers (innite or partially undened arguments may

appear). Note that, when alternate recursion is allowed, theultimate obstination

theoremobviouslyfails.Thisshowsthatthedecidabilityresultshavenothingtodo

withultimateobstination! Ialsoshowthat whenlistsorchangeofparametersin

therecursionschemeareallowed,theseproblemsbecomeundecidable.

Asaby-productoftheproofIalsoget:

LaboratoiredeMathematiques. CampusScientique. 73376LeBourgetduLacCedex. email

david@univ-savoie.fr

(3)

example, that, even when mutual or alternate recursion is allowed, there is no

primitive recursive denition f such that f(S n

(?)) = S n

2

(?). This was proved

by T.Coquandin the ordinarycase.I believethesametechnic could implyother

similar results such as, for example, if mutual recursion is restricted to at most

twofunctions,thereisnof suchthatf(S n

(?))=S [n=3]

(?)wherewhere[x]isthe

integer partof x but this seemsto need a combinatorial lemma that I have not

beenableto prove(nordisprove).

Irecallhereafterthemainintuitionsconcerningthenotionoftrace. LetN be

the domain of lazy integers.An element e of N canbeseenas apartial function

that lls someaccessiblecells (in thesense of [2])with theconstructors S,0and

?. Since?correspondstoalackofinformation,acelllledwith?isoftensaidto

beunlled. Forexample(seegure1)in e

0

=S(0)theaccessiblecellsaretheones

denoted bytheiraddress0and1.TherstoneislledwithSandthesecondwith

0:Ine

1

=S 2

(?)theaccessiblecellsaretheonesdenoted 0;1;2. Thecells0and1

arelledwithS andthethirdoneis unlled.

e

0

=

cellnumber 0 1

constructor S 0

and e

1

=

cellnumber 0 1 2

constructor S S ?

g. 1

Theset of traces isdened asfollows. LetW betheset of(nite orinnite)

wordson thealphabet fx

n

=n 0; x is aletterg. A traceis apair(e;) where

e2 N and isalabellingi.e. afunction from theaccessible cellsof e to W (see

examplesingure2).

Toeach primitiverecursivedenition (prc)f weassociateafunction[[f]]from

traces to traceswhich "codes" theway f gets its result: thefact that the token

x

i

occursin (n)intuitivelymeansthatthecellioftheelementnamedxhasbeen

used togete(n):

An exampleis given in gure 2 : dene add as usual by add(0;m) = m and

add(Sn;m)=Sadd(n;m):

-Thetracet

2

meansthat to getS thealgorithmhas usedthecell0of t

0 and

to get0thealgorithmhasusedrstthecell1oft

0

andnextthecell0oft

1 .

-Thetracet

3

meansthatto getS thealgorithmhasused rstthecell0oft

1

andnextthecell0oft

0

andtoget0thealgorithmhasusedthecell1oft

0 :

t

0

=

cellnumber 0 1

constructor S 0

labelling x

0 x

1 t

1

=

cellnumber 0

constructor 0

labelling y

0

t

2

=[[add]](t

0

;t

1 )=

cellnumber 0 1

constructor S 0

labelling x

0 x

1 y

0

t

3

=[[add]](t

1

;t

0 )=

cellnumber 0 1

constructor S 0

labelling y

0 x

0 x

1

g. 2

Since a trace carries the informations on a computation and not only on the

result,this notionallowsto alsocompose the computations.I believeitalsomakes

(4)

ofColson. Inparticular,theextensionofCoquand'sconstructiveresulttothecase

wheremutualrecursionisallowedwouldprobablybeimpossiblewithoutthenotion

of trace.

Thisnotionoftraceisrelatedto thesequentialalgorithmsintroducedbyBerry

and Curien ([2] or [1], chapter 14) as follows. In their terminology, a sequential

algorithmisatree. Eachbranchofthistreecorrespondstothecomputationofthe

algorithm on particular arguments, that isexactly (witha slight variationon the

syntax andtheterminology)what Icallatrace. Inparticular [[f]] canbeseenas

thesequentialalgorithmassociatedtof.

Thepaperisorganizedasfollows: I recallthenotion oftrace(section 2)and

itsmain properties(section5). Themain resultisgiveninsection3. Insection4,

I giveacombinatorialresultthatiscrucialfortheproofofthemain theorem. The

sections6,7and8aredevotedto itsproof. Insection9,Igivetheundecidability

results. Finally the appendix gives the proof of the combinatorial proposition of

section4.

2 The trace

InthissectionIrecall,forselfcompleteness,themaindenitionsabouttraces.More

details canbefoundin[9].Since,in thispaper,theonlydatatypeI amconcerned

with,isthedatatypeofintegersmanythingsaresimplerthanin thegeneralcase.

I thusadaptthedenitionsof[9]tothiscase.

Denition 1 1. The scheme for primitive recursionis : f(0;

!

r)=g(

!

r) and

f(Sx;

!

r)=h(f(x;

!

r);x;

!

r).

2. The scheme for mutual recursion is : f

i (0;

!

r) = g

i (

!

r) and f

i (Sx;

!

r) =

h

i (f

1 (x;

!

r);:::;f

k (x;

!

r);x;

!

r).

3. Thescheme for alternate recursionis:

f(0;y

2

;:::;y

k

;

!

r)=g

1 (y

2

;:::;y

k

;

!

r)

f(Sy

1

;0;y

3 :::;y

k

;

!

r)=g

2 (y

1

;y

3

;:::;y

k

;

!

r)

f(Sy

1

;Sy

2

;0;:::;y

k

;

!

r)=g

3 (y

1

;y

2

;:::;y

k

;

!

r)

...

f(Sy

1

;:::;Sy

k 1

;0;

!

r)=g

k (y

1

;:::;y

k 1

;

!

r)

f(Sy

1

;:::;Sy

k

;

!

r)=h(f(y

1

;:::;y

k

;

!

r);y

1

;:::;y

k

;

!

r)

Denition 2 1. Thesetsofprc(primitiverecursivecombinators)aredenedas

the leastsets containing the projections, the constructors S and0and which

areclosedundercompositionandprimitive recursion.

2. Thesetsofprc

mut

aredenedinthesamewayasprcbutdenitionbymutual

recursionisallowed.

3. Thesetsofprc

alt

aredenedinthesamewayasprcbutdenitionbyalternate

recursionisallowed.

Examples and comments

1. For thesimplicityofnotations,I assume,withoutlossofgenerality,that the

recursionalwaysisontherstargumentoftheprc.

(5)

Thusaddisaprc:

3. The functions odd and even are dened by : even(0) = 1 and odd(0) = 0:

even(Sx)=odd(x)andodd(Sx)=even(x):Thusoddandevenareinprc

mut :

4. The function inf is dened by : inf(0;0) = 0,inf(Sx;0) = 0andinf

(Sx;Sy) = Sinf(x;y). Thus inf is in prc

alt

and it is easy to see that the

computationtimeofinf(S n

(0);S m

(0))isinf(n;m).

5. Itis wellknownthat,asfunctions,thesets prc,prc

mut

and prc

alt

areequal

butthispapershows,in particular,that,asalgorithms,theyare not.

Denition 3 1. N (resp. N

;Z) is the set of non negative (resp. positive,

negativeor non negative)integers.

2. AnelementeofN isapartialfunctionfromaninitialsegmentofN (denoted

byAcc(e))intofS;0;?gsatisfying :

02Acc(e)

If(n+1)2Acc(e), thene(n)=S:

Ife(n)=?, then(n+1) 2=Acc(e):

3. Anelement eisnite iAcc(e)isnite.

4. Let e;e 0

be elements of N . e e 0

means : Acc(e) Acc(e 0

) and for all

n2Acc(e), ife(n)6=?,thene(n)=e 0

(n):

5. Iwilldenote the elementsof N as:

S n

(0) =f(i;S)=0i<ng[f(n;0)g,

S n

(?)=f(i;S)=0i<ng[f(n;?)g

S

!

=f(i;S)=i2Ng:

Comment

Acc(e)representsthesetofintegersthatareaccessibleine. Inthispresentation,

this simplyis the domain of e. In the generalcase (when various data typesare

allowed)it was moreconvenient to denetwodistinct sets : thedomain of eand

Acc(e). I havekeptthe notationAcc(e) to remaincompatible withthe notations

of [9].

Denition 4 1. Let=fx

n

=xisaletterandn2Ng.Theelementsofare

calledtokens.

2. Awordisanite (possibly empty)or innitesequenceof tokens. The empty

wordisdenoted by":The setof wordsisdenotedbyW.

3. Let u;u 0

be words. uu 0

means that u isa prex of u 0

and u"pdenotes,

for plg(u);the prex of uof lengthp:

4. u+u 0

isthe resultofconcatenatingu 0

attheendofu. Moregenerally, if(u

k )

isa(niteorinnite)sequenceofwordsu

0 +u

1

+::: willbedenotedby P

u

k :

5. Let u

n

be a sequence of words. Say that u

n

! u if for each p there is an

n

0

such that for all n n

0 , u

n

" p = u " p. This unique u is denoted by

Lim(u

n ).

(6)

labellingfunction :Acc(e)!W suchthat : 8n2Acc(e), ife(n)6=?,then

(n)isnite.

2. Atrace(e;) isnite ifeisnite andalllabelsarenite.

3. Theorderingon tracesisgiven by: (e;)(e 0

; 0

)iee 0

and for eachn

inAcc(e); (n) 0

(n)and,if e(n)6=?, then(n)= 0

(n):

4. Theset oftraces isdenotedby T.

5. Lete beanelementof N andx bealetter. The trace(e; )where (n)=x

n

foralln2Acc(e)will bedenotedase[x]. Atracease[x]iscalledanelement

namedx.

6. Let t=(e; )be atrace. eiscalled thevalue of tandisdenotedby Val(t):

iscalledthe labellingof tandisdenotedbyLab(t):

Proposition6 T with itsordering formsadomain. Inparticular :

1. Everytraceisaleastupperbound(denotedbySup)ofanincreasingsequence

ofnite traces.

2. Everyincreasing sequencehas aSup.

Thefollowingnotationswillbeconvenientatmanyplaces.

Denition 7 Lett =(e;)be atraceandw beaniteword.

1. w+t isthe trace (e;

0

) dened by : 0

(0)=w+ (0) and 0

(n)=(n) for

n1:

2. h(S;w) ti (or simply (S;w)t if no confusion is possible) is the trace (e 0

; 0

)

dened by : e 0

(0) = S;

0

(0) = w and, for n 0, e 0

(n+1) = e(n) and

0

(n+1)= (n).

3. Let x be aletter. thx+ki=(e;

0

) where 0

isobtainedfrom by replacing

x

j byx

j+k

for all j:

Example

y

0

+S(0)[x]=(S;y

0 x

0 )(0;x

1 )

S n

(?)[x]=(S;x

0 )(S;x

1 ):::(S;x

n 1 )(?;x

n ):

Lett=S

!

[x],then t=h(S;x

0

)siwheres=thx+1i.

Denition 8 Letf beafunction fromT n

toT:

1. fisincreasing if for allt

j t

0

j ,f(t

1

; :::; t

k )f(t

0

1

; :::; t 0

k ):

2. fiscontinuousifitisincreasingandpreservestheSupofincreasingsequences.

Proposition9 Every n-ary f 2 prc (resp. prc

mut

, resp. prc

alt

) induces (in a

uniqueway) acontinuousfunction (denotedby[[f]]) fromT n

toT suchthat:

[[0]](t

1

; :::; t

n

)=(0;")

[[S]](t)=(S;")t

Iff isthe i-thprojection then [[f]](t

1

; :::; t

n )=t

i

(7)

1 k

[[f]](t

1

; :::; t

n

)=[[g]](r

1

; :::;r

k

)wherer

j

=[[h

j ]](t

1

; :::; t

n )

If f is dened by ordinary or mutual recursion and the recursive equations

are f

i (0;

!

s)=g

i (

!

s)andf

i (Sx;

!

s)=h

i (f

1 (x;

!

s);:::;f

k (x;

!

s);x;

!

s). Then

[[f

i ]](t;

!

s)=

{ (?;w)ift=(?;w):

{ w+[[g

i ]](

!

s) ift=(0;w)

{ w+[[h

i ]]([[f

1 ]](r;

!

s);:::;[[f

k ]](r;

!

s);r;

!

s)if t=(S;w)r

Iff isdenedbyalternaterecursionand(forsimplicityofnotationsIassume

k = 2) the recursive equations are : f(0;y;

!

s) = g

1 (y;

!

s), f(Sx;0;

!

s) =

g

2 (x;

!

s)andf(Sx;Sy;

!

s)=h(f(x;y;

!

s);x;y;

!

s):Then [[f]](t

1

;t

2

;

!

s)=

{ (?;w

1 )if t

1

=(?;w

1 ):

{ w

1 +[[g

1 ]](t

2

;

!

s)if t

1

=(0;w

1 )

{ (?;w

1 +w

2 )ift

1

=(S;w

1

)randt

2

=(?;w

2 ):

{ w

1 +w

2 +[[g

2 ]]((r

1

;

!

s)if t

1

=(S;w

1 )r

1 andt

2

=(0;w

2 ):

{ w

1 +w

2

+[[h]](([[f]](r

1

;r

2

;

!

s);r

1

;r

2

;

!

s) if t

1

= (S;w

1 ) r

1 and t

2

=

(S;w

2 )r

2 :

Commentsand examples

1.

[[add]](S(0)[x];S

!

[y]) = (S;x

0 )(S;x

1 y

0 )(S;y

1 )(S;y

2 )

[[add]](S(0)[x];S 2

(?)[y]) = (S;x

0 )(S;x

1 y

0 )(S;y

1 )(?;y

2 )

[[add]](S 2

(?)[y];S(0)[x]) = (S;y

0 )(S;y

1 )(?;y

2 )

2. Sincethispaperisonlyconcernedwithdecidabilityresults(andnotwithcom-

plexityresults),I donotcareonthestrategyofreductionusedto transform

theequations into algorithms. However, thestrategy that is implicit in this

denitioniscallbyname : intuitively,ateachsteptheleftmostoutermostre-

dexisreducedand,inparticular,twocopiesofthesameredexwillbereduced

twiceiftheyareneededtwice.

3 The main result

Inthissection,I givethemain result(theorem14)ofthepaperandthedenitions

that arenecessaryforitsstatement.

Denition 10 Lett=(e;) beatrace.

1. Thebranchoft(denotedbyBr(t))istheworddenedby: Br(t)= P

k 2Acc(e) (k):

2. Aletterx isunbounded(respectivelybounded)intiffj =x

j

occursinBr(t)g

isinnite(respectively nite).

3. tisultimately obstinate ifithas atmost oneunboundedletter.

4. Nb(t;x;n)isthe least ksuchthat x

n

occurs in (k). If x

n

doesnot occurin

Br(t), Nb(t;x;n)isundened.

Commentsand examples

Références

Documents relatifs

We prove the universality for the eigenvalue gap statistics in the bulk of the spectrum for band matrices, in the regime where the band width is comparable with the dimension of

[7] Chunhui Lai, A lower bound for the number of edges in a graph containing no two cycles of the same length, The Electronic J. Yuster, Covering non-uniform hypergraphs

Wang, Error analysis of the semi-discrete local discontinuous Galerkin method for compressible miscible displacement problem in porous media, Applied Mathematics and Computation,

By Elkhadiri and Sfouli [15], Weierstrass division does not hold in quasianalytic systems that extend strictly the analytic system.. Hence the resolu- tion of Childress’

for proofs and refinements of these assertions. It is in general a very difficult problem to determine the irrationality exponent of a given transcendental real number ξ, unless ξ

We would like to solve this problem by using the One-dimensional Convex Integration Theory.. But there is no obvious choice

We study homogenization of deterministic optimal control problems in random ergodic environments with state dynamics beyond the calculus of variations and macroscopically

In this article, we show a local exact boundary controllability result for the 1d isentropic compressible Navier Stokes equations around a smooth target trajectory.. Our