The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.Nat.EvenOddRec

5 declarations. Mathlib docs · Source

def Nat.evenOddRec E1 #

{P : ℕ → Sort u_1} → P 0 → ((n : ℕ) → P n → P (2 * n)) → ((n : ℕ) → P n → P (2 * n + 1)) → (n : ℕ) → P n

Recursion principle on even and odd numbers: if we have P 0, and for all i : ℕ we can extend from P i to both P (2 * i) and P (2 * i + 1), then we have P n for all n : ℕ. This is nothing more than a wrapper around Nat.binaryRec, to avoid having to switch to dealing with bit0 and bit1.

theorem Nat.evenOddRec_zero E0 #

∀ {P : ℕ → Sort u_1} (h0 : P 0) (h_even : (i : ℕ) → P i → P (2 * i)) (h_odd : (i : ℕ) → P i → P (2 * i + 1)),
  Nat.evenOddRec h0 h_even h_odd 0 = h0

theorem Nat.evenOddRec_even E0 #

∀ {P : ℕ → Sort u_1} (h0 : P 0) (h_even : (i : ℕ) → P i → P (2 * i)) (h_odd : (i : ℕ) → P i → P (2 * i + 1)),
  h_even 0 h0 = h0 → ∀ (n : ℕ), Nat.evenOddRec h0 h_even h_odd (2 * n) = h_even n (Nat.evenOddRec h0 h_even h_odd n)

theorem Nat.evenOddRec_odd E0 #

∀ {P : ℕ → Sort u_1} (h0 : P 0) (h_even : (i : ℕ) → P i → P (2 * i)) (h_odd : (i : ℕ) → P i → P (2 * i + 1)),
  h_even 0 h0 = h0 → ∀ (n : ℕ), Nat.evenOddRec h0 h_even h_odd (2 * n + 1) = h_odd n (Nat.evenOddRec h0 h_even h_odd n)

def Nat.evenOddStrongRec E1 #

{P : ℕ → Sort u_1} →
  ((n : ℕ) → ((k : ℕ) → k < 2 * n → P k) → P (2 * n)) →
    ((n : ℕ) → ((k : ℕ) → k < 2 * n + 1 → P k) → P (2 * n + 1)) → (n : ℕ) → P n

Strong recursion principle on even and odd numbers: if for all i : ℕ we can prove P (2 * i) from P j for all j < 2 * i and we can prove P (2 * i + 1) from P j for all j < 2 * i + 1, then we have P n for all n : ℕ.