Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)

Require Import ZArith_base.
Require Export Wf_nat.
Require Import Omega.
Local Open Scope Z_scope.
Well-founded relations on Z.
We define the following family of relations on Z x Z:
x (Zwf c) y iff x < y & c y
Definition Zwf (c x y:Z) := c <= y /\ x < y.
and we prove that (Zwf c) is well founded
Section wf_proof.

  Variable c : Z.
The proof of well-foundness is classic: we do the proof by induction on a measure in nat, which is here |x-c|
  Let f (z:Z) := Z.abs_nat (z - c).

  
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat

well_founded (Zwf c)
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z

Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z

forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n:nat
a:Z
H:(f a < 0)%nat \/ a < c

Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat \/ a < c
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
n= 0
    
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n:nat
a:Z
H:(f a < 0)%nat \/ a < c
H0:(f a < 0)%nat

Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n:nat
a:Z
H:(f a < 0)%nat \/ a < c
H0:a < c
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat \/ a < c
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n:nat
a:Z
H:(f a < 0)%nat \/ a < c
H0:a < c

Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat \/ a < c
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n:nat
a:Z
H:(f a < 0)%nat \/ a < c
H0:a < c
y:Z
H1:c <= a /\ y < a

Acc (fun x y0 : Z => c <= y0 /\ x < y0) y
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat \/ a < c
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat \/ a < c

Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
inductive case
    
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat

Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat
y:Z
H1:Zwf c y a

Acc (Zwf c) y
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat
y:Z
H1:Zwf c y a

(f y < n0)%nat \/ y < c
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat
y:Z
H1:c <= a /\ y < a

(f y < n0)%nat \/ y < c
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat
y:Z
H1:c <= a /\ y < a
H2:c <= y

(f y < n0)%nat \/ y < c
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(f a < S n0)%nat
y:Z
H1:c <= a /\ y < a
H2:c <= y

(f y < n0)%nat
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(S (f a) <= S n0)%nat
y:Z
H1:c <= a /\ y < a
H2:c <= y

(f y < n0)%nat
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(S (f a) <= S n0)%nat
y:Z
H1:c <= a /\ y < a
H2:c <= y

(f y < f a)%nat
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
n, n0:nat
H:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0
a:Z
H0:(S (f a) <= S n0)%nat
y:Z
H1:c <= a /\ y < a
H2:c <= y

(Z.abs_nat (y - c) < Z.abs_nat (a - c))%nat
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0
Acc (Zwf c) a
c:Z
f:=fun z : Z => Z.abs_nat (z - c):Z -> nat
a:Z
H:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0

Acc (Zwf c) a
apply (H (S (f a))); auto. Qed. End wf_proof. Hint Resolve Zwf_well_founded: datatypes.
We also define the other family of relations:
x (Zwf_up c) y iff y < x c
Definition Zwf_up (c x y:Z) := y < x <= c.
and we prove that (Zwf_up c) is well founded
Section wf_proof_up.

  Variable c : Z.
The proof of well-foundness is classic: we do the proof by induction on a measure in nat, which is here |c-x|
  Let f (z:Z) := Z.abs_nat (c - z).

  
c:Z
f:=fun z : Z => Z.abs_nat (c - z):Z -> nat

well_founded (Zwf_up c)
c:Z
f:=fun z : Z => Z.abs_nat (c - z):Z -> nat

well_founded (Zwf_up c)
c:Z
f:=fun z : Z => Z.abs_nat (c - z):Z -> nat

forall x y : Z, Zwf_up c x y -> (f x < f y)%nat
c:Z
f:=fun z : Z => Z.abs_nat (c - z):Z -> nat

forall x y : Z, y < x <= c -> (Z.abs_nat (c - x) < Z.abs_nat (c - y))%nat
c:Z
f:=fun z : Z => Z.abs_nat (c - z):Z -> nat
x, y:Z
H:y < x <= c

(Z.abs_nat (c - x) < Z.abs_nat (c - y))%nat
c:Z
f:=fun z : Z => Z.abs_nat (c - z):Z -> nat
x, y:Z
H:y < x <= c

c - x < c - y
now apply Z.sub_lt_mono_l. Qed. End wf_proof_up. Hint Resolve Zwf_up_well_founded: datatypes.