🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.prolog
Article #612

Re: Help - how do I avoid circularity here?

#612
From: Chris Moss
Date: Thu, 15 May 1986 14:56
26 lines
1618 bytes
In article <1211@lsuc.UUCP> dave@lsuc.UUCP (David Sherman) writes:
>I'm designing a large Prolog program for corporate tax planning
>under Canadian income tax law. I want to include the following
>definitions:
>
>tptype(Taxpayer, corporation) :- tptype(Taxpayer, ccpc).
>
>Let's call this a "type 1" definition. ... A type
>2 rule might be:
>
>tptype(Taxpayer, ccpc) :-
>	tptype(Taxpayer, corporation),
>Now comes the problem. When I have both type 1 and type 2
>rules in place, I get circularity. 

Well known problem. Structural solution as follows: split your predicate
into two parts, one of rules, the other facts which do not have any
recursive calls.  Add a reference from first to second. By this time
you will rarely if ever need directly recursive calls. 
e.g.
   tptype(Taxpayer, corporation) :- tptypefact(Taxpayer, ccpc).
   tptype(Taxpayer, ccpc) :-	tptypefact(Taxpayer, corporation).
   tptype(Taxpayer, Type) :- tptypefact(Taxpayer, Type).

Chris Moss, Imperial College London.
cdsm@ic.doc.ac.uk or cdsm@icdoc.uucp
Technical Details
Message-ID: <332@ivax.doc.ic.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!mcvax!ukc!icdoc!cdsm
References: <1211@lsuc.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!mcvax!ukc!icdoc!cdsm
From: cdsm@doc.ic.ac.uk (Chris Moss)
Newsgroups: net.lang.prolog
Subject: Re: Help - how do I avoid circularity here?
Message-ID: <332@ivax.doc.ic.ac.uk>
Date: Thu, 15-May-86 10:56:37 EDT
Article-I.D.: ivax.332
Posted: Thu May 15 10:56:37 1986
Date-Received: Sun, 18-May-86 15:06:01 EDT
References: <1211@lsuc.UUCP>
Reply-To: cdsm@doc.ic.ac.uk (Chris Moss)
Organization: Dept. of Computing, Imperial College, London, UK.
Lines: 26