🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.prolog
Article #616

miscellany re income tax planning system

#616
From: David Sherman
Date: Tue, 20 May 1986 03:57
62 lines
3340 bytes
First, thanks to everyone who responded to my plea for help
in avoiding circularity in my definition of tptype. Most people
suggested using two different predicates, one for stated facts
and one for conclusions. It turns out not to be quite so simple,
but I think that suggestion contains the seeds of the solution
I need. I'm still working on finalizing it.

Second, I've developed an interesting predicate which I call
"aggregate" which I'd like to share with the net. It comes from
the tendency of the Income Tax Act to say things like "the aggregate
of his taxable capital gains for the year". I wanted to be able to
take an arbitrary predicate which puts a number into its last
argument, call it as many times as will succeed, and total up
the numbers. Thus, if I have
	taxablecapitalgain(Taxpayer, Year, TCG)
which itself is defined in terms of more basic things (like
transactions, dispositions, proceeds, cost and so on), then I can say
	aggregate(taxablecapitalgain, fred, 1986, Aggr).
and get fred's 1986 taxable capital gains returned in Aggr.

Here's my code. I have no idea whether it will be useful to anyone,
but I'm curious as to what those more experienced with Prolog think
of it. It's probably either ingenious or stupid, but it does work.
It uses the "findall" predicate from Clocksin & Mellish chapter 7.
	
	aggregate(Goal, Arg1, Arg2, Aggr) :-
		Z =.. [Goal, Arg1, Arg2, Amount],
		findall(Amount, call(Z), List),
		listtotal(List, Aggr).

(3 other copies of "aggregate" exist, one with only Arg1,
one with Arg1, Arg2, Arg3, and one with 4 arguments for the
Goal other than the final Amount.)
	
	listtotal([], 0).
	listtotal([H|T], Total) :-
		integer(H),
		listtotal(T, Ttotal),
		Total is H + Ttotal.


Third, I'm currently wrestling with the task of generating,
for a list, every list which is a subset of that list. Thus,
for [a,b,c,d], I want findall to be able to find each of
[a,b] [a,c] [a,d] [a,b,c] [a,b,d] [a,c,d] [b,c] [b,d] [b,c,d] [c,d]. 
I've played with it for a while and can't get a handle on the
approach to take. Can anyone help? (The application is generating
every possible group of taxpayers from the list of those who
own shares in a corporation, so as to determine whether any of
them is a "related group" as defined in the Act.)

Incidentally, if anyone is interested in knowing more about my
project, I'll be happy to mail or post more. It's a comprehensive
corporate tax planning system based on the Canadian Income Tax Act.

Dave Sherman
The Law Society of Upper Canada
Osgoode Hall
Toronto, Canada  M5H 2N6
+1 416 947 3466
-- 
{ ihnp4!utzoo  pesnta  utcs  hcr  decvax!utcsri  } !lsuc!dave
Technical Details
Message-ID: <1219@lsuc.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utcs!mnetor!lsuc!dave

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site lsuc.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utcs!mnetor!lsuc!dave
From: dave@lsuc.UUCP (David Sherman)
Newsgroups: net.lang.prolog
Subject: miscellany re income tax planning system
Message-ID: <1219@lsuc.UUCP>
Date: Mon, 19-May-86 23:57:34 EDT
Article-I.D.: lsuc.1219
Posted: Mon May 19 23:57:34 1986
Date-Received: Tue, 20-May-86 03:24:26 EDT
Reply-To: dave@lsuc.UUCP (David Sherman)
Organization: Law Society of Upper Canada, Toronto
Lines: 62
Summary: followup on circularity; code for "aggregate"; query re generating subsets of a list