









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The concept of syntax and semantics in the context of formal language theory. It introduces the notion of derivations, congruences, and interpretations, and explains how they are related. The document also mentions the work of various authors in this field, including Hotz, Griffiths, and Kuno. It provides definitions and properties of derivations, congruences, and interpretations, and explains how they can be used to understand the structure of formal languages.
What you will learn
Typology: Exercises
1 / 16
This page cannot be seen from the preview
Don't miss anything!
Department of Computer and Information Science, University of North Carolina, Chapel Hill, North Carolina 27514
A syntax is a category of strings and derivations between them. The semantic domain is a category of sets and functions. An interpretation is a cofunctor from the syntax to the semantics generated from a correspondence between produc- tions and certain functions. There is a Galois connection between congruences on derivations and classes of interpretations. The smallest congruence of interest, similarity, is shown to correspond to the class of all interpretations. By considering certain subclasses of interpretations and the corresponding congruences, three different versions of "context-sensitive" are explicated.
T h o m p s o n (1966) proposed a notion of semantics for formal languages generated by a semithue system in which the interpretation of a derivation is a function. Implications of essentially these semantic notions for context-free languages, in particular the implications for compiler design, were found by Knuth (1968). These semantic notions bear strong resemblance to the seman- tic methods for logical calculi (cf. Cohn, 1965). I n the theory of models of logical calculi, the interpretations are to relational systems, and certain collections of interpretations play an important role. In programming languages, and formal language theory the semantics is an action, or function, on certain sets. For example, the retrieval of information or the call and sequential processing of a subroutine is such an action. Notions of truth are not central here. T h e classes of interpretations are, however, useful. Hotz (1966) (also see Schnorr, 1969) introduced the idea of using category theory to study the derivational structure imposed on a formal language by a rewriting system generating the language. T h e categorical formulation is refreshingly clear in its control of the details. A derivationat structure, here called a syntax, is a certain type of category generated by a semithue system. T h e derivational richness of a syntax depends on the intent of the study, as
145
643/I7/2-
146 BENSON
C = ( / ~ 0 _ ~'0 ,..., /'~n--1-/"~.--1 , "/r0-- P0 , ' " , ~'r'm--1 - P m - 1 ) -
external alphabets respectively, we define the external syntax, E, as the full
o) E E + such that (~b, ~o) is not empty in A. T h e strings in E + which are also
term "external" is used to avoid conflict with the use of the term "terminal" in category theory. T h e external syntax is not considered in the sequel. T h e following facts are immediate. If G is monogenic then A is ordered. G is loop free if and only if for each object 0 of A, (0, 0) contains only the iden-
with codomain a member of E + is epic. A does not, in general, have terminal objects.
T h e semantic domain is taken to be some fixed category of sets and func- tions, S, in which cartesian products are available. Cartesian product is considered to be an associative operation. With this, the extension of func-
function from X to Y, then t : W × X × Z -~ W × Y × Z is an extension o f f preserving W and Z iff t acts on Y as does f and acts as the identity on W and Z. That is, t is an extension o f f if the following three diagrams commute, where the unlabeled arrows are the projections.
classes o f qL T h e n
Z l 2 &
L e t H 1 a n d ~-~ be congruences on A, 31 a n d S 2 sub-
Intuitively, two derivations are congruent if they possess the same structure, therefore imposing the same collection of possible meanings on the derived sentence. T h e Galois connection results in a semantic definition of structure. The structural description of a derivation is the equivalence class to which it belongs, and by the Galois connection this is a function of the particular subclass of interpretations considered acceptable by some external criteria. T h e uninterpreted notion of structural description arises from the con- gruence relation of similarity, defined by Griffiths (1968). Let ~-~ denote the similarity relation for the rest of the paper. In this section we show that ~,~ = ~.~(~b). That is, two derivations are similar if and only if they are iden- tically interpreted by each possible interpretation. This result can be con- sidered an additional reason for studying the X-categories of G. Hotz. T h e free X-categories are the quotient categories of complete syntaxes modulo similarity. If ~ ( ~ ) is a proper subclass of q~ for some congruence ~ , the corresponding quotient category is a nonfree X-category. T o begin, the definition of uninterpreted, or syntactic, similarity is required. Similarity is the least congruence relation on A such that if
x : O - ~ ¢ , y : O ' ~ ¢ '
are derivations of A with extensions
Xo: 0 0 ' - + ¢0',
Yo : 00' ~ 0~',
and u = y l x o , v = x l y o , then u is similar to v, u ~-~ v. T o motivate this definition, a brief description of Griffiths' development is given. A derivation can be interchanged into another by switching a pair of production applications when the applications do not interact. From the
the generating relation for similarity is a subset of ~-~(¢), it follows from the definition of similarity as the least congruence than ~-~ _C ~-~((b). | T o show that u N v ( ¢ ) implies u ~ v requires developing an inter- pretation, Q, which recovers derivations up to similarity. Since Q ~ # , the desired result will follow from showing that a canonical derivation similar to
bering of derivations it is possible to obtain as an interpretation. T h e G6del
alphabet A and productions P.
Define the interpretation Q on letters of the alphabet by, for a ~ A,
Section 4.
canonical derivation similar to u.
iterations.
of gl ,-.., gl is a letter and therefore not a triple, no production was applied to the prefix y = gl "'" gi • I f i = m the construction is complete. I f i v~ m
the length of e is k, ~ is equal to the concatenate ofpogi+ 1 ,..., Pogi+~, each of Pdi+l ,...,Plgi+~ is equal to r, and g' = P~gi+l = "'" = P2gi+~, then the production r = ~ --~/3 is applied at this point in the canonical derivation v. T h e next finite sequence to which the reduction process applies is constructed by replacing, in (gl ,-.., g~), the subsequence (gi+l ..... gi+k) by the sequence g'. T h e procedure is iterated on the new sequence. In the above test for the applicability of r = ~--+ /3 if there is some j, 1 ~ j ~< k, such that c~j =/= Pogi+j or r ~ Pxg~+~ or g' ~ P~gi+j, the production r must be defered since some other production application occured first, overlapping the application under test at g~+j. In this case begin testing at position i + j. u is similar to some canonical derivation, say x. Hence Q(u) =- O(x) and Gd(u) --- Gd(x) ~ Gd(v). Since x is canonical by the above construction it is 7). T h u s u ~-~ 7). | From Propositions 5.3 and 5.4 we have
PROPOSITION 5.5. F o r u, 7) derivations of A , u ,-~ 7) iff 1z ~.~ 7.)((I)). | As corollaries note that if ~2 is a class of interpretations with Q E ~2 then ~(~2) = ~ and 3(,~(f2)) = ~. T h e congruence of equality on A has as its corresponding class of interpretations ¢, thus ,--~(Z(=)) = ~.
There are at least three different notions of the structural descriptions of sentences generated by a context-sensitive grammar. T h e first is the purely syntactic view in which the idea of allowing the rewriting by a context-free production only in a fixed (and local) context is avoided by requiring only that the length of production antecedents be less than or equal to the length of the corresponding production consequents. In this sense, the semithue produc- tion ~ - + fi is type one context sensitive just in case the length of a is less than or equal to the length of ft. It is well-known that the above is weakly equiv- alent to the more stringent condition on productions. However the correspond- ing structural descriptions lack the intuitively desired strength. Let P be a set of type one context sensitive productions and (A, P, s) generate the syntax C. T h e class of interpretations of C is denoted by ~ and the structural des- criptions of derivations in C are the morphisms of C/~-~. I n the purely syntactic view no additional structure is imposed. C is called a type one con- text sensitive syntax. T h e second and third notions arise from considering the context sensitive
A type three context-sensitive syntax is a type two context-sensitive syntax, C, with class of admissible interpretations, g?, the largest subclass of 3 such that for each I ~ f2 and each production x = a --+ 13/7 _ 3 generating C there exists a function
f ( x , I ) : I(fi) ---* I(a).
s'2 and the f u n c t i o n s f (x, I ) must satisfy the properties:
(i) T h e commutivity of
where the projections are again unlabeled.
(ii) If x = a ~ fi/y _ 3 and y = a --~ flirt _ p are productions then for each I e ~ , f ( x , I) : 1(/3) --~ I(a) = f ( y , I) : 1(/3) --~ I(a).
T h e latter property corresponds to considering a ~/3/Y - 3 and a --+/3/~- _ p to be a single context-free production a - + / 3 restricted to the context 7 - 3 or to ~r _ p. Without this property the underlying p-marker cannot be obtained. T h e structural description of a derivation x in C is the ~(g2) equivalence class [x]a. T o each equivalence class corresponds a unique p-marker of the under- lying context-free syntax, as the following demonstrates. Suppose P is the set of productions which together with their contexts generate the type three context-sensitive syntax C with class of interpreta- tions f2. T h e n R = {a ~ / 3 I a ~ / 3 / 7 - 8 ~ P } is the set of context-free productions generating the context-free syntax, D, with p-markers D / ~. T h e function F : P -+ R with F ( a --,/3/7 - 8) = a --+/3 extends to the context- freeing functor F : C -+ D. For each I : C ~ S in f2 define Jz : D ~ S by
(i) For each object 0, .1,(0) = I(0) (ii) On morphisms by induction from the productions R, where for each a --~ fi E R, Ji(a --~/3) = f ( x , I ) for any x = a -~ fi/7 - 8 e P such that = - + / 3.
T h e diagram C F + D
class of interpretations of D, since any K e q~o is extendible to some I ~/2. From the above association of a context-free system with the type three
C, is the similarity class of F(x), IF(x)|.
C ~ ~ D
The commutivity of the diagram is obtained directly from the defi- nition of G. |
From the propositions above one has
Kuno (1967) defines trees augmented by quadruples of integers at each node as the structural descriptions of context sensitive derivations. T h e corresponding uninterpreted congruence relation here is called cs-similarity. Cs-similarity, __~, is defined to be the least congruence on C such that
(i) x ~-~ y implies x ~__y, and
160 BENSON
REFERENCES
CoP~,,r, P. M. (1965), "Universal Algebra," Harper and Row, New York. DAVIS, M. (1958), "Computability and Unsolvability," McGraw-Hill Book Co., New York. EILENBERG, S. AND J. B. WRIGHT(1967), Automata in general algebras, Information and Control 11, 452-470. FREYD, P., (1964), "Abelian Categories," Harper and Row, New York. GI~SBURG, S. (1966), "The Mathematical Theory of Context-Free Languages," McGraw-Hill Book Co., New York. GRWFITHS, T. V. (1968), Some remarks on derivations in general rewriting systems, Information and Control 12, 27-54. HOTZ, G. (1966), Eindeutigkeit und Mehrdeutigkeit formaler Sprachen, EIK. 2, 235-247. KNUTH, D. E. (1968), Semantics of context-free languages, Math. Systems Theory 2, 127-146. MACLANE, S. AND G. BIaKHOFF(1967), "Algebra," Macmillian, New York. MITCHELL, B. (1965), "Theory of Categories," Academic Press, Inc., New York. KUNO, S. (1967), A context-sensitive recognition procedure, in Math. Linguistics and Auto. Translation Rpt. NSF-18, Aiken Comp. Lab., Harvard, Cambridge, Mass. NELSON, R. J. (1968), "Introduction to Automata," John Wiley and Sons, Inc., New York. SCHNOat~, C. P. (1969), Transformational classes of grammars, Information and Control 14, 252-277. THATCHEa, J. W. (1967), Characterizing derivation trees of context-free grammars through a generalization of finite automata theory, J. Comp. System Sci. 1, 317-323. T~OMPSON, F. B. (1966), English for the computer, AFIPS Conf. Proc. Vol. 29, 349-356, FJCC, Spartan Books, Washington, D. C.