Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!Germany.EU.net!EU.net!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: If-Then-Else (was: Re: Otherwise?)
Message-ID: <9505704.23884@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <D3x65E.JED@uceng.uc.edu> <3i1888$q7c@goanna.cs.rmit.edu.au> <9505502.26941@mulga.cs.mu.OZ.AU> <3ijuvd$fqi@goanna.cs.rmit.edu.au> <3ikadr$a95@news.irisa.fr> <D4I8DM.Mwq@info.bris.ac.uk>
Date: Sat, 25 Feb 1995 17:56:21 GMT
Lines: 39

bowers@lapu.cs.bris.ac.uk (Antony Bowers) writes:

>While it may be difficult to see the logic in Prolog's (C->A;B), there 
>is no difficulty in giving a logical meaning to conditionals of the form 
>(if C then A else B). The meaning is (C & A) \/ (~C & B). This idea was 
>introduced by Lee Naish in NU-Prolog. There is no need to think of 
>conditionals purely procedurally.
>
>Goedel has this form of conditional, and it is very successful in that 
>it almost completely eliminates the need for explicit pruning, while 
>remaining entirely declarative. There is a more powerful version with 
>existential quantifiers available.

Yes, you are right - Goedel's (and NU-Prolog's) if-then-else is pretty
successful as a declarative replacement for Prolog's (C->A;B).

Unfortunately, it's not successful in doing so while retaining efficiency :-(.

The problem is that in both Goedel and NU-Prolog there is a run-time check
to see whether the non-local variables in the condition are ground.
This check is linear in the size of the terms to which those non-local
variables are bound.  In real-world programs, situations where those
terms are very large arise frequently.  The net implication of this is
that Goedel programs (or pure NU-Prolog programs) tend to run slower
than corresponding Prolog programs by a factor which is assymptotically
proportional to the amount of memory the program consumes!

Mercury solves this problem, because Mercury's compile-time mode checking
ensures that the run-time check isn't necessary.

>Languages that enforce safe negation and lack an explicit cut operator 
>are so much easier to understand than Prolog (and consequently much 
>nicer to teach).

Amen!

-- 
Fergus Henderson - fjh@munta.cs.mu.oz.au
all [L] (programming_language(L), L \= "Mercury") => better("Mercury", L) ;-)
