Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!gatech!howland.reston.ans.net!math.ohio-state.edu!scipio.cyberstore.ca!vanbc.wimsey.com!unixg.ubc.ca!news.bc.net!newsserver.sfu.ca!fornax!tarau
From: tarau@cs.sfu.ca (Paul Tarau)
Subject: Re: Purifying Prolog, Monads for Logic Programming?
Message-ID: <1995Jun1.221200.21075@cs.sfu.ca>
Organization: Universite de Moncton
References: <3qc3kr$ghj@borg.cs.waikato.ac.nz>
Date: Thu, 1 Jun 1995 22:12:00 GMT
Lines: 71

In article <3qc3kr$ghj@borg.cs.waikato.ac.nz>,
Don Smith <dsmith@borg.cs.waikato.ac.nz> wrote:

>While I have your eye, I ask: has anyone tried to apply the ideas of
>monads and single-threading from functional programming to logic
>programming?  Here's a catchy title: "Imperative Relational
>Programming".  I suspect that people will find it really hard to
>program in a language that didn't provide _some_ form of assignment.
>So LP should borrow ideas like monads from FP. ???

Actually, some effort has been recently put both on monadic
constructs in LP and on a cleaner handling of state information
in LP. I will spare bandwidth an give only a pointer to
a monad related paper:

ftp://clement.info.umoncton.ca:/pub/OtherPapers/LPwithMonads.ps.gz


A more recent paper, with emphasis on a clean and efficient handling
of state information can be found at:

ftp://clement.info.umoncton.ca:/pub/BinPrologPapers

in file

TR.95.2-HiddenAccumultorsAndLinImpl.tar.gz

Here is the abstract:

PAPER: Backtrackable State with Linear Assumptions, Continuations 
       and Hidden Accumulator Grammars
       
AUTHORS: Paul Tarau, Veronica Dahl, Andrew Fall
	      
ABSTRACT:
	      
A set of executable specifications and efficient implementations of
backtrackable state persisting over the current AND-continuation is
investigated.
	      
At specification level, our primitive operations are linear and
intuitionistic implications, having as consequent the current
continuation.  On top of them, we introduce a form of hypothetical
assumptions which use no explicit quantifiers and have an easy and
efficient implementation on top of logic programming systems featuring
backtrackable destructive assignment, global variables.
	      
A variant of Extended DCGs handling multiple streams without the need
of a preprocessing technique, Hidden Accumulator Grammars (HAGs), are
specified in terms of linear assumptions.  For HAGs, efficiency
comparable to that of preprocessing techniques is obtained through a
WAM-level implementation of backtrackable destructive assignment,
supporting non-deterministic execution based on value-trailing,
while collapsing to a form of in-place update in case of deterministic
execution.
	      
When more precise information about the location where linear
assumptions are be used is available, either HAGs or a continuation
based representation multi-headed clauses) is used to avoid a
performance penalty due to dynamic implementation.
	      
Not restricted to Prolog, the techniques described in the paper are
portable to alternative logic programming languages like Life, Lolli
and LambdaProlog.
	      
Keywords:
state in logic and functional programming, linear and intuitionistic
implication, accumulator processing, alternative DCG implementations,
destructive assignment, logical global variables, continuations.

Paul Tarau
