Sophie

Sophie

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

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               - Comparing terms</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_20.html">previous</A>, <A HREF="ciao_22.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="SEC144" HREF="ciao_toc.html#TOC144">Comparing terms</A></H1>
<P>
<A NAME="IDX1462"></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#199 (2003/12/19, 18:18:33 CET)


<P>
These built-in predicates are extra-logical. They treat uninstantiated variables as objects with values which may be compared, and they never instantiate those variables. They should <EM>not</EM> be used when what you really want is arithmetic comparison or unification. 


<P>
The predicates make reference to a 
<A NAME="IDX1463"></A>
<A NAME="IDX1464"></A>
<EM>standard total ordering</EM> of terms, which is as follows: 



<UL>

<LI>Variables, by age (roughly, oldest first -- the order is <EM>not</EM> related to the names of variables).

<LI>Floats, in numeric order (e.g. -1.0 is put before 1.0).

<LI>Integers, in numeric order (e.g. -1 is put before 1).

<LI>Atoms, in alphabetical (i.e. character code) order.

<LI>Compound terms, ordered first by arity, then by the name of the principal functor, then by the arguments in left-to-right order. Recall that lists are equivalent to compound terms with principal functor <CODE>'.'/2</CODE>.

</UL>

<P>
For example, here is a list of terms in standard order: 



<PRE>
[ X, -1.0, -9, 1, bar, foo, [1], X = Y, foo(0,2), bar(1,1,1) ]
</PRE>


<UL>
<LI><A HREF="ciao_21.html#SEC145">Usage and interface (term_compare)</A>
<LI><A HREF="ciao_21.html#SEC146">Documentation on exports (term_compare)</A>
</UL>



<H2><A NAME="SEC145" HREF="ciao_toc.html#TOC145">Usage and interface (<CODE>term_compare</CODE>)</A></H2>

<div class="cartouche">

<UL>

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

These predicates are builtin in Ciao, so nothing special has to be done to use them.

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


<UL>

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

<A NAME="IDX1465"></A>
<CODE>compare/3</CODE>.

<LI><EM>Properties:</EM>

<A NAME="IDX1466"></A>
<CODE>==/2</CODE>, 
<A NAME="IDX1467"></A>
<CODE>\==/2</CODE>, 
<A NAME="IDX1468"></A>
<CODE>@&#60;/2</CODE>, 
<A NAME="IDX1469"></A>
<CODE>@=&#60;/2</CODE>, 
<A NAME="IDX1470"></A>
<CODE>@&#62;/2</CODE>, 
<A NAME="IDX1471"></A>
<CODE>@&#62;=/2</CODE>.

</UL>

</UL>

</div class="cartouche">



<H2><A NAME="SEC146" HREF="ciao_toc.html#TOC146">Documentation on exports (<CODE>term_compare</CODE>)</A></H2>
<P>
<A NAME="IDX1472"></A>
<A NAME="IDX1473"></A>
<DL>
<DT><span class="define">PROPERTY:</span> <B>==/2:</B>
<DD><A NAME="IDX1474"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>Term1 == Term2</CODE>

<UL>
<LI><EM>Description:</EM> The terms <CODE>Term1</CODE> and <CODE>Term2</CODE> are strictly identical.

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

<CODE>Term1</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

<CODE>Term2</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

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

</DL>

<P>
<A NAME="IDX1475"></A>
<A NAME="IDX1476"></A>
<DL>
<DT><span class="define">PROPERTY:</span> <B>\==/2:</B>
<DD><A NAME="IDX1477"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>Term1 \== Term2</CODE>

<UL>
<LI><EM>Description:</EM> The terms <CODE>Term1</CODE> and <CODE>Term2</CODE> are not strictly identical.

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

<CODE>Term1</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

<CODE>Term2</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

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

</DL>

<P>
<A NAME="IDX1478"></A>
<A NAME="IDX1479"></A>
<DL>
<DT><span class="define">PROPERTY:</span> <B>@&#60;/2:</B>
<DD><A NAME="IDX1480"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>@&#60;(Term1, Term2)</CODE>

<UL>
<LI><EM>Description:</EM> The term <CODE>Term1</CODE> precedes the term <CODE>Term2</CODE> in the standard order.

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

<CODE>Term1</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

<CODE>Term2</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

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

</DL>

<P>
<A NAME="IDX1481"></A>
<A NAME="IDX1482"></A>
<DL>
<DT><span class="define">PROPERTY:</span> <B>@=&#60;/2:</B>
<DD><A NAME="IDX1483"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>@=&#60;(Term1, Term2)</CODE>

<UL>
<LI><EM>Description:</EM> The term <CODE>Term1</CODE> precedes or is identical to the term <CODE>Term2</CODE> in the standard order.

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

<CODE>Term1</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

<CODE>Term2</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

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

</DL>

<P>
<A NAME="IDX1484"></A>
<A NAME="IDX1485"></A>
<DL>
<DT><span class="define">PROPERTY:</span> <B>@&#62;/2:</B>
<DD><A NAME="IDX1486"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>@&#62;(Term1, Term2)</CODE>

<UL>
<LI><EM>Description:</EM> The term <CODE>Term1</CODE> follows the term <CODE>Term2</CODE> in the standard order.

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

<CODE>Term1</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

<CODE>Term2</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

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

</DL>

<P>
<A NAME="IDX1487"></A>
<A NAME="IDX1488"></A>
<DL>
<DT><span class="define">PROPERTY:</span> <B>@&#62;=/2:</B>
<DD><A NAME="IDX1489"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>@&#62;=(Term1, Term2)</CODE>

<UL>
<LI><EM>Description:</EM> The term <CODE>Term1</CODE> follows or is identical to the term <CODE>Term2</CODE> in the standard order.

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

<CODE>Term1</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

<CODE>Term2</CODE> is not further instantiated.
 (<CODE>basic_props:not_further_inst/2</CODE>)

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

</DL>

<P>
<A NAME="IDX1490"></A>
<A NAME="IDX1491"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>compare/3:</B>
<DD><A NAME="IDX1492"></A>


<P>
<CODE>compare(Op, Term1, Term2)</CODE>


<P>
<CODE>Op</CODE> is the result of comparing the terms <CODE>Term1</CODE> and <CODE>Term2</CODE>.


<P>
<STRONG>Usage:</STRONG> <CODE>compare(?atm, @term, @term)</CODE>

<UL>
<LI><EM>The following properties hold upon exit:</EM>

<CODE>?atm</CODE> is an element of <CODE>[=,&#62;,&#60;]</CODE>.
 (<CODE>basic_props:member/2</CODE>)

<CODE>@term</CODE> is any term.
 (<CODE>basic_props:term/1</CODE>)

<CODE>@term</CODE> is any term.
 (<CODE>basic_props:term/1</CODE>)
<LI><EM>The following properties hold globally:</EM>

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

</DL>

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