assert (forall (n:nat) (a:Z), (f a < n)%nat \/ a < c -> Acc (Zwf c) a). {
clear a; simple induction n; intros.
- (** n= 0 *)
case H; intros.
+ lia.
+ apply Acc_intro; unfold Zwf; intros.
lia.
- (** inductive case *)
case H0; clear H0; intro; auto.
apply Acc_intro; intros.
apply H.
unfold Zwf in H1.
case (Z.le_gt_cases c y); intro. 2: lia.
left.
apply Nat.lt_le_trans with (f a); auto with arith.
unfold f.
lia.
}
apply (H (S (f a))); auto.
Qed.
End wf_proof.
#[global]
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).

(* Specifications: *)
Lemma Zwf_up_well_founded : well_founded (Zwf_up c).
End wf_proof_up.