Subject: predicate logic & using accumulater

From: "Uwe Mayer" <[email-masked]>
Date: Sun, 9 Jan 2000 23:42:43 +0100

hi there,

i am learning from a book, called "Clause and Effect" by William F.Clocksin.
in worksheet 6 he introduces the use of an accumulator in a procedure,
calculating the length of a list:

1.
length([],0).
length([H|T],N) :- length(T,Nt), N is Nt +1.

2.
length(L,N) :- accumulate(L,0,N).

accumulate([],A,A).
accumulate([H|T],A,N) :- A1 is A +1, accumulate(T,A1,N).

furthermore he states that the second version should be prefered. WHY? for
debugging purposes?

my second question is more theoretical.
in analysis phrases like "for all" and "there exists" (dt. Quantoren) are
used.

my second book states that we are only using first order predicate logic in
prolog. (fine)
and that in first order predicate logic we use these <Quantoren> on
individuals and varriables (fine)
BUT that in second (and higher) predicate logic these <Quantoren> work on
predicate varriables. (not fine)

i have problems immagening such a construction.
first case is clear, f.e.:

define a partial map censor such that the goal censor(X,Y) maps the input
list X of words onto the output list Y of words in which no prohibited words
from prohibit(Z) appears.

prohibit(bother).
prohibit(blast).
prohibit(drat).
prohibit(fiddlestick).

censor([],[]).
censor([X|T],[X|L]) :- not prohibit(X), censor(T,L).
censor([X|T],L) :- prohibit(X), censor(T,L).

the second clause of censor can be described as "censor matches the head of
the input list to the head of the output list, if FOR ALL VALUES of the head
of the input list: prohibit(head of input list) fails and recurse on the
tail of the input list".

this would be quantifying (using <Quantoren>) on varriables.
Can anyone give me an example of quantifying on predicate varriables? Why
are such constructions not possible in prolog? why are they useless?

Th@nx in advance

Uwe Mayer

--
"Nothing can be loved or hated
 unless it is first understood"
              Leonardo da Vinci 1452 - 1519