Toward a Compositional Theory of Leftist Grammars and Transformations⋆ P.ChambartandPh.Schnoebelen LSV,ENSCachan,CNRS 0 61,av.Pdt.Wilson,F-94230Cachan,France 1 0 2 Abstract. Leftistgrammars[Motwanietal.,STOC2000]arespecialsemi-Thue n a systemswheresymbolscanonlyinsertorerasetotheirleft.Wedevelopatheory J ofleftistgrammarsseenaswordtransformersasatooltowardrigorousanalyses 7 of their computational power. Our maincontributions inthisfirstpaper are(1) 2 constructionsprovingthatleftisttransformationsareclosedundercompositions andtransitiveclosures,and(2)aproofthatboundedreachabilityisNP-complete ] evenforleftistgrammarswithacyclicrules. L F . s 1 Introduction c [ Leftist grammarswere introducedby Motwaniet al. to study accessibility and safety 1 inprotectionsystems[MPSV00].Inthisframework,leftistgrammarsareusedtoshow v thatrestrictedaccessibilitygrammarshavedecidableaccessibilityproblems(unlikethe 7 4 moregeneralaccess-matrixmodel). 0 Leftistgrammarsarebothsurprisinglysimpleandsurprisinglycomplex.Simplicity 5 comes from the fact that they only allow rules of the form “a→ba” and “cd →d” . 1 where a symbol inserts, resp. erases, another symbol to its left while remaining un- 0 changed. But the combination of insertion and deletion rules makes leftist grammars 0 go beyondcontext-sensitive grammars, and the decidability result comes with a high 1 complexity-theoreticalprice [Jur08]. Mostof all, what is surprisingis thatapparently : v leftist grammars had not been identified as a relevant computational formalism until Xi 2000. Theknownfactsonleftistgrammarsandtheircomputationalandexpressivepower r a are rather scarce. Motwani et al. show that it is decidable whether a given word can be derived (accessibility) and whether all derivable words belong to a given regular language (safety) [MPSV00]. Jurdzin´ski and Lorys´ showed that leftist grammars can define languages that are not context-free [JL07] while leftist grammars restricted to acyclicrulesarelessexpressivesincetheycanonlyrecognizeregularlanguages.Then Jurdzin´skishowedaPSPACElowerboundforaccessibilityinleftistgrammars[Jur07], beforeimprovingthistoanonprimitive-recursivelowerbound[Jur08]. Jurdzin´ski’sresultsrelyonencodingclassicalcomputationalstructures(linear-boun- dedautomata[Jur07]andAckermann’sfunction[Jur08])inleftistgrammars.Devising such encodings is difficult because leftist grammars are very hard to control. Thus, ⋆WorksupportedbytheAgenceNationaledelaRecherche,grantANR-06-SETIN-001. 2 P.ChambartandPh.Schnoebelen forcomputingAckermann’sfunction,devisingtheencodingisactuallynotthehardest part:the hardertask is to provethatthe constructedleftist grammarcannotbehavein unexpectedways.Inthisregard,thepublishedproofsarenecessarilyincomplete,hard to follow, and hard to fully acknowledge. The final results and intermediary lemmas cannoteasilybeadaptedorreused. Our Contribution. We developa compositionaltheoryof leftist grammarsand leftist transformations(i.e.,operationsonstringsthatarecomputedbyleftistgrammars)that provides fundamental tools for the analysis of their computational power. Our main contributionsareeffectiveconstructionsforthecompositionandthetransitiveclosure of leftist transformations.Thecorrectnessproofsfor these constructionsare based on newdefinitions(e.g.,forgreedyderivations)andassociatedlemmas. AfirstapplicationofthecompositionaltheoryisgiveninSection6whereweprove theNP-completenessofboundedreachabilityquestions,evenwhenrestrictedtoacyclic leftistgrammars. A secondapplication,andthe main reasonforthispaper,isour forthcomingcon- structionprovingthatleftistgrammarscansimulate lossychannelsystemsand“com- pute”allmultiply-recursivetransformationsandnothingmore(basedon[CS08b]),thus providingaprecisemeasureoftheircomputationalpower.Finally,afterourintroduction ofPost’sEmbeddingProblem[CS07,CS08a],leftistgrammarsareanotherbasiccom- putationalmodelthatwillhavebeenshownto captureexactlythe notionofmultiply- recursivecomputation. As furthercomparisonwith earlier work,we observethat, of course,the complex constructionsin[Jur07,Jur08]arebuiltmodularly.However,themodularityisnotmade fullyexplicitintheseworks,theinterfacingassumptionsareincompletelystated,orare mixedwith thedetailsofthe constructions,andcorrectnessproofscannotbegivenin full. OutlineofthePaper. BasicnotationsanddefinitionsarerecalledinSection2.Section3 definesleftistgrammarsandprovesageneralizedversionofthecompletenessofgreedy derivations.Sections4introducesleftisttransformersandtheirsequentialcompositions. Section 5 specializes on the “simple” transformers that we use in Section 6 for our encodingof3SAT.FinallySection7showsthatso-called“anchored”transformersare closedunderthetransitiveclosureoperation,thisinaneffectiveway. 2 BasicDefinitions andNotations Words. Weusex,y,u,v,w,a ,b ,...todenotewords,i.e.,finitestringsofsymbolstaken fromsomealphabet.Concatenationisdenotedmultiplicativelywithe (theemptyword) asneutralelement,andthelengthofxisdenoted|x|. Thecongruenceonwordsgeneratedbytheequivalencesa≈aa(forallsymbolsa inthealphabet)iscalledthestutteringequivalenceandisalsodenoted≈:everywordx hasaminimalandcanonicalstuttering-equivalentx′obtainedbyrepeatedlyeliminating symbolsinxthatareadjacenttoacopyofthemselves. Wesaythatxisasubwordofy,denotedx⊑y,ifxcanbeobtainedbydeletingsome symbols (an arbitrarynumber,at arbitrary positions) from y. We further write x⊑S y TowardaCompositionalTheoryofLeftistGrammarsandTransformations 3 whenallthesymbolsdeletedfromybelongtoS (NB:we donotrequirey∈S ∗),and let⊒denotetheinverserelation⊑−1. RelationsandRelationAlgebra. WeseearelationRbetweentwosetsX andY asaset ofpairs,i.e.,someR⊆X×Y.WewritexRyratherthan(x,y)∈R.TworelationsRand R′ can be composed,denotedmultiplicativelywith R.R′, and definedby x(R.R′)y⇔def ∃z. xRz ∧ zR′y . (cid:0)TheunionR+(cid:1)R′,alsodenotedR∪R′,isjusttheset-theoreticunion.Rn isthen-th powerR.R...RofRandR−1istheinverseofR:xR−1y⇔defyRx.Thetransitiveclosure S RnofRassumesY =X andisdenotedR+,whileitsreflexive-transitiveclosure n=1,2,... isR+∪Id ,denotedR∗. X Below we often use notations from relation algebra to state simple equivalences. E.g.,wewrite“R=R′”and“R⊆S”ratherthan“xRyiffxR′y”and“xRyimpliesxSy”. Ourproofsoftenrelyonwell-knownbasiclawsfromrelationalgebra,like(R.R′)−1= R′−1.R−1,or(R+R′).R′′=R.R′′+R′.R′′,withoutexplicitlystatingthem. 3 Leftist Grammars A leftist grammar (an LGr) is a triple G=(S ,P,g) where S ∪{g}={a,b,...} is a finitealphabet,g6∈S isafinalsymbol(alsocalled“axiom”),andP={r,...}isasetof productionrulesthatmaybeinsertionrulesoftheforma→ba,anddeletionrulesof theformcd→d.Forsimplicity,weforbidrulesthatinsertordeletetheaxiomg(this isnolossofgenerality[JL07,Prop.3]). Leftist grammars are not context-free (deletions are contextual), or even context- sensitive (deletions are not length-preserving). For our purposes, we consider them as string rewritesystems, morepreciselysemi-Thuesystems. Writing S for S ∪{g}, g the rules of P define a 1-step rewrite relation in the standard way: for u,u′ ∈S ∗, we g write u⇒r,p u′ wheneverr is some rule a →b , u is some u a u with |u a |= p and 1 2 1 u′ =u b u . We often write shortly u⇒r u′, or evenu⇒u′, when the positionor the 1 2 rule involvedin the step can be left implicit. On the other hand, we sometimes use a subscript,e.g.,writingu⇒ v,whentheunderlyinggrammarhastobemadeexplicit. G A derivation is a sequence p of consecutive rewrite steps, i.e., is some u0 ⇒r1,p1 u1⇒r2,p2 u2···⇒rn,pn un,oftenabbreviatedasu0⇒n un, orevenu0⇒∗ un. A subse- quence(ui−1⇒ri,pi ui)i=m,m+1,...,l of p is a subderivation.As with allsemi-Thuesys- tems,steps(andderivations)areclosedunderadjunction:ifu⇒u′thenvuw⇒vu′w. Two derivations p =(u ⇒∗ u′) and p =(v ⇒∗ v′) can be concatenated in the 1 2 obviousway (denoted p .p ) if u′ =v. They are equivalent,denoted p ≡p , if they 1 2 1 2 havesameextremities,i.e.,ifu=vandu′=v′. Wesaythatu∈S ∗isacceptedbyGifthereisaderivationoftheformug⇒∗gand wewriteL(G)forthesetofacceptedwords,i.e.,thelanguagerecognizedbyG. WesaythatI⊆S ∗isaninvariantforanLGrG=(S ,P,g)ifu∈Iandug⇒vgentail v∈I.KnowingthatIisaninvariantforGisusedintwosymmetricways:(1)fromu∈I andug⇒∗vgonededucesv∈I,and(2)fromug⇒∗vgandv6∈Ionededucesu6∈I. 4 P.ChambartandPh.Schnoebelen 3.1 GraphsandTypesforLeftistGrammars When dealing with LGr’s, it is convenient to write insertion rules under the simpler form“a b”,anddeletionrulesas“d c”,emphasizingthefactthata(resp.d)isnot modifiedduringtheinsertionofb(resp.thedeletionofc)onitsleft.Fora∈S ,welet g def def ins(a)={b|P∋(a b)}anddel(a)={b|P∋(a b)}denotethesetofsymbols thatcanbeinserted(respectively,deleted)bya.We writeins+(a)forthesmallestset that containsb and ins+(b) for all b∈ins(a), while del+(b) is defined similarly. We saythataisinactiveinaLGrifdel(a)∪ins(a)=∅. ItisoftenconvenienttoviewLGr’sinagraph-theoreticalway.Formally,thegraph ofG=(S ,P,g)isthedirectedgrapht havingthesymbolsfromS asverticesandthe G g rulesfromPasedges(comingintwokinds,insertionsanddeletions).Furthermore,we oftendecoratesuchgraphswithextrabookkeepingannotations. We say that G “has type t ” when t is a sub-graph of t . Thus a “type” is just a G restriction on what are the allowed symbols and rules between them. Types are often givenschematically,groupingsymbolsthatplayasimilarroleintoasinglevertex.For insertion: S g deletion: Fig.1.Universaltype(schematically). example,Fig.1displaysschematicallythetype(parametrizedbythealphabet)observed byallLGr’s. 3.2 Leftmost,PureandEagerDerivations We speak informallyof a “letter”, say a, when we really mean “an occurrenceof the symbola”(insomeword).Furthermore,wefollowlettersalongstepsu⇒v,identifying thelettersinuandthecorrespondinglettersinv.Hencea“letter”isalsoasequenceof occurrencesinconsecutivewordsalongaderivation. Aletteraisan-thdescendantofanotherletterb(inthecontextofaderivation)ifa hasbeeninsertedbyb(whenn=1),orbya(n−1)-thdescendantofb. Given a step u⇒r,p v, we say that the p-th letter in u, written u[p], is the active letter: the one that inserts, or deletes, a letter to its left. This is often emphasized by writingthestepundertheform(u=)u au ⇒u′au (=v)(assumingu[p]=a). 1 2 1 2 Aletterisinertinaderivationifitisnotactiveinanystepofthederivation.Aset of letters is inert if it only contains inertletters. A derivationis leftmost if every step u au ⇒u′au inthederivationissuchthatu isinertintherestofthederivation. 1 2 1 2 1 Aletterisusefulinaderivationp =(u⇒∗v)ifitbelongstouorv,orifitinserts or deletes a useful letter along p . This recursive definition is well-founded:since let- tersonlyinsertordeletetotheirleft,the“inserts-or-deletes”relationbetweenlettersis acyclic.Aderivationp ispureifalllettersinp areuseful.Observethatifp isnotpure, TowardaCompositionalTheoryofLeftistGrammarsandTransformations 5 itnecessarilyinsertsatsomestepsomelettera(calledauselessletter)thatstaysinert andwilleventuallybedeleted. Aderivationiseager if,informally,deletionsoccurassoonaspossible.Formally, p =(u0⇒r1,p1 u1···⇒rn,pn un)isnoteagerifthereissomeui−1 oftheformw1baw2 where b is inert in the rest of p and is eventually deleted, where P contains the rule a b,andwherer isnotadeletionrule.1 i A derivation is greedy if it is leftmost, pure and eager. Our definition general- izes[Jur07,Def.4],mostnotablybecauseitalsoappliestoderivationsug⇒∗vgwith nonemptyv.Henceasubderivationp ′ ofp isleftmost,eager,pure,orgreedy,whenp is. Thefollowingpropositiongeneralizes[Jur07,Lemma7]. Proposition3.1 (Greedyderivationsaresufficient).Everyderivationp hasanequiv- alentgreedyderivationp ′. Proof. Withaderivationp oftheformu0⇒r1,p1u1⇒r2,p2u2···⇒rn,pnun,weassociate its measure µ(p )d=efhn,p ,...,p i, a (n+1)-tuple of numbers. Measures are linearly 1 n ordered with the lexicographic ordering, giving rise to a quasi-ordering,denoted ≤ , µ betweenderivations.A derivationiscalled µ-minimalif anyequivalentderivationhas greaterorequalmeasure. We can now prove Prop. 3.1 along the following lines (see Appendix A for full details):firstprovethateveryderivationhasaµ-minimalequivalent(LemmaA.1),then showthatµ-minimalderivationsaregreedy(LemmaA.2). ⊓⊔ Observethat≤ iscompatiblewith concatenationofderivations:if p ≤ p then µ 1 µ 2 p .p .p ′≤ p .p .p ′ whentheseconcatenationsaredefined.Thusanysubderivationofa 1 µ 2 µ-minimalderivationisµ-minimal,hencealsogreedy. µ-minimalityisstrongerthangreediness,andisapowerfulandconvenienttoolfor provingProp. 3.1.However,greedinessis easier to reason with since it only involves localpropertiesofderivations,whileµ-minimalityis“global”.Theseintuitionsarere- flectedby,andexplain,thefollowingcomplexityresults. Theorem3.2. 1.Greediness(decidingwhetheragivenderivationp inthecontextofa givenLGrGisgreedy)isinL. 2.µ-Minimality(decidingwhetheritisµ-minimal)iscoNP-complete,evenifwerestrict toacyclicLGr’s. Proof. 1.Beingleftmostoreageriseasilycheckedinlogspace(i.e.,isinL).Checking non-puritycanbedonebylookingforalastinserteduselessletter,henceisinLtoo. 2. µ-minimality is obviously in coNP. Hardness is proved as Coro. 6.9 below, as a byproductofthereductionweusefortheNP-hardnessofBoundedReachability. ⊓⊔ 1Eagernessdoes not requirethatr deletesb: other deletionsareallowed,only insertionsare i forbidden. 6 P.ChambartandPh.Schnoebelen 4 Leftist Grammarsas Transformers Someleftistgrammarsareusedascomputingdevicesratherthanrecognizersofwords. Forthispurpose,werequireastrictseparationbetweeninputandoutputsymbolsand speakofleftisttransformers,orshortlyLTr’s. 4.1 LeftistTransformers Formally,anLTrisaLGrG=(S ,P,g)whereS ispartitionedasA⊎B⊎C,andwhere symbolsfromAareinactiveinPandarenotinsertedbyP(seeFig.2).Thisisdenoted G :A ⊢C. Here A contains the input symbols, B the temporary symbols, and C the outputsymbols,andG ismoreconvenientlywrittenasG=(A,B,C,P,g).Whenthere isnoneedtodistinguishbetweentemporaryandoutputsymbols,wewriteGunderthe def formG=(A,D,P,g),whereD=B∪Ccontainsthe“working”symbols, A D g Fig.2.Typeofleftisttransformers. AconsequenceoftherestrictionsimposedonLTr’sisthefollowing: Fact4.1 A∗D∗ isaninvariantinanyLTrG=(A,D,P,g). WithG=(A,B,C,P,g), weassociate a transformation(arelationbetweenwords) R ⊆A∗×C∗definedby G uR v ⇔def ug⇒∗ vg∧u∈A∗ ∧v∈C∗ G G andwesaythatGrealizesR .Finally,aleftisttransformationisanyrelationonwords G realizedbysomeLTr.Bynecessity,aleftisttransformationcanonlyrelatewordswritten usingdisjointalphabets(thisisnotcontradictedbye R e ). G Leftist transformations respect some structural constraints. In this paper we shall usethefollowingproperties: Proposition4.2 (Closure for leftist transformations,see App. B). If G:A⊢C is a leftisttransformer,thenR = (⊒ .≈.R .≈). G A G 4.2 Composition We say thattwoleftisttransformationsR ⊆A∗×C∗ andR ⊆A∗×C∗ arechainable 1 1 1 2 2 2 ifC =A andA ∩C =∅.TwoLTr’sarechainableiftheyrealizechainabletransfor- 1 2 1 2 mations. Theorem4.3. ThecompositionR .R oftwochainableleftisttransformationsisaleft- 1 2 ist transformation.Furthermore,onecan buildeffectivelya linear-sized LTr realizing R .R fromLTr’srealizingR andR . 1 2 1 2 TowardaCompositionalTheoryofLeftistGrammarsandTransformations 7 Foraproof,assumeG =(A ,B ,C ,P ,g)andG =(A ,B ,C ,P ,g)realizeR and 1 1 1 1 1 2 2 2 2 2 1 R .Beyondchainability,weassumethatA ∪B andB ∪C aredisjoint,whichcanbe 2 1 1 2 2 ensuredbyrenamingtheintermediarysymbolsinB andB .ThecomposedLTrG .G 1 2 1 2 isgivenby def G .G =(A ,B ∪C ∪B ,C ,P ∪P ,g). 1 2 1 1 1 2 2 1 2 ThisisindeedaLTrfromA toC .SeeFig.3foraschematicsofitstype.SinceG .G 1 2 1 2 g P P P 1 2 1 P 2 A1 D1(⊇A2) D2 P P 1 2 P P 1 2 Fig.3.ThetypeofG .G . 1 2 hasallrulesfromG andG itisclearthat(⇒ +⇒ )⊆⇒ ,fromwhichwededuce 1 2 G1 G2 G RG1.RG2 ⊆RG1.G2.Furthermore,theinclusionintheotherdirectionalsoholds: Lemma4.4 (CompositionLemma,seeAppendixC).RG1.G2 =RG1.RG2. Remark4.5 (Associativity).Thecomposition(G .G ).G iswell-definedifandonlyif 1 2 3 G .(G .G )is.Furthermore,thetwoexpressionsdenoteexactlythesameresult. ⊓⊔ 1 2 3 5 Simple LeftistTransformations AsatoolforSections6and7,wenowintroduceandstudyrestrictedfamiliesofleftist grammars(andtransformers)wheredeletionrulesareforbidden(resp.,onlyallowedon A). AninsertiongrammarisaLGrG=(S ,P,g)wherePonlycontaininsertionrules. SeeFig.4foragraphicdefinition.ForanarbitraryleftistgrammarG,wedenotewith Gins theinsertiongrammarobtainedfromGbykeepingonlytheinsertionrules. The insertion relation I ⊆ S ∗×S ∗ associated with an insertion grammar G = G (S ,P,g)isdefinedbyuIGv⇔defug⇒∗Gvg.Obviously,IG⊆⊑S .ObservethatIG isnot necessarilyaleftisttransformationsinceitdoesnotrequireanyseparationbetweenin- putandoutputsymbols. AsimpleleftisttransformerisanLTrG=(A,B,C,P,g)whereB=∅andwhereno ruleinPerasessymbolsfromC.SeeFig.4foragraphicdefinition.We give,without proof,animmediateconsequenceofthedefinition: Lemma5.1. Let G=(A,∅,C,P,g) be a simple LTr and assume ug⇒k vg for some G u∈A∗andv∈C∗.Thenk=|u|+|v|. 8 P.ChambartandPh.Schnoebelen S g A C g Fig.4.Typesofinsertiongrammars(left)andsimpleleftisttransformers(right). Given a simple LTr G=(A,∅,C,P,g) and two words u=a ···a ∈A∗ and v= 1 n c ···c ∈C∗, we say that a non-decreasing map h:{1,...,n}→{1,...,m} is a G- 1 m witnessforuandvifPcontainstherulesc a andc c (foralli=1,...,n h(i) i j+1 j and j=1,...,m, with the convention that c =g). Finally, we write u(cid:209) v when m+1 G suchaG-witnessexists.Clearly,(cid:209) ⊆R .Indeed,whenGisasimpletransformer,(cid:209) G G G canbeusedasarestrictedversionofR thatiseasiertocontrolandreasonabout. G Lemma5.2 (SeeApp.D).LetG=(A,∅,C,P,g)beasimpleLTr.ThenR =(cid:209) .I . G G Gins Combining Lemma 5.2 with IdC∗ ⊆IGins ⊆⊑C, we obtain the following weaker but simplerstatement. Corollary5.3. LetG=(A,∅,C,P,g)beasimpleLTr.Then(cid:209) ⊆R ⊆(cid:209) .⊑ . G G G C 5.1 UnionofSimpleLeftistTransformers WenowconsiderthecombinationoftwosimpleLTr’sG =(A,∅,C ,P ,g)andG = 1 1 1 2 (A,∅,C ,P ,g) that transform from a same A to disjoint output alphabets, i.e., with 2 2 C ∩C =∅.WedefinetheirunionwithG +G d=ef (A,∅,C ∪C ,P ∪P ,g).Thisis 1 2 1 2 1 2 1 2 clearlyasimpleLTrwith(R +R )⊆R .Itfurthersatisfies: G1 G2 G1+G2 Lemma5.4. IfuR vthenu(R +R )v′forsomev′⊑v. G1+G2 G1 G2 Proof. AssumeuR v.WithCor.5.3,weobtainu(cid:209) v′forsomev′=c ···c ⊑ G1+G2 G1+G2 1 m v.HenceG +G hasinsertionrulesc c forall j=1,...,m,anddeletionrules 1 2 j+1 j oftheformc u[i].SinceC andC aredisjoint,eitheralltheserulesareinG (and h(i) 1 2 1 u(cid:209) v′),ortheyareallinG (andu(cid:209) v′).Henceu(R +R )v′. ⊓⊔ G1 2 G2 G1 G2 6 Encoding 3SATwithAcyclicLeftist Transformers Thissectionprovesthefollowingresult. Theorem6.1. BoundedReachabilityandExactBoundedReachabilityinleftistgram- marsareNP-complete,evenwhenrestrictingtoacyclicgrammars. (Exact)BoundedReachabilityisthequestionwhetherthereexistsan-stepderiva- tionu⇒nv(respectively,aderivationu⇒≤nvofnon-exactlengthatmostn)between givenuandv.Thesequestionsareamongthesimplestreachabilityquestionsand,since we consider that the input n is given in unary,2 they are obviously in NP for leftist grammars(andallsemi-Thuesystems). 2Itisnaturaltobeginwiththisassumptionwhenconsideringfundamentalaspectsofreachabil- itysincewritingnmoresuccinctlywouldblurthecomplexity-theoreticalpicture. TowardaCompositionalTheoryofLeftistGrammarsandTransformations 9 Consequently,ourcontributioninthispaperistheNP-hardnesspart.Thisisproved byencoding3SATinstancesinleftistgrammarswherereachingagivenfinalvamounts toguessingavaluationthatsatisfiestheformula.Whiletheideaofthereductioniseasy tograsp,thetechnicalitiesinvolvedareheavyanditwouldbedifficulttoreallyprove thecorrectnessofthereductionwithoutrelyingonacompositionalframeworklikethe onewedevelopinthispaper.Itisindeedverytemptingto“prove”itbyjustrunningan example. Ratherthanadoptingthiseasyway,weshalldescribethereductionasacomposition of simple leftist transformers and use our composition theorems to break down the correctnessproofinsmaller,manageableparts.Oncetheideasunderlyingthereduction are grasped, a good deal of the reasoning is of the type-checkingkind: verifyingthat theconditionsrequiredforcomposingtransformersaremet. Throughoutthis section we assume a generic 3SAT instance F =Vmi=1Ci with m 3-clauses on n Boolean variables in X ={x ,...,x }. Each clause has the formC = 1 n i W3k=1e i,kxi,k for some polarity e i,k ∈{+,−} and xi,k ∈X. (There are two additional assumptions on F that we postpone until the proof of Coro. 6.5 for clarity.) We use standardmodel-theoreticalnotationlike|=F (validity),ors |=F (entailment)whens isaBooleanformulaoraBooleanvaluationofsomevariables. We write s [x 7→b] for the extension of a valuation s with (x,b), assuming x 6∈ Dom(s ).Finally,foravaluationq :X →{⊤,⊥}andsome j=0,...,n,wewriteq to j denotetherestrictionq ofq onthefirst jvariables. |{x1,...,xj} 6.1 AssociatinganLTrGF withF Fortheencoding,weuseanalphabetS ={Tj,Uj,T′j,U′j|i=1,...,m∧ j=0,...,n}, i i i i i.e., 4(n+1) symbols for each clause. The choice of the symbols is that a U means “Undetermined”andaT means“True”,ordeterminedtobevalid. For j=0,...,n,letV d=ef{Uj,...,Uj,Tj,...,Tj},V′d=ef{U′j,...,U′j,T′j,...,T′j}, j 1 m 1 m j 1 m 1 m andWjd=efVj∪Vj′,sothatS ispartitionedinlevelswithS =Snj=0Wj.Witheachxj∈X weassociatetwointermediaryLTr’s: G⊤d=ef(W ,∅,V ,P,g), G⊥d=ef(W ,∅,V′,P′,g) j j−1 j j j j−1 j j withsetsofrulesP andP′.TherulesforG⊤aregiveninFig.5:somedeletionrulesare j j j conditional,dependingon whether x appearsin the clausesC ,...,C . The rulesfor j 1 m G⊥areobtainedbyswitchingprimedandunprimedsymbols,andbyhavingconditional j rules based on whether ¬x appears in the C’s. One easily checks that G⊤ and G⊥ j i j j are indeed simple transformers. They have same inputs and disjoint outputs so that theunion(G⊤+G⊥):W ⊢W iswell-defined.Hencethefollowingcompositionis j j j−1 j well-formed: GF d=ef(G⊤1 +G⊥1).(G⊤2 +G⊥2)···(G⊤n +G⊥n). WeconcludethedefinitionofGF withanintuitiveexplanationoftheideabehindthere- duction.GF operatesonthewordu0=U10···Um0 whereeachUi0standsfor“thevalidity ofclauseC isundeterminedatstep0(i.e.,atthebeginning)”.Atstep j,G⊤+G⊥picks i j j 10 P.ChambartandPh.Schnoebelen T1j−1 T′1j−1 T2j−1 T′2j−1 ··· Tmj−1 T′mj−1 T1j (ifxj|=C1) UU1′j−j−11 1 UT11jj UT22jj ······ UTmmjj g T2j ... (ifxj|=C2...) UU2′j2−j−11 U1j−1 U′1j−1 U2j−1 U′2j−1 ··· Umj−1 U′mj−1 Tmj (ifxj|=Cm) UUm′jm−j−11 Fig.5.P,therulesforG⊤:Fixedpartonleft,conditionalpartonright. j J avaluationforx :G⊤ picks“x =⊤”whileG⊥ picks“x =⊥”.ThistransformsUj−1 j j j j j i intoUj,andTj−1intoTj,movingthemtothenextlevel.Furthermore,anundetermined i i i Uj−1 can be transformedinto Tj ifC is satisfied by x . In addition,and because G⊤ i i i j j andG⊥musthavedisjointoutputalphabets,thesymbolsintheV ’scomeintwocopies j j (hencetheV′’s) thatbehaveidenticallywhentheyareinputinthetransformerforthe j nextstep. The reductionis concludedwith the followingclaim that we proveby combining Corollaries6.5and6.8below. F issatisfiableiffU0U0···U0g⇒2mnTnTn···Tng 1 2 m GF 1 2 m iffU0U0···U0g⇒≤2mnTnTn···Tng (Correctness) 1 2 m GF 1 2 m iffU0U0···U0g⇒∗ TnTn···Tng. 1 2 m GF 1 2 m ObservefinallythatGF isanacyclicgrammarinthesenseof[JL07],thatistosay, its rules define an acyclic “may-act-upon”relation between symbols. Such grammars are much weaker than generalLGr’s since, e.g., languagesrecognized by LGr’s with acyclicdeletionrules(andarbitraryinsertionrules)areregular[JL07]. Remark6.2. TheconstructionofGF fromF ,mostlyamountingtocopyingoperations fortheG⊤’sandG⊥’s,totype-checkingandsets-joiningoperationsforthecomposition j j oftheLTr’s,canbecarriedoutinlogarithmicspace. ⊓⊔ 6.2 CorrectnessoftheReduction Wesaythataworduis j-cleanifithasexactlymsymbolsandifu[i]∈{Tj,T′j,Uj,U′j} i i i i foralli=1,...,m.Itis⊤-homogeneous(resp.⊥-homogeneous)ifitdoesnotcontain any(resp.,onlycontains)primedsymbols. Let0≤ j≤nandq be a Booleanvaluationofx ,...,x :we say thata j-cleanu j 1 j respects(F under)q when,foralli=1,...,m,q |=C whenu[i]isdetermined(i.e., j j i ∈Tj+T′j).Finallyucodes(F under)q ifadditionallyeachu[i]isdeterminedwhen i i j q |=C.Thus,aworduthatcodessomeq exactlylists(viadeterminedsymbols)the j i j clausesofF madevalidbyq ,andtheonlyflexibilityinuisinusingtheprimedorthe j unprimedcopyofthesymbols.Hencethereisonlyone j-cleanucodingq thatis⊤- j homogeneous,andonlyonethatis⊥-homogeneous.Ifurespectsq insteadofcoding j it, morelatitudeexistssince symbolsmaybeundeterminedevenifthe corresponding