[net.lang.prolog] PROLOG Digest V4 #7

PROLOG-REQUEST@SU-SCORE.ARPA (Chuck Restivo, The Moderator) (02/03/86)

PROLOG Digest            Tuesday, 4 Feb 1986        Volume 4 : Issue 7

Today's Topics:
                       Puzzle - NL & Shoppers,
                  Implementation - Syntactic Sugar,
            LP Philosophy - Lack of expressive capability
----------------------------------------------------------------------

Date: 30 Jan 1986 05:58-EST
From: Gregory.Stein@K.CS.CMU.EDU
Subject: Puzzle

I have found a solution to the puzzle posted by Paul Weiss in
Volume 4, #3 of the digest.  It took quite a bit of grinding
and CAREFUL analysis.  I did most of it using a grid method
which I think is probably pretty common for these types of
puzzles.  Anyhow, here is the solution:

        Couples (in order)                      What they bought
 1. Adam & Geraldine Jones      -   Gloves, Book, COCO, Pearls
 2. Bob & Martha Day            -   Gloves, COCO, Pearls, Handbag
 3. Jack & Susan O'Connor       -   Gloves, COCO, Pearls, Sweater
 4. Tom & Sandra Smith          -   Gloves, Book, COCO, Handbag
 5. Gary & Cathleen Collins     -   Gloves, COCO, Sweater, Handbag
 6. John & Margaret Marshall    -   Gloves, Book, Sweater, Handbag
 7. George & Cheryl Swain       -   Gloves, Pearls, Sweater, Handbag
 8. Bill & Evelyn Stanton       -   Gloves, Book, Pearls, Sweater
 9. Chuck & Rosalyn Douglas     -   Book, COCO, Pearls, Handbag
10. Steve & Eleanor Craig       -   Book, Pearls, Sweater, Handbag
11. Allen & Dorothy Murphy      -   Book, COCO, Pearls, Sweater
12. Joe & Elizabeth Anthony     -   Book, COCO, Sweater, Handbag

There it is!  Check it if you like, but it's right as far as I know.
Anyone who likes a puzzle - this is it - it's a real toughy. Takes
hours.

-- Greg Stein

------------------------------

Date: Wed 29 Jan 86 13:44:08-PST
From: Fernando Pereira <PEREIRA@SRI-CANDIDE.ARPA>
Subject: Syntactic Sugar

There is a more general solution to the syntactic sweetening
problem raised by Zerksis D. Umrigar. This is the introduction
of ``distfix'' operators in the Prolog-10 syntax. A Prolog
reader supporting distfix operators was written a while ago by
Richard O'Keefe, and is available as DISTFI.PL at [SU-SCORE]
<PROLOG>. The following is extracted from the comments in that
file:

Distfix operators have finally been added.  They are declared
by distfixop(Priority, Type, Pattern, Term)

where Priority is as usual, Type is currently only fx or fy (if
the Pattern doesn't specify a right argument one of the types
must still be specified but it doesn't matter which), Term is
what the reader is to return when it sees something matching
the pattern, and the Pattern is a list of atoms and variables
whose first elements is an atom, and in which no two variables
appear side by side without an intervening atom.  To avoid
ambiguities, the first atom following each variable should NOT
be an infix or postfix operator, but the code below does not
check for that, as you could declare such an operator after
declaring the distfix form.

Examples:

distfixop(950, fy, [for,each,X,show,that,Y], forall(X,Y))
distfixop(1105, fx, [try,Goal,reverting,to,Alternative,on,
                                                failure],
                        (Goal;Alternative))
distfixop(999, fy, [there,is,a,clause,with,head,H,and,body,B],
                        clause(H,B))
distfixop(999, fy, [there,is,a,clause,with,head,H], clause(H,_))

Infix forms are also available.  These have the side effect of
declaring the head keyword as an infix operator; anything that
did not do this would be significantly harder to patch into the
old parser.

Examples:

distfixop(700, xfy, [S,is,the,set,of,X,such,that,P], setof(X,P,S))
distfixop(700, xfy, [B,is,the,bag,of,X,such,that,P], bagof(X,P,S)),
distfixop(700, xfy, [X,is,to,Y,as,A,is,to,B], X*B =:= A*Y),
distfixop(700, xfx, [X,had,N,variables], numbervars(X,0,N))


-- Fernando Pereira

------------------------------

Date: Thu, 30 Jan 86 21:37 EST
From: Hewitt@MIT-MC.ARPA
Subject: Lack of expressive capability in Prolog

In his contribution to PROLOG Digest [Volume 4 : Issue 5],
Fernando Pereira states "The expressive power of machine
languages it the power of being able to instruct a machine
to do any elementary step (machine instruction) that the
machine has been designed to do. That kind of expressive
power is thus irrevocably tied to a particular machine
architecture, so let's call it ``machine power''."  I
believe that the expressive power of a machine also
includes the ability to COMMUNICATE with other machines
operating concurrently. Prolog leaves out this ability to
communicate as well as the ability of a machine to CHANGE
ITS LOCAL STATE.  This why I moved beyond MicroPlanner
(late 1960's) to actors (early 1970's). Prolog is a subset
of the capabilities of MicroPlanner that were implemented
by Charniak, Sussman, and Winograd in 1970. (The designers
of Prolog LEFT OUT belief-invoked forward chaining from
Micro-Planner as well as some other things.)

Pereira makes the further point that "Like many other
computer  scientists, advocates of logic programming
understand the  advantages of relinquishing machine power
in favor of ``abstraction power'': the ability to express
abstract relationships and processes without having to
delve into the peculiarities of the implementation of that
expression on a particular machine."  However the abstraction
power of Prolog is fundamentally LESS than that of Common Lisp,
a machine independent language which does a better job than
Prolog of hiding the peculiarities of the implementations of
expressions.  The multiple value return mechanism of Common
Lisp provides the same capabilites of returning values from
subroutines as the values of variables in Prolog goal relations.
Information hiding in Prolog is DEFECTIVE in that it does not
provide the ability to construct new locally acessible objects
the same way that Lisp does.  Instead the newly constructed
relations of Prolog must be placed in the global data base thus
BETRAYING the needs of hiding the peculiarities of implementation.
Prolog does offer backtracking capabilities not found in Lisp.
However, through the experience of using MicroPlanner, the users
discovered that BACKTRACKING IS NOT A GOOD ABSTRACTION MECHANISM.
Concurrency is needed instead.

Pereira claims that "The discipline needed to keep abstractions
alive in a language with substantial machine power (such as Lisp)
seems beyond the grasp of most programmers, to judge by their
products."  However my experience is that PROGRAMMERS CONSTRUCT
AND MAINTAIN BETTER ABSTRACTIONS IN LISP THAN IN PROLOG.
Programmers for standalone Prolog systems are constantly fighting
the limited expressive power of their language.  They are forced
to use INELEGANT HACKS like "print" pseudo-predicates and clumsy
primitives like "assert" and "assertz" to cause needed effects
that cannot be directly expressed in Prolog.

I believe that these limitations of Prolog are FUNDAMENTAL in the
sense that there is no way to remedy them and still remain within
the realm of using Logic as a Programming language.

------------------------------

End of PROLOG Digest
********************

PROLOG-REQUEST@SU-SCORE.ARPA (Chuck Restivo, The Moderator) (02/04/86)

PROLOG Digest            Tuesday, 4 Feb 1986        Volume 4 : Issue 7

Today's Topics:
                       Puzzle - NL & Shoppers,
                  Implementation - Syntactic Sugar,
         LP Philosophy -  of expressive capability in Prolog
----------------------------------------------------------------------

Date: 30 Jan 1986 05:58-EST
From: Gregory.Stein@K.CS.CMU.EDU
Subject: Puzzle

I have found a solution to the puzzle posted by Paul Weiss in
Volume 4, #3 of the digest.  It took quite a bit of grinding
and CAREFUL analysis.  I did most of it using a grid method
which I think is probably pretty common for these types of
puzzles.  Anyhow, here is the solution:

        Couples (in order)                      What they bought
 1. Adam & Geraldine Jones      -   Gloves, Book, COCO, Pearls
 2. Bob & Martha Day            -   Gloves, COCO, Pearls, Handbag
 3. Jack & Susan O'Connor       -   Gloves, COCO, Pearls, Sweater
 4. Tom & Sandra Smith          -   Gloves, Book, COCO, Handbag
 5. Gary & Cathleen Collins     -   Gloves, COCO, Sweater, Handbag
 6. John & Margaret Marshall    -   Gloves, Book, Sweater, Handbag
 7. George & Cheryl Swain       -   Gloves, Pearls, Sweater, Handbag
 8. Bill & Evelyn Stanton       -   Gloves, Book, Pearls, Sweater
 9. Chuck & Rosalyn Douglas     -   Book, COCO, Pearls, Handbag
10. Steve & Eleanor Craig       -   Book, Pearls, Sweater, Handbag
11. Allen & Dorothy Murphy      -   Book, COCO, Pearls, Sweater
12. Joe & Elizabeth Anthony     -   Book, COCO, Sweater, Handbag

There it is!  Check it if you like, but it's right as far as I know.
Anyone who likes a puzzle - this is it - it's a real toughy. Takes
hours.

-- Greg Stein

------------------------------

Date: Wed 29 Jan 86 13:44:08-PST
From: Fernando Pereira <PEREIRA@SRI-CANDIDE.ARPA>
Subject: Syntactic Sugar

There is a more general solution to the syntactic sweetening
problem raised by Zerksis D. Umrigar. This is the introduction
of ``distfix'' operators in the Prolog-10 syntax. A Prolog
reader supporting distfix operators was written a while ago by
Richard O'Keefe, and is available as DISTFI.PL at [SU-SCORE]
<PROLOG>. The following is extracted from the comments in that
file:

Distfix operators have finally been added.  They are declared
by distfixop(Priority, Type, Pattern, Term)

where Priority is as usual, Type is currently only fx or fy (if
the Pattern doesn't specify a right argument one of the types
must still be specified but it doesn't matter which), Term is
what the reader is to return when it sees something matching
the pattern, and the Pattern is a list of atoms and variables
whose first elements is an atom, and in which no two variables
appear side by side without an intervening atom.  To avoid
ambiguities, the first atom following each variable should NOT
be an infix or postfix operator, but the code below does not
check for that, as you could declare such an operator after
declaring the distfix form.

Examples:

distfixop(950, fy, [for,each,X,show,that,Y], forall(X,Y))
distfixop(1105, fx, [try,Goal,reverting,to,Alternative,on,
                                                failure],
                        (Goal;Alternative))
distfixop(999, fy, [there,is,a,clause,with,head,H,and,body,B],
                        clause(H,B))
distfixop(999, fy, [there,is,a,clause,with,head,H], clause(H,_))

Infix forms are also available.  These have the side effect of
declaring the head keyword as an infix operator; anything that
did not do this would be significantly harder to patch into the
old parser.

Examples:

distfixop(700, xfy, [S,is,the,set,of,X,such,that,P], setof(X,P,S))
distfixop(700, xfy, [B,is,the,bag,of,X,such,that,P], bagof(X,P,S)),
distfixop(700, xfy, [X,is,to,Y,as,A,is,to,B], X*B =:= A*Y),
distfixop(700, xfx, [X,had,N,variables], numbervars(X,0,N))


-- Fernando Pereira

------------------------------

Date: Thu, 30 Jan 86 21:37 EST
From: Hewitt@MIT-MC.ARPA
Subject: Lack of expressive capability in Prolog

In his contribution to PROLOG Digest [Volume 4 : Issue 5],
Fernando Pereira states "The expressive power of machine
languages it the power of being able to instruct a machine
to do any elementary step (machine instruction) that the
machine has been designed to do. That kind of expressive
power is thus irrevocably tied to a particular machine
architecture, so let's call it ``machine power''."  I
believe that the expressive power of a machine also
includes the ability to COMMUNICATE with other machines
operating concurrently. Prolog leaves out this ability to
communicate as well as the ability of a machine to CHANGE
ITS LOCAL STATE.  This why I moved beyond MicroPlanner
(late 1960's) to actors (early 1970's). Prolog is a subset
of the capabilities of MicroPlanner that were implemented
by Charniak, Sussman, and Winograd in 1970. (The designers
of Prolog LEFT OUT belief-invoked forward chaining from
Micro-Planner as well as some other things.)

Pereira makes the further point that "Like many other
computer  scientists, advocates of logic programming
understand the  advantages of relinquishing machine power
in favor of ``abstraction power'': the ability to express
abstract relationships and processes without having to
delve into the peculiarities of the implementation of that
expression on a particular machine."  However the abstraction
power of Prolog is fundamentally LESS than that of Common Lisp,
a machine independent language which does a better job than
Prolog of hiding the peculiarities of the implementations of
expressions.  The multiple value return mechanism of Common
Lisp provides the same capabilites of returning values from
subroutines as the values of variables in Prolog goal relations.
Information hiding in Prolog is DEFECTIVE in that it does not
provide the ability to construct new locally acessible objects
the same way that Lisp does.  Instead the newly constructed
relations of Prolog must be placed in the global data base thus
BETRAYING the needs of hiding the peculiarities of implementation.
Prolog does offer backtracking capabilities not found in Lisp.
However, through the experience of using MicroPlanner, the users
discovered that BACKTRACKING IS NOT A GOOD ABSTRACTION MECHANISM.
Concurrency is needed instead.

Pereira claims that "The discipline needed to keep abstractions
alive in a language with substantial machine power (such as Lisp)
seems beyond the grasp of most programmers, to judge by their
products."  However my experience is that PROGRAMMERS CONSTRUCT
AND MAINTAIN BETTER ABSTRACTIONS IN LISP THAN IN PROLOG.
Programmers for standalone Prolog systems are constantly fighting
the limited expressive power of their language.  They are forced
to use INELEGANT HACKS like "print" pseudo-predicates and clumsy
primitives like "assert" and "assertz" to cause needed effects
that cannot be directly expressed in Prolog.

I believe that these limitations of Prolog are FUNDAMENTAL in the
sense that there is no way to remedy them and still remain within
the realm of using Logic as a Programming language.

------------------------------

End of PROLOG Digest
********************