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 BinInt. Require Import Zcompare. Require Import Zorder. Require Import Znat. Require Import Zmisc. Require Import Wf_nat. Local Open Scope Z_scope.
Our purpose is to write an induction shema for {0,1,2,...}
similar to the nat schema (Theorem Natlike_rec). For that the
following implications will be used :
∀n:nat, Q n == ∀n:nat, P (Z.of_nat n) ===> ∀x:Z, x <= 0 -> P x /\ || || (Q O) ∧ (∀n:nat, Q n -> Q (S n)) <=== (P 0) ∧ (∀x:Z, P x -> P (Z.succ x)) <=== (Z.of_nat (S n) = Z.succ (Z.of_nat n)) <=== Z_of_nat_completeThen the diagram will be closed and the theorem proved.
x:Z0 <= x -> exists n : nat, x = Z.of_nat nx:Z0 <= x -> exists n : nat, x = Z.of_nat nx:ZH:0 <= xexists n : nat, x = Z.of_nat nx:ZH:0 <= xx = Z.of_nat (Z.to_nat x)now apply Z2Nat.id. Qed.x:ZH:0 <= xZ.of_nat (Z.to_nat x) = xx:Z0 <= x -> {n : nat | x = Z.of_nat n}x:Z0 <= x -> {n : nat | x = Z.of_nat n}x:ZH:0 <= x{n : nat | x = Z.of_nat n}x:ZH:0 <= xx = Z.of_nat (Z.to_nat x)now apply Z2Nat.id. Qed.x:ZH:0 <= xZ.of_nat (Z.to_nat x) = xforall P : Z -> Prop, (forall n : nat, P (Z.of_nat n)) -> forall x : Z, 0 <= x -> P xforall P : Z -> Prop, (forall n : nat, P (Z.of_nat n)) -> forall x : Z, 0 <= x -> P xnow destruct (Z_of_nat_complete x Hx) as (n,->). Qed.P:Z -> PropH:forall n : nat, P (Z.of_nat n)x:ZHx:0 <= xP xforall P : Z -> Set, (forall n : nat, P (Z.of_nat n)) -> forall x : Z, 0 <= x -> P xforall P : Z -> Set, (forall n : nat, P (Z.of_nat n)) -> forall x : Z, 0 <= x -> P xnow destruct (Z_of_nat_complete_inf x Hx) as (n,->). Qed.P:Z -> SetH:forall n : nat, P (Z.of_nat n)x:ZHx:0 <= xP xforall P : Z -> Prop, P 0 -> (forall x : Z, 0 <= x -> P x -> P (Z.succ x)) -> forall x : Z, 0 <= x -> P xforall P : Z -> Prop, P 0 -> (forall x : Z, 0 <= x -> P x -> P (Z.succ x)) -> forall x : Z, 0 <= x -> P xP:Z -> PropHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xforall n : nat, P (Z.of_nat n)P:Z -> PropHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xP (Z.of_nat 0)P:Z -> PropHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xn:natIHn:P (Z.of_nat n)P (Z.of_nat (S n))P:Z -> PropHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xn:natIHn:P (Z.of_nat n)P (Z.of_nat (S n))apply Hrec; trivial using Nat2Z.is_nonneg. Qed.P:Z -> PropHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xn:natIHn:P (Z.of_nat n)P (Z.succ (Z.of_nat n))forall P : Z -> Set, P 0 -> (forall x : Z, 0 <= x -> P x -> P (Z.succ x)) -> forall x : Z, 0 <= x -> P xforall P : Z -> Set, P 0 -> (forall x : Z, 0 <= x -> P x -> P (Z.succ x)) -> forall x : Z, 0 <= x -> P xP:Z -> SetHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xforall n : nat, P (Z.of_nat n)P:Z -> SetHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xP (Z.of_nat 0)P:Z -> SetHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xn:natIHn:P (Z.of_nat n)P (Z.of_nat (S n))P:Z -> SetHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xn:natIHn:P (Z.of_nat n)P (Z.of_nat (S n))apply Hrec; trivial using Nat2Z.is_nonneg. Qed. Section Efficient_Rec.P:Z -> SetHo:P 0Hrec:forall x0 : Z, 0 <= x0 -> P x0 -> P (Z.succ x0)x:ZHx:0 <= xn:natIHn:P (Z.of_nat n)P (Z.succ (Z.of_nat n))
natlike_rec2 is the same as natlike_rec, but with a different proof, designed
to give a better extracted term.
Let R (a b:Z) := 0 <= a /\ a < b.R:=fun a b : Z => 0 <= a < b:Z -> Z -> Propwell_founded RR:=fun a b : Z => 0 <= a < b:Z -> Z -> Propwell_founded RR:=fun a b : Z => 0 <= a < b:Z -> Z -> Propforall x y : Z, R x y -> (Z.to_nat x < Z.to_nat y)%natapply Z2Nat.inj_lt; Z.order. Qed.R:=fun a b : Z => 0 <= a < b:Z -> Z -> Propx, y:ZHx:0 <= xH:x < y(Z.to_nat x < Z.to_nat y)%natR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, P 0 -> (forall z : Z, 0 <= z -> P z -> P (Z.succ z)) -> forall z : Z, 0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, P 0 -> (forall z : Z, 0 <= z -> P z -> P (Z.succ z)) -> forall z : Z, 0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)forall z : Z, 0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z0 : Z, 0 <= z0 -> P z0 -> P (Z.succ z0)z:ZIH:forall y : Z, R y z -> 0 <= y -> P y0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)IH:forall y : Z, R y 0 -> 0 <= y -> P yHz:0 <= 0P 0R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y : Z, R y (Z.neg p) -> 0 <= y -> P yHz:0 <= Z.neg pP (Z.neg p)apply Ho.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)IH:forall y : Z, R y 0 -> 0 <= y -> P yHz:0 <= 0P 0R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hz:0 <= Z.pos py:=Z.pred (Z.pos p):ZP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hz:0 <= Z.pos py:=Z.pred (Z.pos p):ZLE:0 <= yP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hz:0 <= Z.pos py:=Z.pred (Z.pos p):ZLE:0 <= yEQ:Z.pos p = Z.succ yP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hz:0 <= Z.pos py:=Z.pred (Z.pos p):ZLE:0 <= yEQ:Z.pos p = Z.succ yP (Z.succ y)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hz:0 <= Z.pos py:=Z.pred (Z.pos p):ZLE:0 <= yEQ:Z.pos p = Z.succ yR y (Z.pos p)unfold y; apply Z.lt_pred_l.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hz:0 <= Z.pos py:=Z.pred (Z.pos p):ZLE:0 <= yEQ:Z.pos p = Z.succ yy < Z.pos pnow destruct Hz. Qed.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 <= z -> P z -> P (Z.succ z)p:positiveIH:forall y : Z, R y (Z.neg p) -> 0 <= y -> P yHz:0 <= Z.neg pP (Z.neg p)
A variant of the previous using Z.pred instead of Z.succ.
R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, P 0 -> (forall z : Z, 0 < z -> P (Z.pred z) -> P z) -> forall z : Z, 0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, P 0 -> (forall z : Z, 0 < z -> P (Z.pred z) -> P z) -> forall z : Z, 0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zforall z : Z, 0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z0 : Z, 0 < z0 -> P (Z.pred z0) -> P z0z:ZIH:forall y : Z, R y z -> 0 <= y -> P y0 <= z -> P zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zIH:forall y : Z, R y 0 -> 0 <= y -> P yHz:0 <= 0P 0R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.neg p) -> 0 <= y -> P yHz:0 <= Z.neg pP (Z.neg p)apply Ho.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zIH:forall y : Z, R y 0 -> 0 <= y -> P yHz:0 <= 0P 0R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pEQ:0 <= Z.pred (Z.pos p)P (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pEQ:0 <= Z.pred (Z.pos p)0 < Z.pos pR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pEQ:0 <= Z.pred (Z.pos p)P (Z.pred (Z.pos p))R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pEQ:0 <= Z.pred (Z.pos p)P (Z.pred (Z.pos p))R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pEQ:0 <= Z.pred (Z.pos p)R (Z.pred (Z.pos p)) (Z.pos p)apply Z.lt_pred_l.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHz:0 <= Z.pos pEQ:0 <= Z.pred (Z.pos p)Z.pred (Z.pos p) < Z.pos pnow destruct Hz. Qed.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHo:P 0Hrec:forall z : Z, 0 < z -> P (Z.pred z) -> P zp:positiveIH:forall y : Z, R y (Z.neg p) -> 0 <= y -> P yHz:0 <= Z.neg pP (Z.neg p)
A more general induction principle on non-negative numbers using Z.lt.
R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P x) -> forall x : Z, 0 <= x -> P xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P x) -> forall x : Z, 0 <= x -> P xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xforall x : Z, 0 <= x -> P xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x0 : Z, (forall y : Z, 0 <= y < x0 -> P y) -> 0 <= x0 -> P x0x:ZIH:forall y : Z, R y x -> 0 <= y -> P y0 <= x -> P xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xIH:forall y : Z, R y 0 -> 0 <= y -> P yHx:0 <= 0P 0R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHx:0 <= Z.pos pP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xp:positiveIH:forall y : Z, R y (Z.neg p) -> 0 <= y -> P yHx:0 <= Z.neg pP (Z.neg p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xIH:forall y : Z, R y 0 -> 0 <= y -> P yHx:0 <= 0P 0R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xIH:forall y : Z, R y 0 -> 0 <= y -> P yHx:0 <= 0forall y : Z, 0 <= y < 0 -> P yR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y0 : Z, 0 <= y0 < x -> P y0) -> 0 <= x -> P xIH:forall y0 : Z, R y0 0 -> 0 <= y0 -> P y0Hx:0 <= 0y:ZHy:0 <= yHy':y < 0P ydiscriminate.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y0 : Z, 0 <= y0 < x -> P y0) -> 0 <= x -> P xIH:forall y0 : Z, R y0 0 -> 0 <= y0 -> P y0Hx:0 <= 0y:ZHy:0 <= yHy':y < 0H:0 < 0P yR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHx:0 <= Z.pos pP (Z.pos p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xp:positiveIH:forall y : Z, R y (Z.pos p) -> 0 <= y -> P yHx:0 <= Z.pos pforall y : Z, 0 <= y < Z.pos p -> P yR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y0 : Z, 0 <= y0 < x -> P y0) -> 0 <= x -> P xp:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hx:0 <= Z.pos py:ZHy:0 <= yHy':y < Z.pos pP ynow split.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y0 : Z, 0 <= y0 < x -> P y0) -> 0 <= x -> P xp:positiveIH:forall y0 : Z, R y0 (Z.pos p) -> 0 <= y0 -> P y0Hx:0 <= Z.pos py:ZHy:0 <= yHy':y < Z.pos pR y (Z.pos p)now destruct Hx. Defined.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> TypeHrec:forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P xp:positiveIH:forall y : Z, R y (Z.neg p) -> 0 <= y -> P yHx:0 <= Z.neg pP (Z.neg p)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Prop, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P x) -> forall x : Z, 0 <= x -> P xintros; now apply Zlt_0_rec. Qed.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Prop, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> 0 <= x -> P x) -> forall x : Z, 0 <= x -> P x
Obsolete version of Z.lt induction principle on non-negative numbers
R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> P x) -> forall x : Z, 0 <= x -> P xintros P Hrec; apply Zlt_0_rec; auto. Qed.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Type, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> P x) -> forall x : Z, 0 <= x -> P xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Prop, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> P x) -> forall x : Z, 0 <= x -> P xintros; now apply Z_lt_rec. Qed.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall P : Z -> Prop, (forall x : Z, (forall y : Z, 0 <= y < x -> P y) -> P x) -> forall x : Z, 0 <= x -> P x
An even more general induction principle using Z.lt.
R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall (P : Z -> Type) (z : Z), (forall x : Z, (forall y : Z, z <= y < x -> P y) -> z <= x -> P x) -> forall x : Z, z <= x -> P xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall (P : Z -> Type) (z : Z), (forall x : Z, (forall y : Z, z <= y < x -> P y) -> z <= x -> P x) -> forall x : Z, z <= x -> P xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZHx:z <= xP xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZHx:z <= xP (x - z + z)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZHx:0 <= x - zP (x - z + z)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZHx:0 <= x - zforall x0 : Z, (forall y : Z, 0 <= y < x0 -> P (y + z)) -> 0 <= x0 -> P (x0 + z)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x : Z, (forall y : Z, z <= y < x -> P y) -> z <= x -> P xforall x : Z, (forall y : Z, 0 <= y < x -> P (y + z)) -> 0 <= x -> P (x + z)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xP (x + z)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xforall y : Z, z <= y < x + z -> P yR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xz <= x + zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y0 : Z, z <= y0 < x0 -> P y0) -> z <= x0 -> P x0x:ZIH:forall y0 : Z, 0 <= y0 < x -> P (y0 + z)Hx:0 <= xy:ZHy:z <= yHy':y < x + zP yR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xz <= x + zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y0 : Z, z <= y0 < x0 -> P y0) -> z <= x0 -> P x0x:ZIH:forall y0 : Z, 0 <= y0 < x -> P (y0 + z)Hx:0 <= xy:ZHy:z <= yHy':y < x + zP (y - z + z)R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xz <= x + zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y0 : Z, z <= y0 < x0 -> P y0) -> z <= x0 -> P x0x:ZIH:forall y0 : Z, 0 <= y0 < x -> P (y0 + z)Hx:0 <= xy:ZHy:z <= yHy':y < x + z0 <= y - zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y0 : Z, z <= y0 < x0 -> P y0) -> z <= x0 -> P x0x:ZIH:forall y0 : Z, 0 <= y0 < x -> P (y0 + z)Hx:0 <= xy:ZHy:z <= yHy':y < x + zy - z < xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xz <= x + zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y0 : Z, z <= y0 < x0 -> P y0) -> z <= x0 -> P x0x:ZIH:forall y0 : Z, 0 <= y0 < x -> P (y0 + z)Hx:0 <= xy:ZHy:z <= yHy':y < x + zy - z < xR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xz <= x + znow rewrite <- (Z.add_le_mono_r 0 x z). Qed.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded RP:Z -> Typez:ZHrec:forall x0 : Z, (forall y : Z, z <= y < x0 -> P y) -> z <= x0 -> P x0x:ZIH:forall y : Z, 0 <= y < x -> P (y + z)Hx:0 <= xz <= x + zR:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall (P : Z -> Prop) (z : Z), (forall x : Z, (forall y : Z, z <= y < x -> P y) -> z <= x -> P x) -> forall x : Z, z <= x -> P xintros; now apply Zlt_lower_bound_rec with z. Qed. End Efficient_Rec.R:=fun a b : Z => 0 <= a < b:Z -> Z -> PropR_wf:well_founded Rforall (P : Z -> Prop) (z : Z), (forall x : Z, (forall y : Z, z <= y < x -> P y) -> z <= x -> P x) -> forall x : Z, z <= x -> P x