On Aug 15, 2005, at 5:46 AM, Ryan Kelly wrote:
Hi Alex,
I'm new to Prolog, I wonder if there is a 'not/1' or something similar to use in Ciao, or do I have to write it myself?
The standard negation operator in ciao is +
This implements "negation-as-failure", so `+ G` means that it is impossible to prove goal G.
Your semantics are not quite correct; the system might never prove G due to non termination.
I've seen other prologs offer this as not/1, but I dont think it's done in Ciao. SWI-Prolog, another popular open-source prolog implementation, provides not/1 for compatibility but recommends that + be used for new code.
If you use the module "iso", you can also get the operator =, which means that two terms don't unify. Here are some quick examples:
Succeed:
\+ 3 is 1 + 1. \+ a = b. a \= b.Fail:
\+ 4 is 2 + 2. f(a,b) \= f(a,b)Hope that helps,
Ryan
-- Ryan Kelly http://www.rfk.id.au | This message is digitally signed. Please visit ryan(a)rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details
============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es UnsuFrom owner-ciao-users(a)clip.dia.fi.upm.es Tue Aug 16 00:07:50 2005 Received: from clip.dia.fi.upm.es (localhost [127.0.0.1]) by clip.dia.fi.upm.es (8.12.11/8.12.11) with ESMTP id j7FM7ojV007249; Tue, 16 Aug 2005 00:07:50 +0200 Received: (from majordom(a)localhost) by clip.dia.fi.upm.es (8.12.11/8.12.11/Submit) id j7FM7o6Q007248; Tue, 16 Aug 2005 00:07:50 +0200 X-Authentication-Warning: clip.dia.fi.upm.es: majordom set sender to owner-ciao-users(a)clip.dia.fi.upm.es using -f Received: from clip.dia.fi.upm.es (localhost [127.0.0.1]) by clip.dia.fi.upm.es (8.12.11/8.12.11) with ESMTP id j7FM7n1i007244; Tue, 16 Aug 2005 00:07:49 +0200 Received: (from clip-mod(a)localhost) by clip.dia.fi.upm.es (8.12.11/8.12.11/Submit) id j7FM7nVR007243; Tue, 16 Aug 2005 00:07:49 +0200 Received: from goofy.fi.upm.es (goofy.fi.upm.es [138.100.8.23]) by clip.dia.fi.upm.es (8.12.11/8.12.11) with ESMTP id j7FM7cZO007209 for <ciao-users(a)clip.dia.fi.upm.es>; Tue, 16 Aug 2005 00:07:40 +0200 Received: from relay.upm.es (relay.upm.es [138.100.4.8]) by relay.fi.upm.es (PMDF V6.2-1x5 #30875) with ESMTP id <01LRVJOQ8R0M000ITQ(a)relay.fi.upm.es> for ciao-users(a)clip.dia.fi.upm.es; Tue, 16 Aug 2005 00:06:40 +0200 (MET-DST) Received: from postinofz1.prima.com.ar (postinofz1.prima.com.ar [200.42.0.149]) by relay.upm.es (8.11.2/8.11.1) with SMTP id j7FM6cl14687 for <ciao-users(a)clip.dia.fi.upm.es>; Tue, 16 Aug 2005 00:06:38 +0200 (MEST) Received: (qmail 61902 invoked from network); Mon, 15 Aug 2005 22:06:36 +0000 Received: from unknown (HELO balboa.dia.fi.upm.es) (201.254.225.9) by postinofz1.prima.com.ar with SMTP; Mon, 15 Aug 2005 22:06:36 +0000 Received: by balboa.dia.fi.upm.es (Postfix, from userid 1015) id 7375329013E; Mon, 15 Aug 2005 15:06:40 -0300 (ART) Date: Mon, 15 Aug 2005 15:06:39 -0300 From: Michael Zolda <e9725694(a)student.tuwien.ac.at> Subject: Re: Is there a 'not' predicate for ciao? In-reply-to: <17152.25725.1452.611599(a)balboa.dia.fi.upm.es> To: ciao-users(a)clip.dia.fi.upm.es Cc: yw4126(a)bristol.ac.uk Message-id: <17152.55727.792140.63228(a)balboa.dia.fi.upm.es> MIME-version: 1.0 X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Content-type: Text/Plain; charset=us-ascii Content-transfer-encoding: 7bit References: <17151.44540.237729.129428(a)balboa.dia.fi.upm.es> <17152.25725.1452.611599(a)balboa.dia.fi.upm.es> X-Authentication-warning: stud3.tuwien.ac.at: e9725694 owned process doing -bs X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on clip.dia.fi.upm.es X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.9 tests=BAYES_00 autolearn=ham version=3.0.3 Sender: owner-ciao-users(a)clip.dia.fi.upm.es Precedence: bulk
From: Ryan Kelly <ryan(a)rfk.id.au> Subject: Re: Is there a 'not' predicate for ciao? Date: Mon, 15 Aug 2005 06:46:37 -0300
Hi Alex,
I'm new to Prolog, I wonder if there is a 'not/1' or something similar to use in Ciao, or do I have to write it myself?
The standard negation operator in ciao is +
This implements "negation-as-failure", so `+ G` means that it is impossible to prove goal G.
More precisely, the negation of a goal will succeed, if (the proof search for) that goal eventually fails. On the other hand, non-termination of G implies the non-termination of + G. Some people therefore prefer to use the term "negation as finite failure".
A straightforward DIY implementation of this kind of negation would be:
not(G) :- call(G), !, fail. not(_G).
Michael Zolda
============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ ----------------------------------------------------------------------------- bscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------