Net Talk
edited by Roberto Bagnara


Threads:
DCG's and Haskell Monads

From: Alan Baljeu
Subject: DCG's compared to Haskell monads

Monads are a tool to make the state of a computation implicit.
They're useful in pure functional languages where they
effectively accumulate changes which can be serialized to
some output. I'm probably not explaining them quite correctly.
The list datatype is an example of a monad.

DCG's are are tool for serializing computation, and making
implicit the building up of a list. However, the concept
can be generalized to implicitly collecting any kind of data.

I'm just wondering how close this is to the monad concept.
What's the relation between these, and can DCG style be
used to implicitly manage side-effecty code in prolog, like
monads do for Haskell?



From: Fergus Henderson
Subject: Re: Re: DCG's compared to Haskell monads

Alan Baljeu wrote:
>can DCG style be used to implicitly manage side-effecty code in prolog, like
>monads do for Haskell?

Yes. This approach is used in Mercury <http://www.cs.mu.oz.au/mercury/>,
where the state-of-the-world is represented as an implicit DCG parameter.

However, this approach also relies on Mercury's unique mode support
(which is essentially a directional linear type system -- it is similar
to unique types in Clean) to ensure that there is only one reference to
the state-of-the-world at any point in time. It also relies on Mercury's
support for determinism analysis, to ensure that "side-effecty" code won't
fail and can't be backtracked over. Mercury's determinism analysis in
turn also depends on Mercury's type and mode systems. (Other approaches
to determinism are possible, though, some of which do not rely on mode
analysis -- for example see the language TEL, which is described in
Gert Smolka's PhD thesis.)




From: Jamie Andrews
Subject: Re: DCG's compared to Haskell monads

Fergus has mentioned some constructs in Mercury. Also,
Peter van Roy worked on various variations of the DCG concept a
number of years ago, IIRC. They are the same kind of thing in a
loose sense: a way of getting state into a declarative
computation in a declaratively principled way.

However, the monad concept refers to something very
specific: a data object with some specific operations that do
specific things, which (in a principled functional setting) are
accomplished by making the data object a fairly complex
expression involving lots of lambdas. The only way you could do
that in a declaratively principled way in logic programming is
with a higher order LP language, like Lambda Prolog or Twelf.
The DCG idea is essentially sophisticated syntactic sugar for
extra parameters, which is a different kind of thing.

In Googling to see if anyone had actually worked on this
area, I see that our own Paul Tarau (with Yves Bekkers) has
a paper called "Monadic Constructs for Logic Programming",
available on the Web. I haven't looked at the paper closely,
but it does seem to use Lambda Prolog.



Back to top


Logic Programming Rediscovered

From: Bart Demoen
Subject: amazing new facts about (logic) programming and Prolog :-)

http://www.ftponline.com/javapro/2003_07/magazine/columns/proshop/default.asp

Enjoy !



From: John Fry
Subject: "rules-based programming"

Apparently Prolog has been re-discovered. Behold the hot new trend of
"rules-based programming":
http://www.infoworld.com/article/03/05/16/20OPstrategic_1.html



From: Cesar Rabak
Subject: Re: "rules-based programming"

It seems to me that 'au contraire' the article itself shows Prolog as
old fashioned (even referring to dust in the '85 copy of C & M book) and
goes to describe rule engines in other environments and other platforms,
at the last paragraph a mention to Prolog seems to relegate it to toy
problems and atributes to "Web services" the changing to processing of
business processes and objects.

So for the masses, Prolog has not been re-discovered but only mentioned
as a language which is not in its 'heyday'. . .



From: Andrzej Lewandowski
Subject: Re: "rules-based programming"

This is NIN (Not Invented Now) syndrom. The Young Generation of
so-called "software engineers" has the opinion that "everything that
was invented before the Internet Era is a garbage". Plus the fact
that the average "information technology worker" reads one technical
book every 3 years...



From: Richard (Winwaed Software Technology)
Subject: Re: "rules-based programming"

Whilst I might agree in general (cf. the fuss about Beowulfs, or "on
demand" rented computing power), I read the article in question a bit
differently from others in this thread...

I took the "sorting out this mess" to refer to current "Enterprise
Computing" (ah yes, how do we make "business computing" sound more
interesting? name it after a fictional starship! )
Ie. Perhaps "rule-based programming" will sort out the current
business "mess" and help to extract useful information from all of
those databases. cf. references to XSLT and SQL.

Maybe he's right - perhaps bullk computing power & "useful" data in
databases have both grown to the point where this might happen.

( as an aside: I'm currently taking a post-grad course in Operations
Management as part of an MBA - I can see how rule-based programming
could be useful, assuming it isn't being used already )



From: Andreas Kuhlo
Subject: Re: "rules-based programming"

Richard (Winwaed Software Technology) wrote:
> Whilst I might agree in general (cf. the fuss about Beowulfs, or "on
> demand" rented computing power), I read the article in question a bit
> differently from others in this thread...
>
> I took the "sorting out this mess" to refer to current "Enterprise
> Computing" (ah yes, how do we make "business computing" sound more
> interesting? name it after a fictional starship! )
> Ie. Perhaps "rule-based programming" will sort out the current
> business "mess"

I understand it that way, too, though the article also says, that rules-
based programming might "create a different kind of mess". But that's not
the point here, which is rather: The article says that rules-based
programming might only be of value if done with Java, C# and XML. This is,
I believe, what Andrzej calls the NIN syndrom, that Prolog, just because
it's older than Java et al., is not considered an option, even though it
could do the task just as well as the new "tools" (another one of these
damn hype-words) could.

Look at the article:

"Don't go hunting in the attic for your 5-1/4-inch Turbo Prolog floppy,
though."

OK, I agree, there are more modern, 32 bit, ISO compatible systems out
there, but others might disagree, as some here seem to like Turbo Prolog a
lot and I certainly do not want to start another discussion about that
here, cause this is not the point, it's rather Prolog vs. hype-"technology"
like Java-based stuff.

"Although Jess, a Java-based engine developed at Sandia Labs, has roots in
both Lisp and Prolog, the emerging business-rules engines work with
languages such as Java and C#, read XML-rule declarations, and are packaged
for J2EE and/or .Net deployment."

Now, what's the point here? Why is something so much better just because it
is Java-, C#-, XML- or whatever-the-current-hype-might-be-based then
Prolog? The article does not explain, it just says "Prolog is old, so
Prolog is bad, Java is new, so Java is good".

"In Prolog's heyday, rules engines spent a lot of time solving old
chestnuts such as the Tower of Hanoi puzzle. Business objects and processes
weren't represented in ways that made them accessible to automatic
reasoning."

That's probably because the typical Prolog programmer is too intelligent to
deal with boring business stuff.

"Thanks to the Web services movement, that's changing big time."

Ah, there it is again, the nice hype-of-the-day.


Back to top




Prolog and the Semantic Web

From: Giovanni Tummarello
Subject: Prolog as a semantic web query language?

I am working on a semantic web project (my phd thesys) and one of the
thing that i wanted to clarify is .. is there a need for a NEW query
language for semantic networks if prolog is already known and
existing? RDF has already at least 10 query languages defined proposed
and Topic Maps (ISO) have for example one called "tolog" :-).

In a poster sent to the www conference in hungary I (among other
things) stated this arguing that power appears to be more important
than sheer speed in this field becouse a significat part of the query
would go to "maintain" consistency during batch operations like
merging base of data or inferring new knowledge from old one, and the
inferred knowledge could be stored for future retrival.

Only one reviewer commented about this saying

"To define Prolog as a query language is quite weird. To exaggerate a
bit, it is a Turing engine and hence can of course also be used as a
query language. But what about datalog and corresponding models of
evaluation from the database point of view? "

I am not sure he can seriously say that, i mean prolog is so ideal for
map exploration and inference how can you just say its another touring
complete language? But the point about Datalog (which if i understand
correctly its a semplified version of prolog just made to handle data)
might mean, why prolog and not just datalog?

Anyone has some idea about this issue?

I believe prolog could have a great role in the semantic web (think
"topic maps", "rdf"), expecially when it will become more down to the
people, but some people that i hear told me to just forget about it
since its generically "too slow for any real graph exploration".

Would the use of constraned prologs help this? I was looking into SWI
prolog for its very open licence (LGPL) but they do not seem to offer
support for constrains..
Not having any on the field experience in this i ask you all: would
that be a real obstacle in the end is it just something that can be
emulated with a clever prolog programming?


From: Jan Wielemaker
Subject: Re: Prolog as a semantic web query language?


Prolog may not be suitable to reason in extremely large domains, but it
is surely a very nice language to reason about the implications of
reasonable-sized collections of triples. We have been using SWI-Prolog
with the native Prolog database for a little more than a million triples.
Recently I started a C-extension that represents the triples as Prolog
atoms with indexing that is targetted to frequent queries. With this
we can load our current set of about 1,7 million triples in less then
10 seconds from a file in internal format or a few minutes from RDF/XML
(AMD 1600+). The size of the resulting Prolog process is about 200MB.
Query speed is well over a million lookups per second, regardless of
the size of the triple-set. The low-level engine already handles the
subPropertyOf relation internally.

Actually it was a nice exercise. The version I wrote 2 years ago was
clearly slow and wasting a lot of memory. A few months ago, equiped with
new experience I write a new triple representation and query layer in
Prolog in 2 days. Some rough estimates showed this was not really
suitable to get our job done on a laptop. So, I decided to redo the
low-level as C, saving some bits and getting more speed. I turned out it
took wel over a week to get where I was with the Prolog version. The
result requires half the memory and worked about 30% faster. It is
probably still not bug-free. Ok, it's just enough to fit our data on a
laptop, but I expected much bigger gains from moving to C.

All this is still work in progress. If you're interested, I can provide
you with access to the prototype. Just drop me a mail.

Giovanni Tummarello wrote:
> I believe prolog could have a great role in the semantic web (think
> "topic maps", "rdf"), expecially when it will become more down to the
> people, but some people that i hear told me to just forget about it
> since its generically "too slow for any real graph exploration".
>
> Would the use of constraned prologs help this? I was looking into SWI
> prolog for its very open licence (LGPL) but they do not seem to offer
> support for constrains..
> Not having any on the field experience in this i ask you all: would
> that be a real obstacle in the end is it just something that can be
> emulated with a clever prolog programming?

Henk van de Casteele wrote an 8-queen solver in plain Prolog that was
faster than the contraint one at the Cyprus ICLP contest :-) On the
other hand, constraints may be useful in some areas. Possibly tabling
is even more useful though. It all depends on what you want to do.



From: Paul Tarau
Subject: Re: Prolog as a semantic web query language?


I have looked at Jan's Prolog based RDF parser - and it is definitely
very nice work! Still, accomodating very large RDF tuple spaces (and
very large XML collections of objects in general), given that most of
the time only a small subset needs to be searched/processed, can be
done quite well with a combination of event driven XML parsers (like
Jinni 2003's Java based SAX parser - see
http://www.binnetcorp.com/Jinni ) using an XPath-like query language
and a memory cache based interface to large external Prolog fact
databases. Using an event driven parser avoids keeping large XML trees
in memory and having a cache for external Prolog facts ensures that
other large data is only brought into memory as needed. The
combination of these can keep the size of a Prolog process under
control and it is likely to improve overall performance.


From: Alexei A. Morozov
Subject: Re: Prolog as a semantic web query language?


I agree that Prolog is the best choice for automating Semantic Web.
There was some projects on Web logic programming based on Prolog and
Datalog ideology (The difference is that Datalog implements Bottom-Up
inference). From my point of view, Bottom-Up approach is not flexible
enough for analyzing semi-structured data in the Web. The details of
our approach you could find in our English paper
http://www.cplire.ru/Lab144/pria570m.pdf .
We have some working examples of Web agents as well.


From: Oskar Bartenstein
Subject: Re: Prolog as a semantic web query language?


On the relation of Prolog, Semantic Web, XML you might
want to check some of the papers presented at INAP2001
http://www.ifcomputer.co.jp/inap/inap2001/
The papers are all online, linked from the Program page.
Revised versions of selected papers are available in book form:
Springer LNAI 2543
Web Knowledge Management and Decision Support

 



Back to top