HAL Id: hal-00144931
https://hal.archives-ouvertes.fr/hal-00144931
Submitted on 12 Mar 2010
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
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
Expressiveness of Full First-Order Constraints in the Algebra of Finite or Infinite Trees
Alain Colmerauer, Thi-Bich-Hanh Dao
To cite this version:
Alain Colmerauer, Thi-Bich-Hanh Dao. Expressiveness of Full First-Order Constraints in the Algebra of Finite or Infinite Trees. Constraints, Springer Verlag, 2003, 8 (3), pp.283-302. �hal-00144931�
in the algebra of nite or innite trees
Alain Colmerauer Thi-Bih-Hanh Dao
Marh5, 2003
Abstrat
We are interested inthe expressiveness of onstraints represented by general rstorder
formulae,withequalityasuniquerelationsymbolandfuntionsymbolstakenfromaninnite
set F. The hosen domainis the setof trees whose nodes, inpossibly innite number, are
labelled by elements of F. The operation linked to eah element f of F is the mapping
(a
1
;:::;a
n
) 7!b,where bis thetreewhose initial nodeis labelledf andwhose sequeneof
daughtersisa1;:::;an.
Werstonsidertreeonstraintsinvolvinglongalternatedsequenesofquantiers9898:::.
Weshowhowtoexpresswinningpositionsoftwo-persongameswithsuhonstraintsandapply
ourresultstotwoexamples.
Wethenonstrutafamilyofstronglyexpressivetreeonstraints,inspiredbyaonstru-
tiveproofofaomplexityresultbyPawelMielnizuk. Thisfamilyinvolvesthehugenumber
(k), obtained by top downevaluating a power tower of 2's, of height k. By a tree on-
straintofsizeproportionaltok,itisthenpossibletodeneatreehavingexatly(k)nodes
or to expressthe multipliationtable omputedby aProlog mahine exeuting up to (k)
instrutions.
ByreplaingthePrologmahinewithaTuringmahineweshowthequasi-universalityof
treeonstraints,thatistosay,theabilitytooniselydesribetreeswhihthemostpowerful
mahine will neverhave timeto ompute. We alsoredisover thefollowing resultof Sergei
Vorobyov: the omplexity of analgorithm, deidingwhether atree onstraint without free
variablesistrue,annotbeboundedabovebyafuntionobtainedfromniteompositionof
simplefuntionsinludingexponentiation.
Finally,takingadvantageofthefatthatwehaveatourdisposalanalgorithmforsolving
suhonstraintsinalltheirgeneralities,weprodueasetofbenhmarksforseparatingfeasible
examplesfrompurelyspeulativeones. Amongotherswenotiethatitispossibletosolvea
onstraintof5000symbolsinvolving160alternatingquantiers.
1 Introdution
Thealgebraof(possibly)innitetreesplaysafundamentalroleinomputersiene: itisamodel
for data strutures, program shemes and program exeutions. As early as 1976, Gerard Huet
proposed an algorithm for unifying inniteterms, that is solvingequations in that algebra[12℄.
Bruno Courelle has studied the properties of innite trees in the sope of reursive program
shemes[8, 9℄. Alain Colmerauerhasdesribedthe exeutionof Prolog II, III and IV programs
in terms of solving equations and disequations in that algebra [4, 5, 6, 1℄. Mihael Maher has
introdued andjustiedaomplete theoryofthealgebraofinnitetrees [13℄. Amongothers,he
hasshown thatin this theory,and thusin thealgebraof innitetrees,anyrstorder formulais
equivalenttoaBooleanombinationofonjuntionsofequations(partiallyortotally)existentially
quantied. SergeiVorobyovhas shown that the omplexityof an algorithm, deiding whether a
formula without free variables is true in that theory, annot be bounded above, by a funtion
obtainedfrom nite omposition of simplefuntions, inludingexponentiation [16℄. Pawel Miel-
nizuk[14℄ hasshownasimilarresultinthetheoryoffeaturetrees,butwithamoreonstrutive
method,whihhasinspiredalargepartof theworkpresentedhere.
ofinnitetrees[10, 11℄. Thepurpose ofthis paperisnotthepresentationof thisalgorithm,but
of examples, rst imagined as tests, then extended to show the expressiveness of suh general
onstraints. Thepaperisorganizedasfollows:
We end this rst setion bymaking lear thenotions of innitetrees algebraand rst-order
onstraintsinthat algebra.
Intheseondsetion,weusetwo-partnergamesfordeningonstraintsinvolvinglongsequenes
ofquantiers9898:::.
Inthethirdsetion,weintrodueaompositiononstraintwhihrepeatsthesameonstraint
atremendouslylargenumberoftimes. A longpartofthesetion isdevotedto provingitsmain
property.
Atsetion four, wemoveon to themost expressiveonstraintswe know. Theyare obtained
byhangingthe nature of the repeated onstraint. We produe several examples,among whih
aonstraintdening ahugenite treeand analmost perfet multipliation onstraint. Then by
simulating a Turing mahine, we show the quasi-universality of tree onstraint, that is to say,
theability to onisely desribetrees whih the most powerfulmahine will neverhave time to
ompute. ThisalsoallowsustogiveanotherproofoftheomplexityresultofSergeiVorobyov.
Weonludebydisussions andbenhmarksseparatingthefeasibleexamplesfromthepurely
speulativeones.
1.1 The algebra of innite trees
Asusual,afuntionsymbolisasymboltogetherwithanon-negativeinteger,itsarity. Trees,with
nodeslabelled byfuntion symbols,are well known objetsin theomputersieneworld. Here
aresomeofthem:
. . . . . .
f f
s
f f
f f
f f
s f
s
s s
f
s s
a b a b
a
a b
a
a
a
a
with, ofourse, the funtion symbolsa;b;s;f having respetivelythe arities0;0;1;2. Note that
thersttreeistheonlyonehavinganitesetof nodes,butthat theseondonehasstill anite
set of (patterns of) subtrees. Wedenote by A theset of all trees built on theinnite set F of
funtionsymbols.
1
Weequip Awithaset ofonstrutionoperations,oneforeahelementf 2F,whihare the
mappings(a
1
;:::;a
n
)7!b,where nisthearityof f andb thetreewhose initialnode islabelled
1
Morepreiselywedenerstanodetobeawordonthesetofstritlypositiveintegers. Atree,builtonF,is
thenamappinga:E!F,whereE isanon-emptysetofnodes,eahonei1:::i
k
(withk0)satisfyingthetwo
onditions:(1)ifk>0theni
1 :::i
k1
2E,(2)ifthearityofa(i
1 :::i
k
)isn,thenthesetofnodesofEoftheform
i
1 :::i
k i
k+1
isobtainedbygivingtoi
k+1
thevalues1;:::;n.
f andwhose sequeneof daughtersis(a
1
;:::;a
n ):
. . . . . .
a a
a a
f
1 n
1 n
The set A, together with the onstrution operations, is the algebra of innite trees and is
denotedby(A;F).
1.2 Tree onstraints
Weareinterestedin theexpressivenessof onstraintsrepresentedbygeneralrstorder formulae,
withequalityasuniquerelationsymbolandfuntion symbolstakenfromaninniteset F. These
treeonstraintsareofoneofthe10forms:
s=t; true; false; :('); ('^ ); ('_ ); ('! ); ('$ ); 9x'; 8x';
where'and are shortertreeonstraints,x avariable takenfromaninnitesetands;tterms,
thatistosayexpressionsofoneoftheforms:
x; ft
1 :::t
n
;
wheren0,f 2F,witharityn,andthet
i
'sareshorterterms.
The variables represent elements of the set A of trees built on F, the equality symbol is
interpretedas equalityand thefuntion symbols f are interpreted asonstrutionoperationsin
thealgebraofinnitetrees(A;F). Thusaonstraintwithoutfreevariablesiseither trueorfalse
andaonstraint'(x
1
;:::;x
n
)with nfreevariables x
i
establishes ann-ary relationin theset of
trees. Forexamplethetreeonstraint
(u;v;w;x;y) def
= 9z
z=f(x;f(y;z))^
z=f(u;f(v;f(w;z)))
isequivalentto
x=u^ y=v ^x=w ^ y=u ^x=v ^ y=w:
Thusitexpressesthatthetreesu;v;w;x;y areequal.
2 Long nesting of alternated quantiers
Toshow theexpressive powerof our onstraints,we startexamining deeply embedded quanti-
ations. We onsider two-partnergames and haraterize the positions from whih it is always
possibletowin inatmostkmoves. Inthismannerweobtainonstraintsinvolvinganalternated
sequeneof2k quantiers.
2.1 Winning positions in a two-partner game
Let(V;E)beadiretedgraph,withV asetofvertiesandEVV asetofedges. ThesetsV
andE maybe inniteand theelementsof E arealsoalled positions. Weonsiderthefollowing
two-partnergame: startingfromaninitialpositionx
0
,eahpartnerinturn,hoosesapositionx
1
suh that (x
0
;x
1
) 2 E, then aposition x
2
suh that (x
1
;x
2
) 2 E, then aposition x
3
suh that
2
Infat,theonstrutionoperationlinkedtothe n-arysymbolf ofF isthemapping(a1;:::;an)7!b,where
thea
i
'sareanytrees andbisthe treedenedas followsfromthea
i
'sandtheirsetsofnodesE
i
's: the setE of
nodesofbis f"g[fixjx2E
i
andi21::ng and,foreahx2E,ifx=",thenb(x)=fandifxisoftheformiy,
withibeinganinteger,b(x)=a
i (y).
2 3
followinginnitegraphsorrespondtothetwofollowinggames:
1
0 2 3 4 5 6
Game 1 A non-negative integer i
is given and eah partner, in turn,
subtrats1or2fromi,butkeeping
inon-negative. Therstpersonwho
annotplayanymorehaslost.
0,0 1,0 2,0 3,0
0,1 1,1 2,1 3,1
0,2 1,2 2,2 3,2
0,3 1,3 2,3 3,3
Game 2An orderedpair (i;j) ofnon-negativeintegersis
givenandeahpartner,inturn,hoosesoneoftheintegers
i;j. Depending onwhether thehosenintegeruis oddor
even,hetheninreasesordereasestheotherintegerv by
1,butkeepingvnon-negative. Therstpersonwhoannot
playanymorehaslost.
Letx2V beanyvertexofthediretedgraph(V;E)andsupposethatitistheturn ofperson
Atoplay. Theposition xissaidtobek-winningif,nomatterthewaytheotherpersonB plays,
itisalwayspossibleforAtowin,afterhavingmadeatmostkmoves. Thepositionxissaidtobe
k-losingif,nomatterthewayAplays,B analwaysforeAtoloseandtoplayatmostkmoves.
3
2.2 Expressing k-winning positions by a rst-order onstraint
Insteadoftreeonstraints,onsidergeneralonstraints,whiharerst-orderformulaewhosefun-
tionand relation symbols are interpreted in a given struture D, that is a set D together with
operations and relations. Let G = (V;E) be the graph representing a two-partner game, with
V D,andletmove(x;y)beaonstraintinDsuhthat:
4
foreaha2V andb2V, move(a;b) i (a;b)2E: (1)
We want to build onstraints winning
k
(x) and losing
k
(x) in D, suh that, for k 0 and eah
a2V,
winning
k
(a) i aisak-winningpositionofG;
losing
k
(a) i aisak-losingpositionofG:
>From the denition of k-winning and k-losingpositions in the preeding setion, we inferrst
that,foreveryk0:
winning
0
(x) $ false;
winning
k +1
(x) $ 9y move(x;y)^losing
k (y);
(2)
losing
k
(x) $ 8y move(x;y)!winning
k
(y): (3)
3
Fortherstgame,itanbeshownthatthesetofk-winningpositionsisthesetofnon-negativeintegersisuh
thati<3k andiisnot divisibleby3. For theseondgame,it isthe set oforderedpairs(i;j)of non-negative
integers,suhthati+j<2kandi+j isodd.
4
If'(x
1
;:::;x
n
)denotesaonstraintwhosefreevariablesareamongthex
i
's,andifthea
i
'sareelementsofD,
then'(a
1
;:::;a
n
)istheinterpretationoftheonstraintinD,wherethefreeourrenesofthex
i
'sareinterpreted
bytheorrespondingai's.
bereplaedby
winning
k (x) $
9ymove(x;y)^:(
9xmove(y;x)^:(
9ymove(x;y)^:(
9xmove(y;x)^:(
:::
9ymove(x;y)^:(
9xmove(y;x)^:(
false ):::)
|{z}
2k
(4)
Thusequivalenes(4)and(3)provideanexpliitwayforbuildingtheonstraintsweneed. Notie
that,bymovingthenegationsdownin(4), wegetanestingof2k alternatedquantiers.
5
Itispossibleto keepequivalene(4),whileweakeningondition(1). Werstremark,that for
anynon-negativek,thefollowingpropertyholds:
Property 1 Let three direted graphs be of the form G
1
= (V
1
;E
1 ), G
2
= (V
2
;E
2
) and G =
(V
1 [V
2
;E
1 [E
2
). ThegraphsG
1
andGhavethe sameset ofk-winningpositions, if both:
1. the setsof verties V
1 andV
2
are disjoint,
2. for eahx2V
2
,thereexistsy2V
2
with(x;y)2E
2 .
Indeed,fromtherstonditionitfollowsthatE
1 and E
2
aredisjointand thus thattheset ofk-
winningpositionsofGistheunionofthesetofk-winningpositionsofG
1
withthesetofk-winning
positionsofG
2
. Butthis lastsetisemptybeauseoftheseondondition.
Itfollowsthat:
Property 2(Generalized move) Equivalene(4)holdsalsoforanyonstraintmove(x;y)obey-
ingthe threeonditions:
1. for eaha2V andb2V,if(a;b)2E thenmove(a;b),
2. for noa2D V andnob2V wehave move(a;b),
3. for eaha2D V,thereexistsb2D V suhthatmove(a;b).
2.3 Example : tree onstraint for game 1
Wenowreonsidergame 1introduedin setion2.1. Asstruture Dwe takethe algebra(A ;F)
ofinnite treesonstruted on aset F of funtion symbols inludingamong others thesymbols
0;s, of respetivearities0;1. We ode thevertiesi of thegame graphby thetrees s i
(0).
6
Let
G=(V;E)bethegraphobtainedthisway.
Then,asgeneralizedmove(x;y)onstraintweantake:
move(x;y) def
= x=s(y)_x=s(s(y))_(:(x=0)^:(9ux=s(u))^x=y)
andaordingtoproperty2,thesetofk-winningpositionsofgame1isthesetofsolutionsinxof
theonstraintwinning
k
(x) denedby(4).
5
Fromthethreeequivalenesin(2)and(3)itfollowsthat8xwinning
k
(x)!winning
k+1
(x)and8xlosing
k (x)!
losing
k+1
(x),foranyk0. Indeed,fromthe rstandthelastequivaleneweonludethattheimpliationshold
fork=0and,ifweassumethattheyholdforaertaink0,fromthelasttwoequivalenesweonludethatthey
alsoholdfork+1.
6
Ofourse,s 0
(0)=0ands i+1
(0)=s(s i
(0)).
k
x=s(0)_x=s(s(0))
and,fork=2,to
x=s(0)_x=s(s(0))_x=s(s(s(s(0))))_x=s(s(s(s(s(0))))):
2.4 Example : tree onstraint for game 2
Wealsoreonsider game2introduedin setion 2.1. As strutureD wetakethe algebra(A ;F)
ofinnite treesonstruted on aset F offuntion symbols inludingamong others thesymbols
0;f;g;,of respetivearities0;1;1;2. We ode theverties(i;j) ofthegame graphbythe trees
(i;j)with i=(fg) i
2
(0), if iis even, and i=g(i 1), ifi isodd.
7
Let G=(V;E) be thegraph
obtainedthisway.
Theperspiaiousreader will onvinehimself that, as generalizedonstraintmove(x;y), we
antake:
move(x;y) def
= transition(x;y)_(:(9u9vx=(u;v))^x=y)
with
transition(x;y) def
= 2
6
6
6
6
6
6
4
9u9v9w
(x=(u;v)^y=(u;w))_
(x=(v;u)^y=(w;u))
^
(9iu=g(i)^su(v;w))_
(:(9iu=g(i))^pred(v;w))
3
7
7
7
7
7
7
5
su(v;w)
def
=
((9jv=g(j))^w=f(v))_
(:(9jv=g(j))^w=g(v))
pred(v;w)
def
= 2
6
6
6
6
6
4
(9jv=f(j)^
(9kj=g(k)^w=j)_
(:(9kj=g(k))^w=v)
)_
(9jv=g(j)^
(9kj=g(k)^w=v)_
(:(9kj=g(k))^w=j)
)_
(:(9jv=f(j))^:(9jv=g(j))^:(v=0)^w=v) 3
7
7
7
7
7
5
Aordingtoproperty2,thesetofk-winningpositionsofgame2isthesetofsolutionsinxofthe
onstraintwinning
k
(x)denedin (4).
Forexample,fork=1theonstraintwinning
k
(x)isequivalentto
x=(g(0);0)_x=(0;g(0))
and,fork=2,to
x=(0;g(0))_x=(g(0);0)_x=(0;g(f(g(0))))_
x=(g(0);f(g(0)))_x=(f(g(0));g(0))_x=(g(f(g(0)));0)
3 Composition of onstraints
We now move on to a systemati way of ompressing a onjuntion of a very large number of
onstraintsintoasmall onstraint.
7
Ofourse,(fg) 0
(x)=xand(fg) i+1
(x)=f(g((fg) i
(x))).