File Information
File: 05-lr/acl_arc_1_sum/cleansed_text/xml_by_section/metho/95/p95-1022_metho.xml
Size: 16,474 bytes
Last Modified: 2025-10-06 14:14:06
<?xml version="1.0" standalone="yes"?> <Paper uid="P95-1022"> <Title>The intersection of Finite State Automata and Definite Clause Grammars</Title> <Section position="3" start_page="159" end_page="159" type="metho"> <SectionTitle> 2 The intersection of a CFG and a FSA </SectionTitle> <Paragraph position="0"> The calculation of the intersection of a CFG and a FSA is very simple (Bar-Hillel et al., 1961). The (context-free) grammar defining this intersection is simply constructed by keeping track of the state names in the non-terminal category symbols. For each rule 9\[o -'-' Xl...X. there are rules (Xoqoq) &quot;-* (Xlqoql)(X2qlqa) .. . (X,q,-lq), for all q0...q.. Furthermore for each transition 6(qi, or) = qt we have a rule (orqiqk) --~ or. Thus the intersection of a FSA and a CFG is a CFG that exactly derives all parse-trees. Such a grammar might be called the parse-forest grammar.</Paragraph> <Paragraph position="1"> Although this construction shows that the intersection of a FSA and a CFG is itself a CFG, it is not of practical interest. The reason is that this * construction typically yields an enormous arnount of rules that are 'useless'. In fact the (possibly enormously large) parse forest grammar might define an empty language (if the intersection was empty).</Paragraph> <Paragraph position="2"> Luckily &quot;ordinary&quot; recognizers/parsers for CFG can be easily generalized to construct this intersection yielding (in typical cases) a much smaller grammar.</Paragraph> <Paragraph position="3"> Checking whether the intersection is empty or not is then usually very simple as well: only in the latter case will the parser terminate succesfully.</Paragraph> <Paragraph position="4"> To illustrate how a parser can be generalized to accept a FSA as input we present a simple top-down parser.</Paragraph> <Paragraph position="5"> A context-free grarnxrmr is represented as a definite-clause specification as follows. We do not wish to define the sets of terminal and non-terminal symbols explicitly, these can be understood from the rules that are defined using the relation rule / 2, and where symbols of the ~ are prefixed with '-' in the case of terminals and '+' in the case of non-terminals. The relation top/1 defines the start symbol. The language L' = a&quot;b&quot; is defined as: top (s) .</Paragraph> <Paragraph position="6"> rule(s, \[-a,+s,-b\]). rule(s, \[\]) .</Paragraph> <Paragraph position="7"> In order to illustrate how ordinary parsers can be used to compute the intersection of a FSA and a CFG consider first the definite-clause specification of a top-down parser. This parser runs in polynomial time if implemented using Earle), deduction or XOLDT resolution (Warren, 1992). It is assumed that the input string is represented by the trans / 3 predicate.</Paragraph> <Paragraph position="9"> The predicate side_effect is used to construct the parse forest grammar. The predicate always succoeds, and as a side-effect asserts that its argument is a rule of the parse forest grammar. For the senfence 'a a b b' we obtain the parse forest grammar:</Paragraph> <Paragraph position="11"> The reader easily verifies that indeed this grammar generates (a isomorphism of) the single parse tree of this example, assuming of course that the start symbol for this parse-forest grammar is p ( s, 0,4 ).</Paragraph> <Paragraph position="12"> In the parse-forest grammar, complex symbols are non-terminals, atomic symbols are terminals.</Paragraph> <Paragraph position="13"> Next consider the definite clause specification of a FSA. We define the transition relation using the relation trans/3. For start states, the relation start/1 should hold, and for final states the relation final/1 should hold. Thus the following FSA, defining the regular language L = (aa)*b + (i.e. an even number of a's followed by at least one b) is given as: start(qO), final(q2).</Paragraph> <Paragraph position="14"> trans(qO,a,ql), trans(ql,a,qO).</Paragraph> <Paragraph position="15"> trans(qO,b, q2). trans(q2,b, q2).</Paragraph> <Paragraph position="16"> Interestingly, nothing needs to be changed to use the same parser for the computation of the intersection of a FSA and a CFG. If our input 'sentence' now is the definition of trans / 3 as given above, we obtain the following parse forest granunar (where the start symbol is p ( s, q0, q2 ) ):</Paragraph> <Paragraph position="18"> Thus, even though we now use the same parser for an infinite set of input sentences (represented by the FSA) the parser still is able to come up with a parse forest grammar. A possible derivation for this grammar constructs the following (abbreviated) parse tree in figure 1. Note that the construction of Bar Hillel would have yielded a grammar with 88 rules.</Paragraph> </Section> <Section position="4" start_page="159" end_page="163" type="metho"> <SectionTitle> 3 The intersection of a DCG and a FSA </SectionTitle> <Paragraph position="0"> In this section we want to generalize the ideas described above for CFG to DCG.</Paragraph> <Paragraph position="1"> First note that the problem of calculating the intersection of a DCG and a FSA can be solved trivially by a generalization of the construction by (Bar-Hillel et al., 1961). However, if we use that method we will end up (typically) with an enormously large forest grammar that is not even guaranteed to contain solutions *. Therefore, we are interested in methods that only generate a small subset of this; e.g. if the intersection is empty we want an empty parse-forest grammar.</Paragraph> <Paragraph position="2"> The straightforward approach is to generalize existing recognition algorithms. The same techniques that are used for calculating the intersection of a FSA and a CFG can be applied in the case of DCGs.</Paragraph> <Paragraph position="3"> In order to compute the intersection of a DCG and a FSA we assume that FSA are represented as before.</Paragraph> <Paragraph position="4"> DCGs are represented using the same notation we used for context-free grammars, but now of course the category symbols can be first-order terms of arbitrary complexity (note that without loss of generality we don't take into account DCGs having exter\]In fact, the standard compilation of DCG into Prolog clauses does something similar using variables instead of actual state names. This also illustrates that this method is not very useful yet; all the work has still to be done. nal actions defined in curly braces).</Paragraph> <Paragraph position="5"> But if we use existing techniques for parsing DCGs, then we are also confronted with an undecidability problem: the recognition problem for DCGs is undecidable (Pereira and Warren, 1983). A fortiori the problem of deciding whether the intersection of a FSA and a DCG is empty or not is undecidable. null This undecidability result is usually circumvented by considering subsets of DCGs which can be recognized effectively. For example, we can restrict the attention to DCGs of which the context-free skeleton does not contain cycles. Recognition for such 'off-line parsable' grammars is decidable (Pereira and Warren, 1983).</Paragraph> <Paragraph position="6"> Most existing constraint-based parsing algorithms will terminate for grammars that exhibit the property that for each string there is only a finite number of possible derivations. Note that off-line parsability is one possible way of ensuring that this is the case.</Paragraph> <Paragraph position="7"> This observation is not very helpful in establishing insights concerning interesting subclasses of DCGs for which termination can be guaranteed (in the case of FSA input). The reason is that there are now two sources of recursion: in the DCG and in the FSA (cycles). As we saw earlier: even for CFG it holds that there can be an infinite number of analyses for a given FSA (but in the CFG this of course does not imply undecidability).</Paragraph> <Section position="1" start_page="161" end_page="162" type="sub_section"> <SectionTitle> 3.1 Intersection of FSA and off-line parsable DCG is undecidable </SectionTitle> <Paragraph position="0"> I now show that the question whether the intersection of a FSA and an off-line parsable DCG is empty is undecidable. A yes-no problem is undecidable (cf.</Paragraph> <Paragraph position="1"> (Hopcroft and Ullman, 1979, pp.178-179)) if there is no algorithm that takes as its input an instance of the problem and determines whether the answer to that instance is 'yes' or 'no'. An instance of a problem consists of a particular choice of the parameters of that problem.</Paragraph> <Paragraph position="2"> I use Post's Correspondence Problem (PCP) as a well-known undecidable problem. I show that if the above mentioned intersection problem were decidable, then we could solve the PCP too. The following definition and example of a PCP are taken from (Hopcroft and Ullman, 1979)\[chapter 8.5\].</Paragraph> <Paragraph position="3"> An instance of PCP consists of two lists, A = vx... vk and B = wl... wk of strings over some alphabet ~,,. Tl~s instance has a solution if there is any sequence of integers il... i,~, with m > 1, such that Vii, '0i2, * * &quot;, Vim ~ 'Wil ~ f~Li2, * &quot; * ~ ~im &quot; The sequence il, * *., im is a solution to this instance of PCP. As an example, assume that :C = {0,1}.</Paragraph> <Paragraph position="4"> Furthermore, let A = (1, 10111, 10) and B = 011, 10, 0). A solution to this instance of PCP is the sequence 2,1,1,3 (obtaining the sequence 10111Ul0).</Paragraph> <Paragraph position="5"> For an illustration, cf. figure 3.</Paragraph> <Paragraph position="6"> Clearly there are PCP's that do not have a solution. Assume again that E = {0, 1}. Furthermore let A = (1) and B = (0). Clearly this PCP does not have a solution. In general, however, the problem whether some PCP has a solution or not is not decidable. This result is proved by (Hopcroft and Ullman, 1979) by showing that the halting problem for Turing Machines can be encoded as an instance of</Paragraph> </Section> <Section position="2" start_page="162" end_page="162" type="sub_section"> <SectionTitle> Post's Correspondence Problem. </SectionTitle> <Paragraph position="0"> First I give a simple algorithm to encode any instance of a PCP as a pair, consisting of a FSA and an off-line parsable DCG, in such a way that the question whether there is a solution to this PCP is equivalent to the question whether the intersection of this FSA and DCG is empty.</Paragraph> <Paragraph position="1"> Encoding of PCP.</Paragraph> <Paragraph position="2"> 1. For each I < i < k (k the length of lists A and B) define a DCG rule (the i - th member of A is al ... am, and the i-th member of B is bl... b,): r(\[al ... a,~lA\], A, \[bl .. . b, iB\], B) ~ \[z\]. 2. Furthermore, there is a rule r(Ao,A, Bo, B) --+ r( Ao, A1, Bo, B1), r( A1, A, BI, B).</Paragraph> <Paragraph position="3"> 3. Furthermore, there is a rule s ~ r(X, \[\],X, \[\]). Also, s is the start category of the DCG.</Paragraph> <Paragraph position="4"> 4. Finally, the FSA consists of a single state q which is both the start state and the final state, and a single transition ~(q, z) = q. This FSA generates =*.</Paragraph> <Paragraph position="5"> Observe that the DCG is off-line parsable.</Paragraph> <Paragraph position="6"> The underlying idea of the algorithm is really very simple. For each pair of strings from the lists A and B there will be one lexical entry (deriving the terminal z) where these strings are represented by a difference-list encoding. Furthermore there is a general combination rule that simply concatenates Astrings and concatenates B-strings. Finally the rule for s states that in order to construct a succesful top category the A and B lists must match.</Paragraph> <Paragraph position="7"> The resulting DCG, FSA pair for the example PCP is given in figure 4: Proposition The question whether the intersection of a FSA and an off-line parsable DCG is empty is undecidable.</Paragraph> <Paragraph position="8"> ProoPS Suppose the problem was decidable. In that case there would exist an algorithm for solving the problem. This algorithm could then be used to solve the PCP, because a PCP ~r has a solution if and only if its encoding given above as a FSA and an off-line parsable DCG is not empty. The PCP problem however is known to be undecidable. Hence the intersection question is undecidable too.</Paragraph> </Section> <Section position="3" start_page="162" end_page="163" type="sub_section"> <SectionTitle> 3.2 What to do? </SectionTitle> <Paragraph position="0"> The following approaches towards the undecidability problem can be taken: * limit the power of the FSA * limit the power of the DCG * compromise completeness * compromise soundness These approaches are discussed now in turn. Limit the FSA Rather than assuming the input for parsing is a FSA in its full generality, we might assume that the input is an ordinary word graph (a FSA without cycles).</Paragraph> <Paragraph position="1"> Thus the techniques for robust processing that give rise to such cycles cannot be used. One example is the processing of an unknown sequence of words, e.g. in case there is noise in the input and it is not clear how many words have been uttered during this noise. It is not clear to me right now what we loose (in practical terms) if we give up such cycles.</Paragraph> <Paragraph position="2"> Note that it is easy to verify that the question whether the intersection of a word-graph and an off-line parsable DCG is empty or not is decidable since it reduces to checking whether the DCG derives one of a finite number of strings.</Paragraph> <Paragraph position="3"> Limit the DCG Another approach is to limit the size of the categories that are being employed. This is the GPSG and F-TAG approach. In that case we are not longer dealing with DCGs but rather with CFGs (which have been shown to be insufficient in general for the description of natural languages). Compromi~ completeness Completeness in this context means: the parse forest grammar contains all possible parses. It is possible to compromise here, in such a way that the parser is guaranteed to terminate, but sometimes misses a few parse-trees. For example, if we assume that each edge in the FSA is associated with a probability it is possible to define a threshold such that each partial result that is derived has a probability higher than the threshold. Thus, it is still possible to have cycles in the FSA, but anytime the cycle is 'used' the probability decreases and if too many cycles are encountered the threshold will cut off that derivation.</Paragraph> <Paragraph position="4"> Of course this implies that sometimes the intersection is considered empty by this procedure whereas in fact the intersection is not. For any threshold it is the case that the intersection problem of off-line parsable DCGs and FSA is decidable.</Paragraph> <Paragraph position="5"> Compromise soundness Soundness in this context should be understood as the property that all parse trees in the parse forest grammar are valid parse trees. A possible way to ensure termination is to remove all constraints from the DCG and parse according to this context-free skeleton. The resulting parse-forest grammar will be too general most of the times.</Paragraph> <Paragraph position="6"> A practical variation can be conceived as follows. From the DCG we take its context-free skeleton. This skeleton is obtained by removing the constraints from each of the grammar rules. Then we compute the intersection of the skeleton with the input FSA. This results in a parse forest grammar. Finally, we add the corresponding constraints from the DCG to the grammar rules of the parse forest gral'nrrlaro This has the advantage that the result is still sound and complete, although the size of the parse forest grammar is not optimal (as a consequence it is not guaranteed that the parse forest grammar contains a parse tree). Of course it is possible to experiment with different ways of taking the context-free skeleton (including as much information as possible / useful).</Paragraph> <Paragraph position="7"> ACknowledgments I would like to thank Gosse Bouma, Mark-Jan Nederhof and John Nerbonne for comments on this paper. Furthermore the paper benefitted from remarks made by the anonymous ACL reviewers.</Paragraph> </Section> </Section> class="xml-element"></Paper>