1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(* $Id: Zwf.v 9245 2006-10-17 12:53:34Z notin $ *)
11
Require Import ZArith_base.
12
Require Export Wf_nat.
14
Open Local Scope Z_scope.
16
(** Well-founded relations on Z. *)
18
(** We define the following family of relations on [Z x Z]:
20
[x (Zwf c) y] iff [x < y & c <= y]
23
Definition Zwf (c x y:Z) := c <= y /\ x < y.
25
(** and we prove that [(Zwf c)] is well founded *)
31
(** The proof of well-foundness is classic: we do the proof by induction
32
on a measure in nat, which is here [|x-c|] *)
34
Let f (z:Z) := Zabs_nat (z - c).
36
Lemma Zwf_well_founded : well_founded (Zwf c).
38
assert (forall (n:nat) (a:Z), (f a < n)%nat \/ a < c -> Acc (Zwf c) a).
39
clear a; simple induction n; intros.
42
case (lt_n_O (f a)); auto.
43
apply Acc_intro; unfold Zwf in |- *; intros.
44
assert False; omega || contradiction.
46
case H0; clear H0; intro; auto.
47
apply Acc_intro; intros.
50
case (Zle_or_lt c y); intro; auto with zarith.
53
apply lt_le_trans with (f a); auto with arith.
55
apply Zabs.Zabs_nat_lt; omega.
56
apply (H (S (f a))); auto.
61
Hint Resolve Zwf_well_founded: datatypes v62.
64
(** We also define the other family of relations:
66
[x (Zwf_up c) y] iff [y < x <= c]
69
Definition Zwf_up (c x y:Z) := y < x <= c.
71
(** and we prove that [(Zwf_up c)] is well founded *)
77
(** The proof of well-foundness is classic: we do the proof by induction
78
on a measure in nat, which is here [|c-x|] *)
80
Let f (z:Z) := Zabs_nat (c - z).
82
Lemma Zwf_up_well_founded : well_founded (Zwf_up c).
84
apply well_founded_lt_compat with (f := f).
85
unfold Zwf_up, f in |- *.
87
apply Zabs.Zabs_nat_lt.
88
unfold Zminus in |- *. split.
89
apply Zle_left; intuition.
90
apply Zplus_lt_compat_l; unfold Zlt in |- *; rewrite <- Zcompare_opp;
96
Hint Resolve Zwf_up_well_founded: datatypes v62.