AFTD Auto-Formalizing Theoretical Domains

Nat.segment_idem

theoremverifiedformalizationimported Lean

For a strictly monotonic function f : ℕ → ℕ, the segment of f k is k.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open Function Set in
variable {f : ℕ → ℕ} in
@[simp]
theorem Nat.segment_idem (hm : StrictMono f) (k : ℕ) :
    segment f (f k) = k
Formalizes
CSLib, `Nat.segment_idem`
Lean proof
By Ching-Tsun Chou, from github.com/leanprover/cslib at 3951377e5a3f (Copyright (c) 2025 Ching-Tsun Chou. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.33.0.
Verified
08 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • Nat.strictMono_infiniteAny strictly monotonic function f : ℕ → ℕ has an infinite range.
  • Nat.segmentThe f-segment of k, where f : ℕ → ℕ will be assumed to be at least StrictMono.
  • Nat.nth_of_strictMonoFor a strictly monotonic function f : ℕ → ℕ, f n is exactly the n-th element of the range of f.
Used by 8
  • Nat.segment'segment' is a helper function that will be proved to be equal to segment. It facilitates the proofs of some theorems below.
  • Nat.segment_upper_boundFor a strictly monotonic function f : ℕ → ℕ with f 0 = 0, k < f (segment f k + 1) for all k : ℕ.
  • Nat.segment_zeroFor a strictly monotonic function f : ℕ → ℕ with f 0 = 0, segment f 0 = 0.
  • Nat.segment_lower_boundFor a strictly monotonic function f : ℕ → ℕ with f 0 = 0, f (segment f k) ≤ k for all k : ℕ.
  • Nat.segment_galois_connectionFor a strictly monotonic function f : ℕ → ℕ with f 0 = 0, f and segment f form a Galois connection.
  • Nat.segment_range_valFor a strictly monotonic function f : ℕ → ℕ, all k satisfying f m ≤ k < f (m + 1) has segment f k = m.
  • Nat.segment_pre_zeroFor a strictly monotonic function f : ℕ → ℕ, segment f k = 0 for all k < f 0.
  • Nat.segment_plus_oneA slight restatement of the definition of segment which has proven useful.

Lean source view module on GitHub

set_option autoImplicit true inset_option relaxedAutoImplicit true inopen Function Set invariable {f : ℕ → ℕ} in/-- For a strictly monotonic function `f : ℕ → ℕ`, the segment of `f k` is `k`. -/@[simp]theorem Nat.segment_idem (hm : StrictMono f) (k : ℕ) :    segment f (f k) = k := by  classical  have := count_nth_of_infinite (p := (· ∈ range f)) <| strictMono_infinite hm  have := nth_of_strictMono hm  grind [segment]
See it in the graphDiscuss this resultChallenge it