This file is indexed.

/usr/share/doc/gprolog-doc/gprolog.html/gprolog060.html is in gprolog-doc 1.3.0-6.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>

<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<META name="GENERATOR" content="hevea 1.10">
<LINK rel="stylesheet" type="text/css" href="gprolog.css">
<TITLE>Arithmetic constraints</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="gprolog059.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog054.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog061.html"><IMG SRC="next_motif.gif" ALT="Next"></A>
<HR>
<H3 CLASS="subsection"><A NAME="htoc321">8.6</A>&#XA0;&#XA0;Arithmetic constraints</H3><UL>
<LI><A HREF="gprolog060.html#toc263">FD arithmetic expressions</A>
</LI><LI><A HREF="gprolog060.html#toc264">Partial AC: <TT>(#=)/2</TT> - constraint equal,
<TT>(#</TT><TT>\</TT><TT>=)/2</TT> - constraint not equal,<BR>
 <TT>(#</TT><TT>&lt;</TT><TT>)/2</TT> - constraint less than,
<TT>(#=</TT><TT>&lt;</TT><TT>)/2</TT> - constraint less than or equal,<BR>
 <TT>(#</TT><TT>&gt;</TT><TT>)/2</TT> - constraint greater than,
<TT>(#</TT><TT>&gt;</TT><TT>=)/2</TT> - constraint greater than or equal</A>
</LI><LI><A HREF="gprolog060.html#toc265">Full AC: <TT>(#=#)/2</TT> - constraint equal,
<TT>(#</TT><TT>\</TT><TT>=#)/2</TT> - constraint not equal,<BR>
 <TT>(#</TT><TT>&lt;</TT><TT>#)/2</TT> - constraint less than,
<TT>(#=</TT><TT>&lt;</TT><TT>#)/2</TT> - constraint less than or equal,<BR>
 <TT>(#</TT><TT>&gt;</TT><TT>#)/2</TT> - constraint greater than,
<TT>(#</TT><TT>&gt;</TT><TT>=#)/2</TT> - constraint greater than or equal</A>
</LI><LI><A HREF="gprolog060.html#toc266"><TT>fd_prime/1</TT>,
<TT>fd_not_prime/1</TT></A>
</LI></UL>
<H4 CLASS="subsubsection"><A NAME="toc263"></A><A NAME="htoc322">8.6.1</A>&#XA0;&#XA0;FD arithmetic expressions</H4><P>
<A NAME="FD-arithmetic-expressions"></A>
An FD arithmetic expression is a Prolog term built from integers, variables
(Prolog or FD variables), and functors (or operators) that represent
arithmetic functions. The following table details the components of an FD
arithmetic expression:</P><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1><TR><TD VALIGN=top ALIGN=left NOWRAP>
FD Expression</TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">Result</DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
Prolog variable</TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">domain <TT>0..fd_max_integer</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
FD variable <TT>X</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">domain of <TT>X</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
integer number <TT>N</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">domain <TT>N..N</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>+ E</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">same as <TT>E</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>- E</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">opposite of <TT>E</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>E1 + E2</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">sum of <TT>E1</TT> and <TT>E2</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>E1 - E2</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">subtraction of <TT>E2</TT> from <TT>E1</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>E1 * E2</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">multiplication of <TT>E1</TT> by <TT>E2</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>E1 / E2</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">integer division of <TT>E1</TT> by <TT>E2</TT> (only
succeeds if the remainder is 0)</DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>E1 ** E2</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft"><TT>E1</TT> raised to the power of <TT>E2
</TT>(<TT>E1</TT> or <TT>E2</TT> must be an integer)</DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>min(E1,E2)</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">minimum of <TT>E1</TT> and <TT>E2</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>max(E1,E2)</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">maximum of <TT>E1</TT> and <TT>E2</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>dist(E1,E2)</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">distance, i.e. |<TT>E1 - E2|</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>E1 // E2</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">quotient of the integer division of <TT>E1</TT> by
<TT>E2</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>E1 rem E2</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">remainder of the integer division of <TT>E1</TT> by
<TT>E2</TT></DIV></TD></TR>
<TR><TD VALIGN=top ALIGN=left NOWRAP>
<TT>quot_rem(E1,E2,R)</TT></TD><TD VALIGN=top ALIGN=left><DIV CLASS="flushleft">quotient of the integer division of
<TT>E1</TT> by <TT>E2</TT>
<BR>
(<TT>R</TT> is the remainder of the integer division of <TT>E1</TT> by
<TT>E2</TT>)</DIV></TD></TR>
</TABLE><P>FD expressions are not restricted to be linear. However non-linear
constraints usually yield less constraint propagation than linear
constraints.</P><P><TT>+</TT>, <TT>-</TT>, <TT>*</TT>, <TT>/</TT>, <TT>//</TT>, <TT>rem</TT>
and <TT>**</TT> are predefined infix operators. <TT>+</TT> and <TT>-</TT>
are predefined prefix operators (section&#XA0;<A HREF="gprolog037.html#op/3:(Term-input/output)">7.14.10</A>).</P><P><B>Errors</B></P><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD CLASS="hbar" COLSPAN=3></TD></TR>
<TR><TD VALIGN=top ALIGN=left>
a sub-expression is of the form <TT>_ ** E</TT> and <TT>E</TT> is
a variable</TD><TD VALIGN=top ALIGN=center NOWRAP>&#XA0;&#XA0;</TD><TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD></TR>
<TR><TD CLASS="hbar" COLSPAN=3></TD></TR>
<TR><TD VALIGN=top ALIGN=left>
a sub-expression <TT>E</TT> is neither a variable nor an integer
nor an FD arithmetic functor</TD><TD VALIGN=top ALIGN=center NOWRAP>&#XA0;&#XA0;</TD><TD VALIGN=top ALIGN=left><TT>type_error(fd_evaluable, E)</TT></TD></TR>
<TR><TD CLASS="hbar" COLSPAN=3></TD></TR>
<TR><TD VALIGN=top ALIGN=left>
an expression is too complex</TD><TD VALIGN=top ALIGN=center NOWRAP>&#XA0;&#XA0;</TD><TD VALIGN=top ALIGN=left><TT>resource_error(too_big_fd_constraint)</TT></TD></TR>
<TR><TD CLASS="hbar" COLSPAN=3></TD></TR>
</TABLE><H4 CLASS="subsubsection"><A NAME="toc264"></A><A NAME="htoc323">8.6.2</A>&#XA0;&#XA0;Partial AC: <TT>(#=)/2</TT> - constraint equal,
<TT>(#\=)/2</TT> - constraint not equal,<BR>
 <TT>(#&lt;)/2</TT> - constraint less than,
<TT>(#=&lt;)/2</TT> - constraint less than or equal,<BR>
 <TT>(#&gt;)/2</TT> - constraint greater than,
<TT>(#&gt;=)/2</TT> - constraint greater than or equal</H4><P>
<A NAME="Partial-AC:-(:=)/2"></A>





</P><P><B>Templates</B></P><DL CLASS="list"><DT CLASS="dt-list">
</DT><DD CLASS="dd-list"><TT>
#=(?fd_evaluable, ?fd_evaluable)<BR>
#\=(?fd_evaluable, ?fd_evaluable)<BR>
#&lt;(?fd_evaluable, ?fd_evaluable)<BR>
#=&lt;(?fd_evaluable, ?fd_evaluable)<BR>
#&gt;(?fd_evaluable, ?fd_evaluable)<BR>
#&gt;=(?fd_evaluable, ?fd_evaluable)</TT></DD></DL><P><B>Description</B></P><P><TT>FdExpr1 #= FdExpr2</TT> constrains <TT>FdExpr1</TT> to be
equal to <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #\= FdExpr2</TT> constrains <TT>FdExpr1</TT>
to be different from <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #&lt; FdExpr2</TT> constrains <TT>FdExpr1</TT> to
be less than <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #=&lt; FdExpr2</TT> constrains <TT>FdExpr1</TT>
to be less than or equal to <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #&gt; FdExpr2</TT> constrains <TT>FdExpr1</TT> to
be greater than <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #&gt;= FdExpr2</TT> constrains <TT>FdExpr1</TT>
to be greater than or equal to <TT>FdExpr2</TT>.</P><P><TT>FdExpr1</TT> and <TT>FdExpr2</TT> are arithmetic FD expressions
(section&#XA0;<A HREF="#FD-arithmetic-expressions">8.6.1</A>).</P><P><TT>#=</TT>, <TT>#\=</TT>, <TT>#&lt;</TT>, <TT>#=&lt;</TT>,
<TT>#&gt;</TT> and <TT>#&gt;=</TT> are predefined infix operators
(section&#XA0;<A HREF="gprolog037.html#op/3:(Term-input/output)">7.14.10</A>).</P><P>These predicates post arithmetic constraints that are managed by the solver
using a partial arc-consistency algorithm to reduce the domain of involved
variables. In this scheme only the bounds of the domain of variables are
updated. This leads to less propagation than full arc-consistency techniques
(section&#XA0;<A HREF="#Full-AC:-(:=:)/2">8.6.3</A>) but is generally more efficient for
arithmetic. These arithmetic constraints can be reified (section&#XA0;<A HREF="gprolog061.html#Boolean-and-reified-constraints">8.7</A>).</P><P><B>Errors</B></P><P>Refer to the syntax of arithmetic FD expressions for possible errors
(section&#XA0;<A HREF="#FD-arithmetic-expressions">8.6.1</A>).</P><P><B>Portability</B></P><P>GNU Prolog predicates.</P><H4 CLASS="subsubsection"><A NAME="toc265"></A><A NAME="htoc324">8.6.3</A>&#XA0;&#XA0;Full AC: <TT>(#=#)/2</TT> - constraint equal,
<TT>(#\=#)/2</TT> - constraint not equal,<BR>
 <TT>(#&lt;#)/2</TT> - constraint less than,
<TT>(#=&lt;#)/2</TT> - constraint less than or equal,<BR>
 <TT>(#&gt;#)/2</TT> - constraint greater than,
<TT>(#&gt;=#)/2</TT> - constraint greater than or equal</H4><P>
<A NAME="Full-AC:-(:=:)/2"></A>





</P><P><B>Templates</B></P><DL CLASS="list"><DT CLASS="dt-list">
</DT><DD CLASS="dd-list"><TT>
#=#(?fd_evaluable, ?fd_evaluable)<BR>
#\=#(?fd_evaluable, ?fd_evaluable)<BR>
#&lt;#(?fd_evaluable, ?fd_evaluable)<BR>
#=&lt;#(?fd_evaluable, ?fd_evaluable)<BR>
#&gt;#(?fd_evaluable, ?fd_evaluable)<BR>
#&gt;=#(?fd_evaluable, ?fd_evaluable)</TT></DD></DL><P><B>Description</B></P><P><TT>FdExpr1 #=# FdExpr2</TT> constrains <TT>FdExpr1</TT> to
be equal to <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #\=# FdExpr2</TT> constrains <TT>FdExpr1</TT> to be
different from <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #&lt;# FdExpr2</TT> constrains <TT>FdExpr1</TT>
to be less than <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #=&lt;# FdExpr2</TT> constrains <TT>FdExpr1</TT> to be
less than or equal to <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #&gt;# FdExpr2</TT> constrains <TT>FdExpr1</TT>
to be greater than <TT>FdExpr2</TT>.</P><P><TT>FdExpr1 #&gt;=# FdExpr2</TT> constrains <TT>FdExpr1</TT> to be
greater than or equal to <TT>FdExpr2</TT>.</P><P><TT>FdExpr1</TT> and <TT>FdExpr2</TT> are arithmetic FD expressions
(section&#XA0;<A HREF="#FD-arithmetic-expressions">8.6.1</A>).</P><P><TT>#=#</TT>, <TT>#\=#</TT>, <TT>#&lt;#</TT>,
<TT>#=&lt;#</TT>, <TT>#&gt;#</TT> and <TT>#&gt;=#</TT> are
predefined infix operators (section&#XA0;<A HREF="gprolog037.html#op/3:(Term-input/output)">7.14.10</A>).</P><P>These predicates post arithmetic constraints that are managed by the solver
using a full arc-consistency algorithm to reduce the domain of involved
variables. In this scheme the full domain of variables is updated. This
leads to more propagation than partial arc-consistency techniques (section&#XA0;<A HREF="#FD-arithmetic-expressions">8.6.1</A>) but is generally less efficient for arithmetic.
These arithmetic constraints can be reified (section&#XA0;<A HREF="gprolog061.html#Boolean-FD-expressions">8.7.1</A>).</P><P><B>Errors</B></P><P>Refer to the syntax of arithmetic FD expressions for possible errors
(section&#XA0;<A HREF="#FD-arithmetic-expressions">8.6.1</A>).</P><P><B>Portability</B></P><P>GNU Prolog predicates.</P><H4 CLASS="subsubsection"><A NAME="toc266"></A><A NAME="htoc325">8.6.4</A>&#XA0;&#XA0;<TT>fd_prime/1</TT>,
<TT>fd_not_prime/1</TT></H4><P><B>Templates</B></P><DL CLASS="list"><DT CLASS="dt-list">
</DT><DD CLASS="dd-list"><TT>
fd_prime(?fd_variable)<BR>
fd_not_prime(?fd_variable)</TT></DD></DL><P><B>Description</B></P><P><TT>fd_prime(X)</TT> constraints <TT>X</TT> to be a prime number between
<TT>0..vector_max</TT>.
This constraint enforces a sparse representation
for the domain of <TT>X</TT> (section&#XA0;<A HREF="gprolog055.html#Intro-FD">8.1</A>).</P><P><TT>fd_not_prime(X)</TT> constraints <TT>X</TT> to be a non prime number
between <TT>0..vector_max</TT>. This constraint enforces a sparse
representation for the domain of <TT>X</TT> (section&#XA0;<A HREF="gprolog055.html#Intro-FD">8.1</A>).</P><P><B>Errors</B></P><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD CLASS="hbar" COLSPAN=3></TD></TR>
<TR><TD VALIGN=top ALIGN=left>
<TT>X</TT> is neither an FD variable nor an integer</TD><TD VALIGN=top ALIGN=center NOWRAP>&#XA0;&#XA0;</TD><TD VALIGN=top ALIGN=left><TT>type_error(fd_variable, X)</TT></TD></TR>
<TR><TD CLASS="hbar" COLSPAN=3></TD></TR>
</TABLE><P><B>Portability</B></P><P>GNU Prolog predicates.</P>
<HR SIZE=2>
Copyright (C) 1999-2007 Daniel Diaz
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. <A HREF="index.html#copyright">More about the copyright</A>
<HR>
<A HREF="gprolog059.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog054.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog061.html"><IMG SRC="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>