Sophie

Sophie

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

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               - Breadth-first execution</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_108.html">previous</A>, <A HREF="ciao_110.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="SEC452" HREF="ciao_toc.html#TOC452">Breadth-first execution</A></H1>
<P>
<A NAME="IDX5449"></A>


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


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


<P>
<STRONG>Version of last change:</STRONG> 1.5#143 (2000/5/12, 13:54:34 CEST)


<P>
This package implements breadth-first execution of predicates. Predicates written with operators 
<A NAME="IDX5450"></A>
<CODE>'&#60;-'/1</CODE> (facts) and 
<A NAME="IDX5451"></A>
<CODE>'&#60;-'/2</CODE> (clauses) are executed using breadth-first search. This may be useful in search problems when a 
<A NAME="IDX5452"></A>
complete proof procedure is needed. An example of code would be: 

<PRE>
:- module(chain, _, [bf]).

test(bf) :- bfchain(a,d).
test(df) :- chain(a,d).   % loops!

bfchain(X,X) &#60;- .
bfchain(X,Y) &#60;- arc(X,Z), bfchain(Z,Y).

chain(X,X).
chain(X,Y) :- arc(X,Z), chain(Z,Y).

arc(a,b).
arc(a,d).
arc(b,c).
arc(c,a).

</PRE>

<P>
There is another version, called 
<A NAME="IDX5453"></A>
<CODE>bf/af</CODE>, which ensures AND-fairness by goal shuffling. This version correctly says "<CODE>no</CODE>" executing the following test: 

<PRE>
:- module(sublistapp, [test/0,sublistapp/2], ['bf/af']).

test :- sublistapp([a],[b]).

sublistapp(S,L) &#60;- append(_,S,Y), append(Y,_,L).

append([], L, L) &#60;- .
append([X|Xs], L, [X|Ys]) &#60;- append(Xs, L, Ys).

</PRE>


<UL>
<LI><A HREF="ciao_109.html#SEC453">Usage and interface (bf)</A>
<LI><A HREF="ciao_109.html#SEC454">Known bugs and planned improvements (bf)</A>
</UL>



<H2><A NAME="SEC453" HREF="ciao_toc.html#TOC453">Usage and interface (<CODE>bf</CODE>)</A></H2>

<div class="cartouche">

<UL>

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

<CODE>:- use_package(bf).</CODE>

or

<CODE>:- module(...,...,[bf]).</CODE>

<LI><STRONG>New operators defined:</STRONG>

<A NAME="IDX5454"></A>
<CODE>&#60;-/2</CODE> [1200,xfx], 
<A NAME="IDX5455"></A>
<CODE>&#60;-/1</CODE> [1200,xf].
</UL>

</div class="cartouche">



<H2><A NAME="SEC454" HREF="ciao_toc.html#TOC454">Known bugs and planned improvements (<CODE>bf</CODE>)</A></H2>


<UL>

<LI>

Does not correctly work in user files.
</UL>

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