\chapter{Brief overview of AGFL}\label{ch:intro}
In this chapter, we present a short introduction to the main features
of the \agfl\ formalism. For additional introductory material
we refer to the original article \cite{KOS91a} and to the \agfl\
website {\tt http://www.cs.kun.nl/agfl}.
In the next chapter a more systematic and complete description of the
\agfl\ formalism is presented.

Affix grammars can be seen as the formalization of a notion familiar
to linguists, namely that of a Context Free (CF) grammar extended with
features.
Other formalizations of the same notion are to be found
in attribute grammars and various more recent feature-based syntactic
formalisms.
The notation of \agfl\ is rather like that of {\sc prolog}, because
both have a common ancestor: The \XXs{two-level}{grammar} introduced in
1966 by Aad van Wijngaarden for the formal description of {\sc algol 68}
\cite{WIJ72}.

\agfl\ is intended as a practical formalism for describing the syntax of
natural languages. The \agfl\ system generates parsers from grammars and
lexica. It supports two kinds of applications:
\begin{itemize}
\item \XX{linguistic}{applications}, where all analyses of a given
(possibly {\em ambiguous}) utterance are to be found
\YY{Information Retrieval}{applications}
\item applications in {\bf Information Retrieval} and Natural Language
Front ends, where {\em the most likely analysis} has to be found for
consecutive segments of a running text.
\end{itemize}
In order to express the notion of likeliness and to obtain robust parsing,
a number of mechanisms (penalties and probabilities) have been provided.

\section{Affix Grammars and AGFL}
\agfl\ (for an explanation of the name, see \ref{whatis}) is a 
form of Affix grammars especially developed for describing the syntax of
natural languages.
Like other kinds of Affix Grammars, an \agfl\ has a first or
lower level consisting of context-free \XXs{syntax}{rule}, rewriting
nonterminals to terminals or to other nonterminals, and a second level
which adds \Xs{parameter} (called \Xes{affix}) to the first-level rules.
The characteristic property of \agfl\ is that the affixes are finite
set-valued.

The use of the term 'affix' rather than 'attribute' or 'feature' comes
from the original intuition of considering the affix as an ending to
the name of the nonterminal (like in the {\tt cfg} grammar).

\subsection{The first level}
A syntax rule without a second level is just a CF
rule, as can be seen in the following example:
\begin{grammar}
RULE sentence: subject, verb.
\end{grammar}
This rule states that the nonterminal {\tt sentence} can be rewritten
to a {\tt subject} followed by a {\tt verb}. It provides one
\X{production} for the nonterminal {\tt sentence}. The rule
\begin{grammar}
RULE subject:
   personal pronoun; noun phrase.
\end{grammar}
gives two productions for {\tt subject}. This particular rule has the
\XX{rule}{type} {\tt RULE}, which is also the default (so the symbol {\tt
RULE} may be omitted). Other rule types are {\tt OPTION} and {\tt
CONDITION} (see later). Names of nonterminals may be written in a
mixture of small and capital letters, and they may include embedded spaces
and underscores.

\subsection{The second level}
The second level is the level where the \Xes{affix} live (also known
as \Xs{attribute} or \Xs{feature}). As an example, the \XX{affix}{rule}
\begin{grammar}
NUMBER :: plural | singular.
\end{grammar}
defines the \XX{affix}{nonterminal} {\tt NUMBER} as the union ({\tt |})
of the \XXes{terminal}{affix} {\tt plural} and {\tt singular}. Names of
nonterminal affixes are written in capital letters, those of terminal
affixes in small letters (and a few special characters). Embedded spaces
are not allowed in affix names. An affix rule states that a nonterminal
affix can be rewritten into the union of certain affix-terminals or
affix-nonterminals. The \X{domain} of an affix nonterminal is a
\XX{finite}{set}, the union of all the terminal affixes to which it can be
rewritten.

\subsection{Combining the levels}
The two levels are combined by using affixes as parameters to
the nonterminals in the syntax rules.
According to the \X{consistent substitution rule}, all occurrences of
an affix within one rule obtain the same value. This implies computing the
largest intersection as a means for the \X{unification} of affix values.
As an example, the rule
\begin{grammar}
RULE sentence: subject (NUMBER), verb (NUMBER).
\end{grammar}
expresses the \X{agreement} in number between subject and verb.

The affix mechanism is a powerful tool to make a large CF grammar
more compact, while at the same time allowing for a linguistically
motivated way of describing. We will show this by the following, still
very small example.
\begin{grammar}
GRAMMAR cfg.
ROOT sentence.

RULE sentence: subject_plural, verb_plural.
RULE sentence: subject_singular, verb_singular.
RULE subject_plural: "we".
RULE subject_singular: "I".
RULE subject_plural: "you".
RULE subject_singular: "you".
RULE verb_plural: "walk".
RULE verb_singular: "walk".
\end{grammar}
Notice the bureaucratic heading specifying grammar name and root. The type
{\tt RULE} is optional (see \ref{se:rtype}). 
This one-level (CF) grammar describes the same sentences as the following
two-level grammar:
\begin{grammar}
GRAMMAR agfl.
ROOT sentence.

RULE sentence: subject (NUMBER), verb (NUMBER).
RULE subject (plural): "we".
RULE subject (singular): "I".
RULE subject (NUMBER): "you".
RULE verb (NUMBER): "walk".
\end{grammar}
They both describe the sentences {\sf I walk}, {\sf we walk},
and  {\sf you walk} in which the affix {\tt NUMBER} has the values
{\tt singular}, {\tt plural} and {\tt singular|plural}, respectively.

\subsection{Rule type}\label{se:rtype}
A nonterminal symbol may be \X{productive} to a smaller or larger degree,
in the sense that it {\em always}, {\em sometimes} or {\em never}
generates terminal symbols. Syntax rules may be typed accordingly as
{\tt RULE}, {\tt OPTION} or {\tt CONDITION} (since the ones that never
generate a symbol may enforce some condition on its affix values
by failing or succeeding depending on those values).

\section{Affix Grammars over a Finite Lattice}
Affix Grammars over a Finite Lattice are a particularly simple form of
Affix Grammars: in {\agfl} the second level consists of
restricted context-free \XXs{affix}{rule}. Each affix-rule allows to
rewrite a nonterminal affix into a union of one or more terminal or
nonterminal affixes. The (finite) set of terminal affixes into which a
nonterminal affix can be rewritten forms its \X{domain}.

\subsection{Powerset domains}
In \agfl\ the affix-rules are restricted to have a finite domain,
because recursion is prohibited. This enables reliable
\XXs{consistency}{check} and the generation of \XXs{efficient}{parser}.
With this restriction, Affix Grammars
describe only Context-Free languages. Without such a restriction, i.e.
allowing the affix rules to be CF, all recursively enumerable languages
can be defined [Sintzoff 1967]. Since \agfl\ is intended for the
syntactic description of natural languages, CF power should be largely
adequate [Gazdar]. The power of the formalism was limited on purpose,
to keep grammar writers from abusing larger power to write a parser
rather than a grammar. \footnote{But a good {\sc fortran} programmer
can write {\sc fortran} programs in any language.}
\YY{set-valued}{affix}

A characteristic property of {\agfl} is that affixes are set-valued.
The only operation allowed on affixes is set
\X{intersection} (either implicit or indicated by \Xs{guard}).
This means that the value of a nonterminal affix is determined by the
intersection of the domains of the different instances.
In the example above, the intersection for the value of the affix
\texttt{NUMBER} is taken.  There are two instances of the affix,
namely one for \texttt{subject} and one for \texttt{verb}. For the sentence
{\sf we walk} the first instance of \texttt{NUMBER} has
the set-value \texttt{plural} and the second instance, for {\sf walk} has
the set-value \texttt{NUMBER} (short for {\tt {singular|plural}}).
The intersection of these two sets is the singleton value {\tt plural},
which will be the result.

Finite set-valued affixes can be used to model classical morphological
and syntactical features, but also for expressing finite semantical
distinctions (such as (in)animateness of nouns and verb subcategorization).

Another characteristic of \agfl\ is that it describes one
parse with the set of all terminal affixes, the maximal intersection,
where some other formalisms would describe a separate parse for each
affix-value from the intersection.  For example, the analysis of
{\sf you walk} with the above grammar would give one parse with the
affixvalue \texttt{NUMBER}, and not one analysis with the value
\texttt{plural} and another one with the value \texttt{singular}.  To
do this, \agfl\ uses the \X{consistent
substitution rule}, which is similar to the principle of
\X{unification}.  In rewriting a rule, all occurrences of
the same affix variable obtain the same value, which is
\emph{the set of all terminal affixes for which rewriting succeeds}.

Since each domain is a finite enumeration of terminal affixes,
a rule with a nonterminal affix assuming $n$ possible values, like
\begin{grammar}
RULE subject (NUMBER): "you".
\end{grammar}
may be replaced by $n$ rules, in each of which the affix has been
replaced by one of its terminal productions:
\begin{grammar}
RULE subject (singular): "you".
RULE subject (plural): "you".
\end{grammar}
By applying this \X{blow-up} in a systematic way to all rules in the
grammar and then removing the bracketed affixes, a context free
grammar is obtained, equivalent to the original {\agfl}. {\agfl}s are
therefore not more expressive than Context-Free grammars, but they
may be much more compact than an equivalent CF and allow for a more
efficient implementation.

\subsection{Affix lattices}\label{lattices}
\label{whatis}
The possible values of an affix variable form a mathematical object
called a \XX{power-set}{lattice}. An example lattice for the affix
defined by
\begin{grammar}
	PERSON :: first | second | third.
\end{grammar}
is shown in figure~\ref{fig_latt_pers}.

\begin{figure}[!htbp]
\centering
\begin{picture}(240,200)(35,-170)
\put( 60,   -5)  {\tt $\top$ = \{first, second, third\} = PERSON}
\put(138,   -11) {\line(-3,-1){90}}
\put(140,   -11) {\line(0,-1){30}}
\put(142,   -11) {\line(3,-1){90}}
\put( 10,   -54) {\tt \{first, second\}}
\put(110,   -54) {\tt \{first, third\}}
\put(210,   -54) {\tt \{second, third\}}
\put( 40,   -60) {\line(0,-1){30}}
\put( 42,   -60) {\line(3,-1){88}}
\put(139,   -61) {\line(-3,-1){88}}
\put(141,   -61) {\line(3,-1){88}}
\put(238,   -61) {\line(-3,-1){88}}
\put(240,   -61) {\line(0,-1){30}}
\put( 25,  -102) {\tt \{first\}}
\put(118.5,-102) {\tt \{second\}}
\put(225,  -102) {\tt \{third\}}
\put( 45,  -107) {\line(3,-1){88}}
\put(140,  -107) {\line(0,-1){30}}
\put(235,  -107) {\line(-3,-1){88}}
\put(136,  -149) {$\bot$}
\end{picture}
\caption{Lattice of values for the affix {\tt PERSON}\label{fig_latt_pers}}
\end{figure}

The \XX{top}{element} of the lattice can be seen as the union of all
possibilities (the value may be \texttt{first} or \texttt{second} or
\texttt{third} or any combination). As more information is obtained,
the number of possibilities is narrowed down to a particular value,
or even further to the \XX{bottom}{element} which indicates
\X{inconsistency}. In that case, no parsing is found.

By means of an additional affix rule
\begin{grammar}
	NONFIRST :: second  | third.
\end{grammar}
a name can be given to the values denoting an
intermediate degree of specification like \verb+{second,third}+
(figure~\ref{fig_latt_pers_interm}).\footnote{However,
	these intermediate levels do not \emph{require} a
	name, they always exist as potential intersections.}
It is important to bear in mind that affixes do not necessarily need
to obtain single terminal values. A nonterminal affix represents a
\emph{set} of values from its domain, yielding an elegant and
efficient representation in case of \XX{affix}{ambiguity}.

\begin{figure}[!htbp]
\centering
\begin{picture}(240,200)(35,-170)
\put( 60,   -5)  {\tt $\top$ = \{first, second, third\} = PERSON}
\put(138,   -11) {\line(-3,-1){90}}
\put(140,   -11) {\line(0,-1){30}}
\put(142,   -11) {\line(3,-1){90}}
\put( 10,   -54) {\tt NONTHIRD}
\put(110,   -54) {\tt NONSECOND}
\put(210,   -54) {\tt NONFIRST}
\put( 40,   -60) {\line(0,-1){30}}
\put( 42,   -60) {\line(3,-1){88}}
\put(139,   -61) {\line(-3,-1){88}}
\put(141,   -61) {\line(3,-1){88}}
\put(238,   -61) {\line(-3,-1){88}}
\put(240,   -61) {\line(0,-1){30}}
\put( 25,  -102) {\tt \{first\}}
\put(118.5,-102) {\tt \{second\}}
\put(225,  -102) {\tt \{third\}}
\put( 45,  -107) {\line(3,-1){88}}
\put(140,  -107) {\line(0,-1){30}}
\put(235,  -107) {\line(-3,-1){88}}
\put(136,  -149) {$\bot$}
\end{picture}
\caption{Lattice of values for the affix {\tt PERSON}, with
names for intermediate levels \label{fig_latt_pers_interm}}
\end{figure}

Affixes can be used to capture classical linguistic notions like case,
time, modality, but they can also be used for other \XX{finite}{semantic}
distinctions, like the animate/inanimate feature for nouns and the
absolute/comparative/superlative feature for adjectives, or for
morphological distinctions.


\subsection{Flat lattices}
Besides the power-set domains, two \XXs{flat}{domain} may be used in
\agfl.  A flat domain is an affix domain of single values, covering
only the individual affix terminals and their complete union as possible
values, but no other subsets.
In \agfl\ there are two predefined types of affixes that
produce lattices without intermediate levels.  These two predefined
flat domains are the \XXes{text}{affix}, which can have any textual value
(denoted between quotes), and the \XXes{integer}{affix}, which can have any
integer value (denoted by numbers)
(see figure~\ref{fig_latt_int}).


\begin{figure}[!htbp]
\centering
\begin{picture}(120,105)(-15,-15)
\put(30,  0  ){\line(-1, 1){30}}
\put(30,  0  ){\line( 0, 1){30}}
\put(30,  0  ){\line( 1, 1){30}}
\put(30,  0  ){\line( 2, 1){60}}
\put(30, 75  ){\line(-1,-1){30}}
\put(30, 75  ){\line( 0,-1){30}}
\put(30, 75  ){\line( 1,-1){30}}
\put(30, 75  ){\line( 2,-1){60}}
\put(0 , 37.5){\makebox(0,0){\tt 1}}
\put(30, 37.5){\makebox(0,0){\tt 2}}
\put(60, 37.5){\makebox(0,0){\tt 3}}
\put(90, 37.5){\makebox(0,0){\dots}}
\put(30, -7.5){\makebox(0,0){$\bot$}}
\put(30, 82.5){\makebox(0,0){\tt $\top$ = INT}}
\end{picture}
\caption{Flat lattice of integers\label{fig_latt_int}}
\end{figure}

\noindent
Flat domains are to be used when the affix alternatives are mutually
exclusive, and powerset domains when combinations can occur. Flat domains
are particularly useful for enforcing (long distance) agreements, like
that between a (phrasal) verb and a particle in the following example:

\begin{grammar}
GRAMMAR flataff.
ROOT s.

X::TEXT.

s: verb form(X), particle(X);
   particle(X), verb form(X).

verb form("goes away"): "goes".
verb form("comes back"): "comes".

particle("goes away"): "away".
particle("comes back"): "back".
\end{grammar}
This grammar recognises the phrases\\
\hspace*{.5cm}{\sf goes away}\\
\hspace*{.5cm}{\sf away goes}\\
\hspace*{.5cm}{\sf comes back}\\
\hspace*{.5cm}{\sf back comes}\\
but no others.

The example can be used as a model for the description of phrasal verbs
and even idiomatic phrases. Instead of the the text-domain, the integer
domain might have been used. 


\section{\agfl\-parsers}
The parsers generated by the {\agfl}-system are top-down recursive
backup parsers \cite{KOS74},\linebreak \cite{MEI86} implementing nondeterministic
\XX{top-down}{parsing} \cite{NED93} using continuations and positive memoization.
This parsing method is
capable of dealing with (slightly restricted\footnote{Rules
	that are cyclic on the first level are not allowed.  A grammar
	is cyclic if a nonterminal can be rewritten to itself.  e.g.\
	`\texttt{B:[A],B,[C].}' allows for the rewriting
	`\texttt{B:B.}' and therefore it is
	cyclic.})
\XXs{left-recursive}{grammar}.

It can produce, on demand, one or all parsings for ambiguous input.
The user of the {\agfl}-system needs to have little knowledge
about the mechanism of parsing, and does not need to be aware of
transformations and optimalizations applied to the grammar; the only
thing that counts is the language described by the grammar.
Especially when using Best-Only parsing, the generated parsers
can be very fast.

Parsing takes place in three steps (phases):
\begin{itemize}
\item the \XX{prescan}{phase} performs table initialization and 
robust lexicalization
\item the \XX{parse}{phase}, which includes the attribute computations
\item the \XX{print}{phase} for transducing and printing the best
analysis (or -es).
\end{itemize}
When using Best-Only parsing, parsing is so fast that the prescan phase
may take most of the time. When there are many analyses, the construction
and printing of the parse forest may take much more time than the parsing
itself.

In {\agfl} parsing, affix values are computed \emph{on the fly}.  This
means that the value of an affix may be narrowed down during parsing.
In this way, an efficient and fast parser is obtained, which computes the
affix values economically.  Furthermore this has the advantage that
affix values may remain unspecified or partially unspecified,
i.e.\ the parse contains the set of all possible terminal affixes.

The on-the-fly computation of affix values during left-to-right parsing
can be illustrated by the following example for a fragment of Dutch:
\begin{grammar}
GRAMMAR littledutch.
ROOT sentence.

RULE sentence: subject (NUMBER), verb (NUMBER).
RULE subject (NUMBER): "zij".             # {\em she/they}
RULE verb (singular): "loopt".            # {\em walks}
RULE verb (plural): "lopen".              # {\em walk}
\end{grammar}
In the Dutch sentence {\sf zij loopt}, the value of the affix of the
\texttt{verb} {\sf loopt} determines the value of the affix of the the
\texttt{subject} {\sf zij}.  It is not clear until the last word that the
\texttt{subject} of the sub-clause is \texttt{singular}. Until that moment,
the value of \texttt{NUMBER} of the \texttt{subject} {\sf zij} remains the
full set \verb+{singular,plural}+.  The rule in the grammar which
controls the agreement between the \texttt{subject} and the \texttt{verb},
will accomplish that the number of {\sf zij} will be
\texttt{singular}.  This is done by taking the intersection of both
set-values, a variant of \XX{consistent}{substitution}.

\section{The lexicon}
The \agfl\ system comes with a lexicon system capable of storing terminal
symbols together with their \X{part-of-speech} (\X{POS}), containing entries
looking like inverted grammar rules, e.g.
\begin{grammar}
"provide"   VERBI(with,intr)
"provided"  VERBP(with,intr)
"provided"  VERBV(with,intr)
"provides"  VERBS(with,intr)
"providing" VERBG(with,intr)
"sell"  VERBI(to,ditr)
"sells" VERBS(to,ditr)
"sold"  VERBV(to,ditr)
\end{grammar}
The syntactic categories defining the part-of-speech (such as 
{\tt VERBI(PREP,TRAN)}) are called \Xs{pre-ter\-minal} or
\XX{lexicon}{nonterminals}. Terminal symbols may also be introduced by
pre-terminal rules in the grammar, but since these are lexicalized
one-by-one during the prescan, it is more efficient to put them into
the lexicon.

The lexicon is stored very compactly and access to it is very fast, making
it an excellent tool for dealing with large vocabularies - in many cases
preferable to the use of a separate tagger or morphological analyser.

\section{Hybrid parsing}
So far, \agfl\ was presented as a pure \XX{rule}{base} system, describing
a (usually infinite) set of sentences. In practical usage, such a system
suffers from an amazingly high degree of \X{ambiguity}. Except for some
linguistic applications, we are usually interested in finding the {\em
most likely} analysis of a sentence rather than the collection of all its
possible analyses. We will now describe two mechanisms in \agfl\
that give a ranking to the various analyses that should help in taking the
most likely analysis: penalties and probabilities. The same mechanisms
play an important rule in making \agfl\ parsers robust against incorrect
or unforeseen input.

\subsection{Penalties}
A production in the grammar may be marked with a \X{penalty} (a whole
number), indicating
that every parsing which involves this production should obtain
this penalty. The \XX{penalty}{level} of an analysis is the sum of its
accumulated penalties. As an example, a nounphrase without determiner
could be penalized, in order to avoid trivial NP's:
\begin{grammar}
RULE noun phrase:
  determiner, noun part;
  $PENALTY(3), noun part.
\end{grammar}
Although the idea of penalties is intuitively appealing, it is hard to
give them a formal basis.
The main function of penalties is to act as
\XXs{tie}{breaker} in the case of multiple analyses, but in case of a
trade-off between various penalized constructions, it is hard to predict
what will be the result.

We take the approach that the penalties are related to {\em the negative
logarithm of the probabilities} of the analyses. In order to make penalties
commensurate with probabilities, we interpret a penalty of one as a factor
$\frac{1}{2}$ in probability. Thus, the previous rule may be motivated by
the fact that we consider a noun phrase {\em with} a determiner 8 times
as likely (or ``acceptable") than one without.

\subsection{Syntactic probabilities}
\label{se:synprob}
The second mechanism NOT IMPLEMENTED IN THIS VERSION
for expressing likelyhood concerns the rewriting
probabilities of alternatives: Each alternative (production) of a rule can
be marked with a \X{frequency}. The default frequency is one.
The \XX{syntactic}{probability} of the $i$-th alternative of a rule is its
frequency divided by the sum of frequencies of all alternatives of the
rule.

The frequencies may be given arbitrarily, like
the penalties, but they could also be derived from a \X{treebank}, i.e.
a syntactically analyzed corpus where each sentence has been disambiguated
in context. Such treebanks are, at the moment, rather scarce and
syntactically not very detailed.
In theory, the frequency of an alternative should expresses the number of
times that this alternative has been applied in generating some corpus.
An example: The following rule expresses the intuitive idea that any
number of adjectives may precede a noun, but that a low number of
adjectives is much more likely than a higher number:
\begin{grammar}
RULE noun part:
   [25] adjective, noun part;
   [75] noun.
\end{grammar}
In this example the frequencies nicely sum to 100, but this is of course
not necessary. By this rule, the probability of having $n$ adjectives
preceding a noun decreases geometrically with $n$:
\vspace{0.5cm}

\begin{tabular}{ll}
n = 0 & $.75$ \\
n = 1 & $0.25*0.75$ \\
n = 2 & $0.25*0.25*0.75$ \\
\ldots 
\end{tabular}\vspace{0.5cm}

\noindent
The frequencies play an obvious role in \X{generating} text with given
statistical properties, but they can also be used like the penalties to
rank the analyses in order of decreasing probability. The syntactic
probabilty of each alternative applied is transformed to a penalty
(taking the logarithm and rounding to the nearest integer).

\subsection{Lexical probabilities}
One of the main sources of the perplexingly high ambiguity of natural
language is the \XX{lexical}{ambiguity}: the fact that one word may have
more than one \XX{lexical}{category} or Part-Of-Speech (\X{POS}).
As an example, the famous shibboleth {\sf time flies like an arrow} makes
a play on threefold lexical ambiguity.
\footnote{also on the \X{attachment} of the PP {\sf like an arrow} to the
main verb or to the object. Unlike the first three, this is a matter of
syntactic rather than lexical probability.}
\begin{itemize}
\item {\sf time} as noun or verb
\item {\sf flies} as noun or verb
\item {\sf like} as preposition or verb.
\end{itemize}
Luckily, not all these interpretations are equally likely: {\sf time}
occurs much more often as a noun than as a verb.

In \agfl\ every entry in the lexicon (word plus POS) can be given a
\XX{lexical}{frequency} (default is one), and a particular entry obtains
a \XX{lexical}{probability} which is the frequency of this entry divided by
the sum of the
frequencies of all entries for this word. In a non-ambiguous sentence,
the lexical probabilities do not make any difference, but for a lexically
ambiguous sentence they act as very effective tie breakers by preferring
the most likely POS for every word.

\subsection{Robustness mechanisms}
\agfl\ comes with a number of mechanisms to achieve \XX{robust}{parsing}.
The general approach is to accept, besides the language to be recognized,
also all possible forms of incorrect input and rank the analyses
appropriately by means of the previous mechanisms. For this purpose, the
following additional mechanisms can be used:
\begin{itemize}
\item the \XX{commit}{operator} {\tt !}, which prevents the execution
of further alternatives from a rule if a preceding alternative has been
succesfull. This operator may {\em only be used within a} {\tt
CONDITION}.
\item \XX{wildcard}{matching}, matching unknown words of the input against
\XXs{regular}{expression}, like
\begin{grammar}
RULE robust verbform:
   $PENALTY, $MATCH(".*ing");
   $PENALTY, $MATCH(".*ed").
\end{grammar}
\end{itemize}

Making a grammar robust is an art, but \agfl\ provides the right
mechanisms.

\section{Parse trees and transduction}
An agfl parser may produce as output either
\begin{itemize}
\item a parse tree in a simple indented format, suitable for diagnostics
\item a parse tree in labelled bracket form, suitable for many applications,
or even
\item a form of output which is completely controlled by the grammar.
\end{itemize}
This \XX{transduction}{mechanism}
is explained in \ref{ch:inout}, giving many practical examples.

\section{Generating examples}
As of Version 2.4, the \agfl\ system comes with a tool to generate
examples of the language described by the grammar. The \X{generator}
is a {\sc prolog} program, which reads an \agfl\ grammar and produces
another {\sc prolog} program that generates a random example of a
terminal production of the root of the grammar. Since the random
number generator is seeded by the clock, this program can be run
repeatedly to obtain different examples. Many users find this an
appealing way to test their grammar.

The generation process is guided by the syntactic probabilities
(see \ref{se:synprob}).
In the absence of syntactic probabilities, the generator assigns to
every alternative the frequency one, so that all alternatives of a
rule have the same probability. In order to give more probability to
alternatives that may serve to stop recursion (repetition), each
alternative that may produce empty is duplicated.

%\section{Invitation}
%Interested? You are herewith invited to download the \agfl\ system,
%install it on your computer and use it for your purposes.
