Can We Transform Logic Programs into Attribute Grammars?

In this paper we study the relationship between Attribute Grammars and Logic Programs,concentrating on transforming logic programs into attribute grammars. Thishas potential applications in compilation techniques for logic programs. It does notseem possible to transform arbitrary Logic Programs into Attribute Grammars, basicallybecause the same logic variables can sometimes be used as input and sometimes asoutput. We introduce the notion of an Abstract Attribute Grammar, which is similar tothat of an Attribute Grammar with the exception that attributes are not classified intoinherited and synthesized, and that the semantic equations are replaced by restrictionsets. These sets represent a restriction on the values of attribute occurrences namely,all elements within each set have to be equal. We give an effective translation schemawhich produces an equivalent Abstract Attribute Grammar for a given Logic Program.We provide a formal proof of this equivalence. We then proceed to classify a classof Abstract Attribute Grammars that can be transformed into Attribute Grammars,and show how to achieve this transformation. By composing both transformations onecan transform certain logic programs into attribute grammars. Complete proofs ar5egiven.