🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #883

Re: mutual recursion query

#883
From: Richard A. O'Keefe
Date: Fri, 08 Jun 1990 05:19
48 lines
2362 bytes
 In article <3164@goanna.cs.rmit.oz.au>, I wrote
> Consider a grammar written in Datalog.  For example,
> 	s --> np(P,N,nom), vp(P,N).
> 	np(P,N,C) --> word(X), {pronoun(X,P,N,C)}.
	...
In article <792@fornax.UUCP>, han@fornax.UUCP (Jiawei Han)
missed the point completely.
> Let me try it.  I write the grammar as follows.
> 	s :- np(P,N,nom), vp(P,N).
> 	np(P,N,C) :- pronoun(X,P,N,C).
	...

I used definite clause grammar notation (and referred to non-terminals
with N arguments as P//N rather than to predicates with N+2 arguments
as P/(N+2)) because I was writing a grammar.  The first two clauses
transliterate to
	s(S0,S) :- np(P, N, nom, S0, S1), vp(P, N, S1, S).

If the method works well with what I actually wrote, it's interesting.
If it works with some random thing with no sequence arguments, it isn't.

Let me repeat the grammar, this time with the sequence arguments
explicit, and one more rule which I accidentally forgot.

	s(S0,S) :- np(P,N,nom,S0,S1), vp(P,N,S1,S).

	np(P,N,C,S0,S) :- word(X,S0,S), pronoun(X,P,N,C).
	np(3,N,_,S0,S) :- word(the,S0,S1), word(X,S1,S2),
			  noun(X,N), opt_rel(S2,S).

	opt_rel(S0,S) :- word(that,S0,S1), vp(_,_,S1,S).
	opt_rel(S0,S) :- word(that,S0,S1), np(P,N,nom,S1,S2), tv(P,N,S2,S).
	opt_rel(S,S).

	vp(P,N,S0,S) :- word(X,S0,S), intrans(X,P,N).
	vp(P,N,S0,S) :- tv(P,N,S0,S1), np(_,_,acc,S1,S).

	tv(P,N,S0,S) :- word(X,S0,S), trans(X,P,N).

The rule which had been omitted lets us say "the rat that the cat chased"
as well as "the cat that chased the rat", and it really made me look
stupid leaving it out because the _point_ of my example was to show
something that was naturally recurring in a "tree-structured" fashion.

-- 
"A 7th class of programs, correct in every way, is believed to exist by a
few computer scientists.  However, no example could be found to include here."
Technical Details
Message-ID: <3191@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ames!uakari.primate.wisc.edu!samsung!munnari.oz.au!bruce!goanna!ok
References: <4176@munnari.oz.au> <10462@spool.cs.wisc.edu> <718@fornax.UUCP> <792@fornax.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ames!uakari.primate.wisc.edu!samsung!munnari.oz.au!bruce!goanna!ok
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: mutual recursion query
Message-ID: <3191@goanna.cs.rmit.oz.au>
Date: 8 Jun 90 05:19:16 GMT
References: <4176@munnari.oz.au> <10462@spool.cs.wisc.edu> <718@fornax.UUCP> <792@fornax.UUCP>
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 48