[Up] [Next]
Go up to Extending DCGs: Agreement
Go forward to Prolog Implementation

Agreement in Context Free Grammar Rules

The grammar programs discussed in section Context Free Grammars and section Definite Clause Grammars describe a very small fragment of English. It is simplistic and ignores many potentially relevant syntactic features, such as subject--agreement. Nodes labeled verb are rewritten as chases without actually checking whether this fits the subject or any restriction there may be on tense. This is acceptable behaviour (in the sense that it will not allow any sentences which human subjects would consider unacceptable) in this particular grammar and dictionary, as all possible NPs are third person singular and the rules only allow sentences with a single finite verb. But say that we want to write a grammar which recognises (1) and (4) below as grammatical, while not admitting (2) and (3):

  1.   The cat miaows.
  2. The cat miaow.
  3. The cats miaows.
  4.   The cats miaow.
With rules such as
s -> np vp
np -> det noun 
vp -> verb
a tree representation of the sentence would be as in the figure below.
Figure 4 : A parse tree for the sentences in examples (1).
  But this shows that accounting for subject--verb agreement is potentially a problem for context free grammars. Specifically, when rewriting a node into a terminal, we are not allowed to take any other part of the tree into account, but here we want the terminal attached to the V-node to agree with the terminal attached to the N-node. A context free grammar cannot include a rule which lets the V-node have access to information about the N-node (and this would be undesirabe anyway, as it is rather difficult to write a program which does that)>

This is what we do instead: a context free grammar can only pass information from a node to its daughters. So the information that the terminals should agree must be introduced at a point where it can be passed onto two daughters. With respect to the figure above, this means where the S is rewritten into the NP and the VP. We then let the information trickle down through the tree until it is finally used to select an appropriate dictionary rule. This is the sort of behaviour we need (all occurrences of the Num variable must be instantiated to the same value throughout each rule):

s -> np(Num), vp(Num)
np(Num) -> det(Num), n(Num)
vp(Num) -> verb(Num), np(Num2)
The information that the subject and the verb will agree is introduced by the S-node, passed onto both the NP-- and VP--nodes, which in turn pass it onto the N-- and V--nodes, thus allowing it to be used for the selection of an appropriate terminal. This method allows us to use ordinary phrase structure rules, instead of using information from adjacent nodes. The number information will be present at all relevant nodes, being passed on through each subsequent rewrite rule. We call information that is passed on this way FEATURES. An NP has a feature Number, which must agree with the Number feature on its sister VP in the sentence rule.


[Up] [Next]