Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 5ee7712a65135f0dd95d1c92938a0193 > files > 188

ocaml-facile-doc-1.1-2mdv2010.0.i586.rpm

<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Start" href="index.html">
<link rel="previous" href="Reify.html">
<link rel="next" href="Conjunto.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Domain" rel="Chapter" href="Domain.html">
<link title="SetDomain" rel="Chapter" href="SetDomain.html">
<link title="Stak" rel="Chapter" href="Stak.html">
<link title="Data" rel="Chapter" href="Data.html">
<link title="Cstr" rel="Chapter" href="Cstr.html">
<link title="Var" rel="Chapter" href="Var.html">
<link title="Invariant" rel="Chapter" href="Invariant.html">
<link title="Reify" rel="Chapter" href="Reify.html">
<link title="Arith" rel="Chapter" href="Arith.html">
<link title="Conjunto" rel="Chapter" href="Conjunto.html">
<link title="Goals" rel="Chapter" href="Goals.html">
<link title="FdArray" rel="Chapter" href="FdArray.html">
<link title="Gcc" rel="Chapter" href="Gcc.html">
<link title="Alldiff" rel="Chapter" href="Alldiff.html">
<link title="Sorting" rel="Chapter" href="Sorting.html">
<link title="Interval" rel="Chapter" href="Interval.html"><link title="Basics" rel="Section" href="#2_Basics">
<link title="Construction of Arithmetic Expressions" rel="Section" href="#2_ConstructionofArithmeticExpressions">
<link title="Access" rel="Section" href="#2_Access">
<link title="Arithmetic Constraints on Expressions" rel="Section" href="#2_ArithmeticConstraintsonExpressions">
<link title="Reification" rel="Section" href="#2_Reification">
<link title="Boolean sums setting" rel="Section" href="#2_Booleansumssetting">
<title>Arith</title>
</head>
<body>
<div class="navbar"><a href="Reify.html">Previous</a>
&nbsp;<a href="index.html">Up</a>
&nbsp;<a href="Conjunto.html">Next</a>
</div>
<center><h1>Module <a href="type_Arith.html">Arith</a></h1></center>
<br>
<pre><span class="keyword">module</span> Arith: <code class="code">sig</code> <a href="Arith.html">..</a> <code class="code">end</code></pre><a name="1_ArithmeticExpressionsandConstraints"></a>
<h1>Arithmetic Expressions and Constraints</h1><br>
<hr width="100%">
<br>
<br>
<br>
This module provides functions and operators to build arithmetic
   expressions and state (in/dis)equation constraints on them.<br>
<br>
<a name="2_Basics"></a>
<h2>Basics</h2><br>
<pre><span class="keyword">type</span> <a name="TYPEt"></a><code class="type"></code>t </pre>
<div class="info">
Type of arithmetic expressions over variables of type <code class="code">Var.Fd.t</code> and
   integers.<br>
</div>

<pre><span class="keyword">val</span> <a name="VALi2e"></a>i2e : <code class="type">int -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">i2e n</code> returns an expression which evaluates to <code class="code">n</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALfd2e"></a>fd2e : <code class="type">Var.Fd.t -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">fd2e v</code> returns an expression which evaluates to <code class="code">n</code> if the
    variable <code class="code">v</code> is instantiated to <code class="code">n</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALe2fd"></a>e2fd : <code class="type"><a href="Arith.html#TYPEt">t</a> -> Var.Fd.t</code></pre><div class="info">
<code class="code">e2fd e</code> creates and returns a new variable <code class="code">v</code> and posts the constraint
    <code class="code">fd2e v =~ e</code>.<br>
</div>
<br>
<a name="2_ConstructionofArithmeticExpressions"></a>
<h2>Construction of Arithmetic Expressions</h2><br>
<br>
<b>Only</b> if compiled in bytecode (using <code class="code">facile.cma</code>),
   the arithmetic operators check whether any integer overflow
   (i.e. the result of an arithmetic operation on integers is
   less than <code class="code">min_int</code> or greater than <code class="code">max_int</code>) occurs during
   constraints internal computations and raise an assert failure.
   Arithmetic operations are taken modulo  otherwise
   (or  on 64-bit processors, see the OCaml reference
   manual), thus incomplete failures may happen
   with native code compiled programs.<br>
<pre><span class="keyword">val</span> <a name="VAL(+~)"></a>(+~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(-~)"></a>(-~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(*~)"></a>(*~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
Addition, substraction, multiplication on expressions.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(**~)"></a>(**~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> int -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
Exponentiation of an expression to an integer value.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(/~)"></a>(/~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(%~)"></a>(%~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
Division and modulo on expressions. The exception <code class="code">Division_by_zero</code>
   is raised whenever the second argument evaluates to 0.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALabs"></a>abs : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
Absolute value on expressions.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALsum"></a>sum : <code class="type"><a href="Arith.html#TYPEt">t</a> array -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALsum_fd"></a>sum_fd : <code class="type">Var.Fd.t array -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">sum exps</code> (resp. <code class="code">sum_fd vars</code>) returns the sum of all the elements of an
   array of expressions (resp. variables). Returns an expression that evaluates
   to 0 if the array is empty.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALscalprod"></a>scalprod : <code class="type">int array -> <a href="Arith.html#TYPEt">t</a> array -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALscalprod_fd"></a>scalprod_fd : <code class="type">int array -> Var.Fd.t array -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">scalprod coeffs exps</code> (resp. <code class="code">scalprod_fd coeffs vars</code>) returns the
   scalar product of an array of integers and an array of expressions
   (resp. variables).
   Returns an expression that evaluates to 0 if both arrays are empty.
   Raises <code class="code">Invalid_argument</code> if the arrays don't have the same length.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALprod"></a>prod : <code class="type"><a href="Arith.html#TYPEt">t</a> array -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VALprod_fd"></a>prod_fd : <code class="type">Var.Fd.t array -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">prod exps</code> (resp. <code class="code">prod_fd vars</code>) returns the product of all the
   elements of an array of expressions (resp. variables).
   Returns an expression that evaluates to 1 if the array is empty.<br>
</div>
<br>
<a name="2_Access"></a>
<h2>Access</h2><br>
<pre><span class="keyword">val</span> <a name="VALfprint"></a>fprint : <code class="type">Pervasives.out_channel -> <a href="Arith.html#TYPEt">t</a> -> unit</code></pre><div class="info">
<code class="code">fprint chan e</code> prints expression <code class="code">e</code> on channel <code class="code">chan</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALeval"></a>eval : <code class="type"><a href="Arith.html#TYPEt">t</a> -> int</code></pre><div class="info">
<code class="code">eval e</code> returns the integer numerical value of a fully instantiated
   expression <code class="code">e</code>. Raises <code class="code">Invalid_argument</code> if <code class="code">e</code> is not instantiated.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmin_of_expr"></a>min_of_expr : <code class="type"><a href="Arith.html#TYPEt">t</a> -> int</code></pre><pre><span class="keyword">val</span> <a name="VALmax_of_expr"></a>max_of_expr : <code class="type"><a href="Arith.html#TYPEt">t</a> -> int</code></pre><div class="info">
<code class="code">min_of_expr e</code> (resp. <code class="code">max_of_expr e</code>) returns the minimal (resp. maximal)
   possible value of expression <code class="code">e</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALmin_max_of_expr"></a>min_max_of_expr : <code class="type"><a href="Arith.html#TYPEt">t</a> -> int * int</code></pre><div class="info">
<code class="code">min_max_of_expr e</code> is equivalent to <code class="code">(min_of_expr e, max_of_expr e)</code>.<br>
</div>
<br>
<a name="2_ArithmeticConstraintsonExpressions"></a>
<h2>Arithmetic Constraints on Expressions</h2><br>
<br>
FaCiLe processes arithmetic constraints to try to simplify and factorize
   common subexpressions. Furthermore, auxilliary variables are created to
   handle non-linear expressions and substituted to the original terms.
   So printing an arithmetic constraint may produce something quite
   different from the user's input.<br>
<pre><span class="keyword">val</span> <a name="VAL(<~)"></a>(<~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Cstr.html#TYPEt">Cstr.t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(<=~)"></a>(<=~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Cstr.html#TYPEt">Cstr.t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(=~)"></a>(=~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Cstr.html#TYPEt">Cstr.t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(>=~)"></a>(>=~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Cstr.html#TYPEt">Cstr.t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(>~)"></a>(>~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Cstr.html#TYPEt">Cstr.t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(<>~)"></a>(<>~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Cstr.html#TYPEt">Cstr.t</a></code></pre><div class="info">
Strictly less, less or equal, equal, greater or equal,
   strictly greater and different constraints on expressions.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALshift"></a>shift : <code class="type">Var.Fd.t -> int -> Var.Fd.t</code></pre><div class="info">
<code class="code">shift x d</code> returns a finite domain variable constrained to be
   equal to <code class="code">x+d</code>.<br>
</div>
<br>
<a name="2_Reification"></a>
<h2>Reification</h2><br>
<br>
The following operators are  shortcuts to lighten the writing of reified
   expressions. They replace the corresponding constraint by an expression
   equal to a boolean variable that is instantiated to <code class="code">1</code> when the constraint is
   satisfied and to <code class="code">0</code> if it is violated.
   See module <code class="code">Reify</code> .<br>
<pre><span class="keyword">val</span> <a name="VAL(<~~)"></a>(<~~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
<code class="code">e1 op~~ e2</code> is equivalent to <code class="code">fd2e (Reify.boolean (e1 op~ e2))</code>.<br>
</div>
<pre><span class="keyword">val</span> <a name="VAL(<=~~)"></a>(<=~~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(=~~)"></a>(=~~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(>=~~)"></a>(>=~~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(>~~)"></a>(>~~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><pre><span class="keyword">val</span> <a name="VAL(<>~~)"></a>(<>~~) : <code class="type"><a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a> -> <a href="Arith.html#TYPEt">t</a></code></pre><div class="info">
Reified strictly less, less or equal, equal, greater or equal,
   strictly greater and different.<br>
</div>
<br>
<a name="2_Booleansumssetting"></a>
<h2>Boolean sums setting</h2>
<p>

   FaCiLe tries to automatically optimize the processing of
   boolean (0-1 variables) sums whenever their sizes are large enough.<br>
<pre><span class="keyword">val</span> <a name="VALget_boolsum_threshold"></a>get_boolsum_threshold : <code class="type">unit -> int</code></pre><div class="info">
Returns the minimum size for boolean sums optimization. (Default: 5)<br>
</div>
<pre><span class="keyword">val</span> <a name="VALset_boolsum_threshold"></a>set_boolsum_threshold : <code class="type">int -> unit</code></pre><div class="info">
Set the minimum size for boolean sums optimization.
   <code class="code">boolsum_threshold max_int</code> disables it.<br>
</div>
</body></html>