Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 2fc07611b08d4a735fd34d5eb60d8e16 > files > 2107

ciao-1.10p8-3mdv2010.0.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 -->

<LINK rel="stylesheet" href="ciao.css" type="text/css">
<TITLE>The Ciao Prolog System               - Control constructs/predicates</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_15.html">previous</A>, <A HREF="ciao_17.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC128" HREF="ciao_toc.html#TOC128">Control constructs/predicates</A></H1>
<P>
<A NAME="IDX1213"></A>


<P>
<STRONG>Author(s):</STRONG> Daniel Cabeza, Manuel Hermenegildo.


<P>
<STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST)


<P>
<STRONG>Version of last change:</STRONG> 1.9#316 (2004/2/25, 19:16:1 CET)


<P>
This module contains the set of basic control predicates, except the predicates dealing with exceptions, which are in section <A HREF="ciao_26.html#SEC160">Exception handling</A>.



<UL>
<LI><A HREF="ciao_16.html#SEC129">Usage and interface (basiccontrol)</A>
<LI><A HREF="ciao_16.html#SEC130">Documentation on exports (basiccontrol)</A>
<LI><A HREF="ciao_16.html#SEC131">Documentation on internals (basiccontrol)</A>
</UL>



<H2><A NAME="SEC129" HREF="ciao_toc.html#TOC129">Usage and interface (<CODE>basiccontrol</CODE>)</A></H2>

<div class="cartouche">

<UL>

<LI><STRONG>Library usage:</STRONG>

These predicates/constructs are builtin in Ciao, so nothing special has to be done to use them. In fact, as they are hardwired in some parts of the system, most of them cannot be redefined.

<LI><STRONG>Exports:</STRONG>


<UL>

<LI><EM>Predicates:</EM>

<A NAME="IDX1214"></A>
<CODE>,/2</CODE>, 
<A NAME="IDX1215"></A>
<CODE>;/2</CODE>, 
<A NAME="IDX1216"></A>
<CODE>-&#62;/2</CODE>, 
<A NAME="IDX1217"></A>
<CODE>!/0</CODE>, 
<A NAME="IDX1218"></A>
<CODE>\+/1</CODE>, 
<A NAME="IDX1219"></A>
<CODE>if/3</CODE>, 
<A NAME="IDX1220"></A>
<CODE>true/0</CODE>, 
<A NAME="IDX1221"></A>
<CODE>fail/0</CODE>, 
<A NAME="IDX1222"></A>
<CODE>repeat/0</CODE>, 
<A NAME="IDX1223"></A>
<CODE>call/1</CODE>.

</UL>

</UL>

</div class="cartouche">



<H2><A NAME="SEC130" HREF="ciao_toc.html#TOC130">Documentation on exports (<CODE>basiccontrol</CODE>)</A></H2>
<P>
<A NAME="IDX1224"></A>
<A NAME="IDX1225"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>,/2:</B>
<DD><A NAME="IDX1226"></A>


<P>
<CODE>P , Q</CODE>


<P>
Conjunction (<CODE>P</CODE> <EM>and</EM> <CODE>Q</CODE>).


</DL>

<P>
<A NAME="IDX1227"></A>
<A NAME="IDX1228"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>;/2:</B>
<DD><A NAME="IDX1229"></A>


<P>
<CODE>P ; Q</CODE>


<P>
Disjunction (<CODE>P</CODE> <EM>or</EM> <CODE>Q</CODE>).


</DL>

<P>
<A NAME="IDX1230"></A>
<A NAME="IDX1231"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>-&#62;/2:</B>
<DD><A NAME="IDX1232"></A>


<P>
<CODE>P -&#62; Q</CODE>


<P>
If <CODE>P</CODE> then <CODE>Q</CODE> else fail, using first solution of <CODE>P</CODE> only. Also, <CODE>(</CODE><CODE>P</CODE> <CODE>-&#62;</CODE> <CODE>Q</CODE> <CODE>;</CODE> <CODE>R</CODE><CODE>)</CODE>, if <CODE>P</CODE> then <CODE>Q</CODE> else <CODE>R</CODE>, using first solution of <CODE>P</CODE> only. No cuts are allowed in <CODE>P</CODE>.


</DL>

<P>
<A NAME="IDX1233"></A>
<A NAME="IDX1234"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>!/0:</B>
<DD><A NAME="IDX1235"></A>


<P>
<STRONG>Usage:</STRONG> 
<KBD> * ISO * </KBD>

<UL>
<LI><EM>Description:</EM> Commit to any choices taken in the current predicate.

<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1236"></A>
<A NAME="IDX1237"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>\+/1:</B>
<DD><A NAME="IDX1238"></A>


<P>
<CODE>\+ P</CODE>


<P>
Goal <CODE>P</CODE> is not provable (negation by failure). Fails if <CODE>P</CODE> has a solution, and succeeds otherwise. No cuts are allowed in <CODE>P</CODE>.


<P>
<EM>Meta-predicate</EM> with arguments: <CODE>\+goal</CODE>.


<P>
<STRONG>General properties:</STRONG> <CODE>\+ X</CODE>

<UL>
<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP as <CODE>not(X)</CODE>.
 (<CODE>basic_props:native/2</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1239"></A>
<A NAME="IDX1240"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>if/3:</B>
<DD><A NAME="IDX1241"></A>


<P>
<CODE>if(P, Q, R)</CODE>


<P>
If <CODE>P</CODE> then <CODE>Q</CODE> else <CODE>R</CODE>, exploring all solutions of <CODE>P</CODE>. No cuts are allowed in <CODE>P</CODE>.


</DL>

<P>
<A NAME="IDX1242"></A>
<A NAME="IDX1243"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>true/0:</B>
<DD><A NAME="IDX1244"></A>


<P>
<STRONG>Usage:</STRONG> 
<KBD> * ISO * </KBD>

<UL>
<LI><EM>Description:</EM> Succeed (noop).

<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1245"></A>
<A NAME="IDX1246"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>fail/0:</B>
<DD><A NAME="IDX1247"></A>


<P>
<STRONG>Usage:</STRONG> 
<KBD> * ISO * </KBD>

<UL>
<LI><EM>Description:</EM> Fail, backtrack immediately.

<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1248"></A>
<A NAME="IDX1249"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>repeat/0:</B>
<DD><A NAME="IDX1250"></A>


<P>
<STRONG>Usage:</STRONG> 
<KBD> * ISO * </KBD>

<UL>
<LI><EM>Description:</EM> Generates an infinite sequence of backtracking choices.

<LI><EM>The following properties hold globally:</EM>

This predicate is understood natively by CiaoPP.
 (<CODE>basic_props:native/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX1251"></A>
<A NAME="IDX1252"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>call/1:</B>
<DD><A NAME="IDX1253"></A>


<P>
<CODE>call(G)</CODE>


<P>
Executes goal <CODE>G</CODE>, restricting the scope of the cuts to the execution of <CODE>G</CODE>. Equivalent to writing a variable <CODE>G</CODE> in a goal position.


<P>
<EM>Meta-predicate</EM> with arguments: <CODE>call(goal)</CODE>.


</DL>



<H2><A NAME="SEC131" HREF="ciao_toc.html#TOC131">Documentation on internals (<CODE>basiccontrol</CODE>)</A></H2>
<P>
<A NAME="IDX1254"></A>
<A NAME="IDX1255"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>|/2:</B>
<DD><A NAME="IDX1256"></A>


<P>
An alias for disjunction (when appearing outside a list). The alias is performed when terms are read in.


</DL>

<P><HR><P>
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_15.html">previous</A>, <A HREF="ciao_17.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
</BODY>
</HTML>