Lambda the Ultimate

inactiveTopic Expressiveness of Declarative Languages
started 8/22/2000; 1:58:39 PM - last post 8/23/2000; 11:05:46 AM
andrew cooke - Expressiveness of Declarative Languages  blueArrow
8/22/2000; 1:58:39 PM (reads: 479, responses: 3)
Expressiveness of Declarative Languages
The discussions got me thinking about declarative languages. In particular, what distinguishes a logic language from a functional language: how easy is translation between them and which is "most expressive" (and what does that mean)? This thesis looks at Prolog and Hashell and tries to answer those questions.

Since I've never used Prolog, or any other logic language, I couldn't follow some of the arguments. A crucial difference appears to centre around well-moded Prolog - but all I know about "well-modedness" is that Mercury (a logic programming language something like Prolog, but faster - an attempt to bring logic programming to commercial applications) doesn't support non-well-moded (bad-moded?) clauses.

Can anyone expand on this? Thanks! (Even if you're as clueless as me, there's some interesting stuff - try the first few chapters and then chapter 8).

For something lighter(?) check out Prolog in Javascript...
Posted to "" by andrew cooke on 8/22/00; 2:09:30 PM

Skib - Mercury in Haskell  blueArrow
8/22/2000; 9:46:23 PM (reads: 514, responses: 2)
Why stop at Prolog?

I haven't read the link fully just skimmed over it but it appears to be an attempt to implement Mercury in Haskell

It actually has a cheap definition of moded predicates. There are other things on modes here but basically; your moded ones translate into functions easily, your bad-moded ones don't. (This is about the depth of my understanding).

Small point, logic programming is used in some areas of commercial applications but they are usually behind the scenes type things. Ilog use lots of constraint logic. A nice application of constraint logic which could be considered more mainstream is the GUI toolkit Amulet which uses constraints for layout and callbacks.

andrew cooke - Re: Mercury in Haskell  blueArrow
8/23/2000; 1:12:38 AM (reads: 569, responses: 1)
Ah! Thanks - excellent link.

OK, so that makes it clearer what modes are. Prolog has logic variables which can be "unassigned". When the equivalent of a function call occurs Prolog tries to assign values to unassigned parameters (basically by searching). So there's no distinction between input and output - any unassigned values are "output".

In Mercury it appears that you have to say which variables are input and which output. Given the above I think it's obvious how this makes translating to functional languages easier.

But it also removes some of the "declarative" nature of Prolog. In Prolog, as far as I understand it, you "just" write a bunch of relations and throw in a bunch of facts. In return, you get the values of any undefined values that can be inferred from the given data. There is no implied flow of data - anything that can be inferred will be (assuming sufficient time and not getting lost down some infinite regression).

By specifying modedness you remove this "magic" quality that makes Prolog so declarative...

Skib - Re: Mercury in Haskell  blueArrow
8/23/2000; 11:05:46 AM (reads: 608, responses: 0)
It doesn't appear to be an all or nothing scenario. It looks like there is a mode system like a type system and Mercury is "strongly moded", Prolog is "weakly moded".

Modes seem to related to the permitted use of the variable so it can be free/grounded which covers the in/out case. This allows a moded request variable for a database (section 4 of the reference manual).

:- inst request ==
bound(  lookup(ground, free)
;       set(ground, ground)
).
:- mode create_request == free >> request.
:- mode satisfy_request == request >> ground.

This looks to me like "declarative typing" with the creation of the "request class" in "primitive types", (too many Quotes?). This doesn't seem to make Mercury less declarative just with stronger declarative 3-D typing, so still has the magic...

Is it valid to say, "modes are equivalent to declarative typing" or is this completely meaningless?