(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(****************************************************************************)
(*                                                                          *)
(*  Proof of the three gap theorem.                                         *)
(*                                                                          *)
(*  Micaela Mayero (INRIA-Rocquencourt)                                     *)
(*  September 1998                                                          *)
(*                                                                          *)
(****************************************************************************)
(****************************************************************************)
(*                               tools.v                                    *)
(****************************************************************************)
(*********************************************************)
(*            Tools for The three gap theorem            *)
(*                                                       *)
(*********************************************************)
Require Export Reals.
Require Export Nat_compl.
Unset Standard Proposition Elimination Names.
Parameter alpha : R.
(*********************************************************)
(*********************************************************)
(*           first and last                              *)
(*********************************************************)
(**********)
Definition frac_part_n_alpha (n : nat) : R := frac_part (INR n * alpha).
(**********)
Definition ordre_total (n m : nat) :=
(0 < alpha)%R /\ (alpha < 1)%R ->
(frac_part_n_alpha n <= frac_part_n_alpha m)%R.
simple induction N; auto with arith real.
intros; elim H; intro y.
elim y; intro y0.
left; right; auto with arith real.
right; rewrite <- y0; auto with arith real.
right; auto with arith real.
Qed.
intro; unfold ordre_total in |- *; intro; unfold Rle in |- *; right;
auto with arith real.
Qed.
simple induction N; intro.
absurd (0 >= 2).
inversion H.
auto with arith real.
intro X; case (N_classic n); intro.
elim s; intro y.
rewrite y; intro; absurd (1 >= 2); inversion H; inversion H1;
auto with arith real.
rewrite y; intro; exists 1; split; auto with arith real.
split; auto with arith real.
intros; replace m with 1.
apply tech_total_order.
apply sym_equal; elim H0; intro.
inversion H1; auto with arith real.
intros.
elim (X g); intros.
cut
({(frac_part_n_alpha x <= frac_part_n_alpha n)%R} +
{~ (frac_part_n_alpha x <= frac_part_n_alpha n)%R}).
intro X0; elim X0; intro.
exists x; split.
elim p; intros; auto with arith real.
split.
elim p; intros.
elim H1; intros; auto with arith real.
intros; elim p; intros; elim H2; intros; cut (0 < m /\ m < n \/ m = n).
intro; elim H5; intro.
elim (H4 m H6); auto with arith real.
apply prop_alpha.
rewrite H6; unfold ordre_total in |- *; intro; auto with arith real.
elim H0; intros; cut (0 < m /\ m < n \/ 0 < m /\ m = n).
intro; elim H7; intros.
left; auto with arith real.
elim H8; intros; right; auto with arith real.
cut (0 < m /\ (m < n \/ m = n)).
intro; elim H7; intros; elim H9; intro.
left; auto with arith real.
right; auto with arith real.
split; auto with arith real.
unfold lt in H6; inversion H6; auto with arith real.
exists n; split; auto with arith real.
split; auto with arith real.
intros; cut (0 < m /\ m < n \/ m = n).
intro; elim H1.
intro; elim p; intros; elim H4; intros; unfold ordre_total in |- *; intro.
cut (frac_part_n_alpha x <= frac_part_n_alpha m)%R.
cut (frac_part_n_alpha x > frac_part_n_alpha n)%R.
intros; unfold Rgt in H8; cut (frac_part_n_alpha n < frac_part_n_alpha m)%R.
intro; apply (Rlt_le (frac_part_n_alpha n) (frac_part_n_alpha m) H10).
apply
(Rlt_le_trans (frac_part_n_alpha n) (frac_part_n_alpha x)
(frac_part_n_alpha m) H8 H9).
apply (Rnot_le_lt (frac_part_n_alpha x) (frac_part_n_alpha n) b).
elim (H6 m H2).
intro; apply (Rlt_le (frac_part_n_alpha x) (frac_part_n_alpha m) H8).
intro; rewrite H8; unfold Rle in |- *; right; auto with arith real.
apply prop_alpha.
intro; rewrite H2; apply tech_total_order.
elim H0; intros.
cut (0 < m /\ m < n \/ 0 < m /\ m = n).
intro; elim H3; intro.
left; auto with arith real.
elim H4; intros.
right; auto with arith real.
cut (0 < m /\ (m < n \/ m = n)).
intro; elim H3; intros.
elim H5; intro.
left; auto with arith real.
right; auto with arith real.
split; auto with arith real.
unfold lt in H2; inversion H2; auto with arith real.
apply (Rle_dec (frac_part_n_alpha x) (frac_part_n_alpha n)).
Qed.

(**********)
Lemma exist_last :
forall N : nat,
N >= 2 ->
sigT
(fun n : nat =>
0 < n /\ n < N /\ (forall m : nat, 0 < m /\ m < N -> ordre_total m n)).