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:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natwell_founded (Zwf c)c:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:Zforall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0c:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn:nata:ZH:(f a < 0)%nat \/ a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%nat \/ a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) a
n= 0
c:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn:nata:ZH:(f a < 0)%nat \/ a < cH0:(f a < 0)%natAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn:nata:ZH:(f a < 0)%nat \/ a < cH0:a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%nat \/ a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn:nata:ZH:(f a < 0)%nat \/ a < cH0:a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%nat \/ a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn:nata:ZH:(f a < 0)%nat \/ a < cH0:a < cy:ZH1:c <= a /\ y < aAcc (fun x y0 : Z => c <= y0 /\ x < y0) yc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%nat \/ a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%nat \/ a < cAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) a
inductive case
c:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%natAcc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%naty:ZH1:Zwf c y aAcc (Zwf c) yc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%naty:ZH1:Zwf c y a(f y < n0)%nat \/ y < cc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%naty:ZH1:c <= a /\ y < a(f y < n0)%nat \/ y < cc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%naty:ZH1:c <= a /\ y < aH2:c <= y(f y < n0)%nat \/ y < cc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(f a < S n0)%naty:ZH1:c <= a /\ y < aH2:c <= y(f y < n0)%natc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(S (f a) <= S n0)%naty:ZH1:c <= a /\ y < aH2:c <= y(f y < n0)%natc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(S (f a) <= S n0)%naty:ZH1:c <= a /\ y < aH2:c <= y(f y < f a)%natc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) ac:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> natn, n0:natH:forall a0 : Z, (f a0 < n0)%nat \/ a0 < c -> Acc (Zwf c) a0a:ZH0:(S (f a) <= S n0)%naty:ZH1:c <= a /\ y < aH2:c <= y(Z.abs_nat (y - c) < Z.abs_nat (a - c))%natc:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) aapply (H (S (f a))); auto. Qed. End wf_proof. Hint Resolve Zwf_well_founded: datatypes.c:Zf:=fun z : Z => Z.abs_nat (z - c):Z -> nata:ZH:forall (n : nat) (a0 : Z), (f a0 < n)%nat \/ a0 < c -> Acc (Zwf c) a0Acc (Zwf c) a
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:Zf:=fun z : Z => Z.abs_nat (c - z):Z -> natwell_founded (Zwf_up c)c:Zf:=fun z : Z => Z.abs_nat (c - z):Z -> natwell_founded (Zwf_up c)c:Zf:=fun z : Z => Z.abs_nat (c - z):Z -> natforall x y : Z, Zwf_up c x y -> (f x < f y)%natc:Zf:=fun z : Z => Z.abs_nat (c - z):Z -> natforall x y : Z, y < x <= c -> (Z.abs_nat (c - x) < Z.abs_nat (c - y))%natc:Zf:=fun z : Z => Z.abs_nat (c - z):Z -> natx, y:ZH:y < x <= c(Z.abs_nat (c - x) < Z.abs_nat (c - y))%natnow apply Z.sub_lt_mono_l. Qed. End wf_proof_up. Hint Resolve Zwf_up_well_founded: datatypes.c:Zf:=fun z : Z => Z.abs_nat (c - z):Z -> natx, y:ZH:y < x <= cc - x < c - y