next up previous contents
Next: Parsing and generation Up: Procedural Semantics Previous: Solving a query

Meta-interpreter

Note that I did restrict a grammar to consist only of a set of definite clauses defining the predicate sign/1. However, I will also use definite clauses of $ \cal {R}$($ \cal {L}$) to define meta-interpreters for such grammars. For these meta-interpreters I will assume the operational semantics sketched above. In such cases I treat the definite clauses defining sign as data; a clause:

\begin{displaymath}
\mbox{\it sign}(\mbox{\rm X}_{0}) \mbox{\tt :-} \mbox{\it si...
...box{\rm X}_{1}) \dots
\mbox{\it sign}(\mbox{\rm X}_{n}), \phi.
\end{displaymath}
is represented as the clause

\begin{displaymath}
\mbox{\it rule}(\mbox{\rm X}_{0},\langle \mbox{\rm X}_{1}, \dots \mbox{\rm X}_{n}\rangle) \mbox{\tt :-} \phi.
\end{displaymath}
i.e. the body of the clause is represented as a list. A meta-interpreter for $ \cal {R}$($ \cal {L}$) thus may be defined as in program 6, which follows the procedural semantics of $ \cal {R}$($ \cal {L}$), i.e. it is a top-down proof procedure with a left-most computation rule and a depth-first search rule.

\pr
\pred
\head{\mbox{\it refutation}(\mbox{\rm Goal}) \mbox{\tt :-}}
\body{ \mb...
...ation}(\mbox{\rm H}),}
\body{ \mbox{\it refutations}(\mbox{\rm T}).}
\epred\epr
For example, a rightmost computation rule can be implemented by defining the predicate refutations as follows:

\pr\pred
\head{\mbox{\it refutations}(\langle\rangle).}
\head{\mbox{\it refutati...
...ations}(\mbox{\rm T}),}
\body{ \mbox{\it refutation}(\mbox{\rm H}).}
\epred\epr



Noord G.J.M. van
1998-09-30