This library provides vernacular files containing tactics for simplifying the proofs of inequalities on expressions of real numbers for the Coq proof assistant.

This package is free software; you can redistribute it and/or modify it
under the terms of CeCILL-C Free Software License
(see the `COPYING`

file in the archive).

If you are managing your Coq installation using OPAM, you can install the library using the following command:

opam install --jobs=2 coq-interval

Note that the `coq-interval`

package is hosted in the OPAM
repository dedicated
to Coq libraries.
So you have to type the following command beforehand, if your OPAM
installation does not yet know about this repository.

opam repo add coq-released https://coq.inria.fr/opam/released

- version 3.4.0 (Coq 8.7 & 8.8, Flocq 3.0, MathComp 1.6, Coquelicot 3.0),
- version 3.3.0 (Coq 8.5 to 8.8, Flocq 2.5, MathComp 1.6, Coquelicot 3.0),
- version 3.2.0 (Coq 8.5 & 8.6, Flocq 2.5, MathComp 1.6, Coquelicot 3.0),
- version 3.1.1 (Coq 8.5 & 8.6, Flocq 2.5, MathComp 1.6, Coquelicot),
- version 2.2.0 (Coq 8.4, Flocq 2.5, MathComp 1.5, Coquelicot),
- version 2.1.0 (Coq 8.4, Flocq 2.5, MathComp 1.5).

In addition to the Coq proof assistant, you need the following libraries:

- Mathematical Components,
- Flocq,
- Coquelicot,
- BigNums (for Coq >= 8.7).

This library is hosted on the Inria Forge server. It was mainly developed by Guillaume Melquiond.

Ideally, you should just have to type:

./configure && ./remake --jobs=2 && ./remake install

The environment variable `COQC`

can be passed to the
configure script in order to set the Coq compiler command. The configure
script defaults to `coqc`

. Similarly, `COQDEP`

can
be used to specify the location of `coqdep`

. The
`COQBIN`

environment variable can be used to set both
variables at once.

Option `--libdir=DIR`

sets the directory where the compiled
library files should be installed by `./remake install`

. By
default, the target directory is ```
`$COQC
-where`/user-contrib/Interval
```

.

The files are compiled at a logical location starting with
`Interval`

.

In order to use the tactics of the library, one has to import the
`Interval_tactic`

file into a Coq proof script. The main
tactic is named `interval`

.

The tactic can be applied on a goal of the form ```
(c1 <= e
<= c2)%R
```

with `e`

an expression involving
real-valued operators. Sub-expressions that are not recognized by the
tactic should be either terms `t`

appearing in hypothesis
inequalities `(c3 <= t <= c4)%R`

or simple integers. The
bounds `c1`

`c2`

... are expressions that contain
only constant leaves, e.g. `(5 / sqrt (1 + PI))%R`

.

The complete list of recognized goals is as follows:

`(c1 <= e <= c2)%R`

`(e <= c2)%R`

`(c1 <= e)%R`

`(0 < e)%R`

`(e <> 0)%R`

`(Rabs e <= c2)%R`

, handled as`(-c2 <= e <= c2)%R`

`(e1 <= e2)%R`

, handled as`(e1 - e2 <= 0)%R`

`(e1 < e2)%R`

, handled as`(0 < e2 - e1)%R`

`(e1 <> e2)%R`

, handled as`(e1 - e2 <> 0)%R`

Operators recognized by the tactic are: `PI`

, `Ropp`

,
`Rabs`

, `Rinv`

, `Rsqr`

, `sqrt`

,
`cos`

, `sin`

, `tan`

, `atan`

,
`exp`

, `ln`

, `pow`

, `powerRZ`

,
`Rplus`

, `Rminus`

, `Rmult`

, `Rdiv`

.
Operators `Zfloor`

, `Zceil`

, `Ztrunc`

,
`ZnearestE`

(composed with `IZR`

) are also
recognized. There are some restrictions on the domain of a few
functions: `pow`

and `powerRZ`

should be written
with a numeric exponent; the input of `cos`

and `sin`

should be between `-2*PI`

and `2*PI`

; the input of `tan`

should be between
`-PI/2`

and `PI/2`

.

The tactic also recognizes integral expressions `RInt`

whose bounds are constants and whose integrand is an expression
containing only constant leaves except for the integration variable. Some
improper integral expressions RInt_gen are also supported with
bounds `(at_right 0) (at_point _)`

or ```
(at_point _)
(Rbar_locally p_infty)
```

. The integrand should be of the
form `(fun t => f t * g t)`

with `g`

one of the
following expressions:

`exp (- (_ * t))`

`powerRZ t _ * (ln t) ^ _`

`/ (t * (ln t) ^ _)`

A helper tactic `interval_intro e`

is also available. Instead
of proving the current goal, it computes an enclosure of the expression
`e`

passed as argument and it introduces the inequalities into the
proof context. If only one bound is needed, the keywords `lower`

and `upper`

can be passed to the tactic, so that it does not
perform useless computations. For example, `interval_intro e lower`

introduces only a floating-point lower bound of `e`

in the
context. Unless one uses `as`

followed by an intro pattern, the
`interval_intro`

tactic generates a fresh name for the
hypothesis added to the context.

The behavior of the tactics can be tuned by adding an optional set of
parameters `with (param1, param2, ...)`

at the end of the tactics.
These parameters are parsed from left to right: If some parameters are
conflicting, the earlier ones are discarded. Available parameter classes are:
(with the type of their arguments, if any)

`i_prec (p:nat)`

sets precision of the floating-point computations;`i_depth (n:nat)`

sets bisection depth (2^{n}sub-intervals at most);`i_bisect (x:R)`

splits input interval on`x`

and repeat until proven;`i_bisect_diff (x:R)`

, same as`i_bisect`

, but studies variations along`x`

too;`i_bisect_taylor (x:R) (d:nat)`

, same as`i_bisect_diff`

, but computes degree-`d`

Taylor models instead of performing automatic differentiation;`i_integral_prec (p:nat)`

sets the target relative accuracy of integral expressions to approximately`p`

bits;`i_integral_width (p:Z)`

sets the target accuracy of integral expressions to an interval width of 2^{p};`i_integral_depth (n:nat)`

sets the bisection depth for bounding integral expressions (2^{n}sub-intervals at most);`i_integral_deg (d:nat)`

sets the degree of Taylor models for approximating the integrand when bounding integral expressions;`i_native_compute`

uses`native_compute`

instead of`vm_compute`

;`i_delay`

delays proof checking till`Qed`

, especially useful when experimenting with`interval_intro`

.

For both tactics, performing a bisection of depth 1 is not much slower
than performing no bisection. If the current goal can be proven by
`interval`

with a bisection of depth n, then increasing the
depth to n + 1 will not have any noticeable effect. For
`interval_intro`

, increasing the depth from n to n + 1 can,
however, double the computation time.

Performing an `i_bisect_diff`

bisection has a much higher cost per
sub-interval, but it can considerably reduce the amount of sub-intervals
considered. As a consequence, unless there is a huge amount of trivial
propositions to prove, one should use this improved bisection.

If the proof process is still too slow, the `i_bisect_taylor`

bisection can be tried instead, as it usually reduces the number of
sub-intervals much further. In some corner cases though, it will not be able
to prove properties for which `i_bisect_diff`

would have
succeeded.

By default, the precision of the floating-point computations is 30
bits. If the user enables a bisection, the default depth is 15
for `interval`

and 5 for `interval_intro`

. When
bounding integral expressions, the tactics target 10 bits of accuracy by
splitting the domain into 2^{3} subdomains at most and by using
degree-10 Taylor models.

(** BEGIN **) Require Import Reals. Require Import Interval.Interval_tactic. Open Scope R_scope. Goal forall x, -1 <= x <= 1 -> sqrt (1 - x) <= 3/2. Proof. intros. interval. Qed. Goal forall x, -1 <= x <= 1 -> sqrt (1 - x) <= 141422/100000. Proof. intros. interval. Qed. Goal forall x, -1 <= x <= 1 -> sqrt (1 - x) <= 141422/100000. Proof. intros. interval_intro (sqrt (1 - x)) upper as H'. apply Rle_trans with (1 := H'). interval. Qed. Goal forall x, 3/2 <= x <= 2 -> forall y, 1 <= y <= 33/32 -> Rabs (sqrt(1 + x/sqrt(x+y)) - 144/1000*x - 118/100) <= 71/32768. Proof. intros. interval with (i_prec 19, i_bisect x). Qed. Goal forall x, 1/2 <= x <= 2 -> Rabs (sqrt x - (((((122 / 7397 * x + (-1733) / 13547) * x + 529 / 1274) * x + (-767) / 999) * x + 407 / 334) * x + 227 / 925)) <= 5/65536. Proof. intros. interval with (i_bisect_taylor x 3). Qed. Goal forall x, -1 <= x -> x < 1 + powerRZ x 3. Proof. intros. interval with (i_bisect_diff x). Qed. Require Import Coquelicot.Coquelicot. Goal Rabs (RInt (fun x => atan (sqrt (x*x + 2)) / (sqrt (x*x + 2) * (x*x + 1))) 0 1 - 5/96*PI*PI) <= 1/1000. Proof. interval with (i_integral_prec 9, i_integral_depth 1, i_integral_deg 5). Qed. Goal RInt_gen (fun x => 1 * (powerRZ x 3 * ln x^2)) (at_right 0) (at_point 1) = 1/32. Proof. refine ((fun H => Rle_antisym _ _ (proj2 H) (proj1 H)) _). interval. Qed. Goal Rabs (RInt_gen (fun t => 1/sqrt t * exp (-(1*t))) (at_point 1) (Rbar_locally p_infty) - 2788/10000) <= 1/1000. Proof. interval. Qed. (*** END ***)