Skip to main content

Challenge 34: If P holds infinitely often, there is an extraction along which it always holds

Let \(P\) be a property of the natural numbers that holds for arbitrarily large numbers; that is, \[ \forall N, \exists n > N, P(n) \]

Prove that there exists an extraction function (that is, a strictly increasing function \(\varphi : \mathbb{N} \to \mathbb{N}\)) along which \(P\) always holds; that is, \[ \forall n, P(\varphi(n)) \]

To do so, complete the following theory in Lean 4:

import Mathlib.Basic.Real.Basic

open Function

def IsExtraction (φ : ℕ → ℕ) : Prop :=
  StrictMono φ

variable (P : ℕ → Prop)

example
  (h : ∀ N, ∃ n > N, P n)
  : ∃ φ : ℕ → ℕ, IsExtraction φ ∧ ∀ n, P (φ n) :=
by sorry

I recommend that you try to solve the challenge on your own in Lean 4 Web before looking at the solutions. Once you have tried, expand the “Proposed solutions” section to compare your approach with the proofs you will find there.

Have you found a different proof? Share it in the comments, inside a Lean code block (using ```lean ... ```), to enrich the challenge!

Proposed solutions

1. Proof in natural language

By hypothesis, for each \(N\) there exists an \(n > N\) satisfying \(P\). Choosing one such \(n\) for each \(N\), we obtain a function \[ \tau : \mathbb{N} \to \mathbb{N} \] with two properties: \[ \forall n, \tau(n) > n \tag{1} \] \[ \forall n, P(\tau(n)) \tag{2} \]

We define \[ \varphi(n) = \tau^n(\tau(0)), \] where \(\tau^n\) denotes the composition of \(\tau\) with itself \(n\) times; that is, \[ \begin{array}{ll} \varphi(0) &= \tau(0), \\ \varphi(1) &= \tau(\tau(0)), \\ \varphi(2) &= \tau(\tau(\tau(0))), \\ \end{array} \] and so on. (We start from \(\tau(0)\) rather than from \(0\) because \(P(0)\) might not hold.)

Let us check that \(\varphi\) satisfies the requirements.

(a) \(\varphi\) is an extraction function, by the lemma of Challenge 33 (applied to \(\tau\), with initial value \(\tau(0)\)) and (1).

(b) \(P(\varphi(n))\) holds for every \(n\). Let \(n\) be an arbitrary natural number. Then, \[ \varphi(n) = \tau(\tau^n(0)) \tag{3} \] since \[ \begin{array}{ll} \varphi(n) &= \tau^n(\tau(0)) \\ &= \tau^{n+1}(0) \\ &= \tau(\tau^n(0)) \\ \end{array} \] By (2), we have \[ P(\tau(\tau^n(0))) \tag{4} \] Hence, by (4) and (3), we have \[ P(\varphi(n)). \]

2. Proofs in Lean 4

import Mathlib.Basic.Real.Basic

open Function

variable (P : ℕ → Prop)

-- Results from previous challenges
-- ================================

def IsExtraction (φ : ℕ → ℕ) : Prop :=
  StrictMono φ

lemma isExtraction_of_Iterate -- Challenge 33
  (φ : ℕ → ℕ)
  (hφ : ∀ n, n < φ n)
  (n₀ : ℕ)
  : IsExtraction (fun n ↦ φ^[n] n₀) :=
by
  apply strictMono_nat_of_lt_succ
  -- ⊢ ∀ (n : ℕ), φ^[n] n₀ < φ^[n + 1] n₀
  intro n
  -- n : ℕ
  -- ⊢ φ^[n] n₀ < φ^[n + 1] n₀
  simpa [Function.iterate_succ_apply'] using hφ (φ^[n] n₀)

-- Proof 1
-- =======

example
  (h : ∀ N, ∃ n > N, P n)
  : ∃ φ : ℕ → ℕ, IsExtraction φ ∧ ∀ n, P (φ n) :=
by
  choose τ hτBnd hτP using h
  -- τ : ℕ → ℕ
  -- hτBnd : ∀ (N : ℕ), τ N > N
  -- hτP : ∀ (N : ℕ), P (τ N)
  let φ := fun n ↦ τ^[n] (τ 0)
  use φ
  -- ⊢ IsExtraction φ ∧ ∀ (n : ℕ), P (φ n)
  constructor
  · -- ⊢ IsExtraction φ
    apply isExtraction_of_Iterate τ hτBnd (τ 0)
  · -- ⊢ ∀ (n : ℕ), P (φ n)
    intro n
    -- n : ℕ
    -- ⊢ P (φ n)
    have h1 : φ n = τ (τ^[n] 0) := by
      calc φ n
           = τ^[n] (τ 0) := rfl
         _ = τ^[n + 1] 0 := (iterate_succ_apply τ n 0).symm
         _ = τ (τ^[n] 0) := iterate_succ_apply' τ n 0
    rw [h1]
    -- ⊢ P (τ (τ^[n] 0))
    exact hτP (τ^[n] 0)

-- Proof 2
-- =======

theorem exists_extraction_of_frequently
  (h : ∀ N, ∃ n > N, P n)
  : ∃ φ : ℕ → ℕ, IsExtraction φ ∧ ∀ n, P (φ n) :=
by
  choose τ hτBnd hτP using h
  -- τ : ℕ → ℕ
  -- hτBnd : ∀ (N : ℕ), τ N > N
  -- hτP : ∀ (N : ℕ), P (τ N)
  refine ⟨fun n ↦ τ^[n] (τ 0), isExtraction_of_Iterate τ hτBnd (τ 0), ?_⟩
  -- ⊢ ∀ (n : ℕ), P ((fun n => τ^[n] (τ 0)) n)
  intro n
  -- n : ℕ
  -- ⊢ P ((fun n => τ^[n] (τ 0)) n)
  show P (τ^[n + 1] 0)
  rw [Function.iterate_succ_apply']
  -- ⊢ P (τ (τ^[n] 0))
  exact hτP (τ^[n] 0)

You can inspect, modify and run the code of these proofs interactively in Lean 4 Web.

Comments