<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>'<-'/1</CODE> (facts) and <A NAME="IDX5451"></A> <CODE>'<-'/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) <- . bfchain(X,Y) <- 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) <- append(_,S,Y), append(Y,_,L). append([], L, L) <- . append([X|Xs], L, [X|Ys]) <- 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><-/2</CODE> [1200,xfx], <A NAME="IDX5455"></A> <CODE><-/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>