AFTD Auto-Formalizing Theoretical Domains

arrival_nat_ceil_of_dist_lt_one

theoremverified

For any natural number u and real number x such that x ≤ u and (u : ℝ) - x < 1, u equals Nat.ceil x.

Statement

theorem arrival_nat_ceil_of_dist_lt_one (u : ℕ) (x : ℝ) (h1 : x ≤ u) (h2 : (u : ℝ) - x < 1) :
    u = Nat.ceil x
Source
folklore
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

Read back from the Lean

For every natural number $u$ and every real number $x$, if $x \le u$ (with $u$ cast to $\mathbb{R}$) and $u - x < 1$, then $u = \lceil x \rceil_+$ (that is, $u$ equals Nat.ceil x, the ceiling of $x$ as a natural number).

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The proof splits into cases on whether u = 0 or u > 0. When u = 0, the hypothesis x ≤ 0 forces ⌈x⌉₊ = 0 = u. When u > 0, the hypothesis x ≤ u immediately yields ⌈x⌉₊ ≤ u, while the condition u - x < 1 rearranges to u - 1 < x. Casting u - 1 to ℝ gives u - 1 < ⌈x⌉₊, which implies u ≤ ⌈x⌉₊, and the two inequalities together establish u = ⌈x⌉₊.

  1. When u = 0, the ceiling ⌈x⌉₊ equals 0, so u = ⌈x⌉₊.

    We split on whether u = 0 or u > 0 (Nat.eq_zero_or_pos). In the case u = 0, the hypothesis x ≤ u becomes x ≤ 0. By the ceiling upper bound equivalence (Nat.ceil_le), this implies ⌈x⌉₊ ≤ 0. Since ⌈x⌉₊ is a natural number and thus at least 0 (Nat.zero_le), antisymmetry of ≤ (le_antisymm) forces ⌈x⌉₊ = 0. Simplifying with this equality closes the u = 0 case.

    lines 4–11

    uses Nat.eq_zero_or_pos, Nat.ceil_le, Nat.zero_le, le_antisymm

      rcases Nat.eq_zero_or_pos u with hu | hu
      · subst hu
        have hx0 : x ≤ 0 := by simpa using h1
        have hc0 : Nat.ceil x ≤ 0 := by
          rw [Nat.ceil_le]; simpa using hx0
        have hcge : 0 ≤ Nat.ceil x := Nat.zero_le _
        have hzero : Nat.ceil x = 0 := le_antisymm hc0 hcge
        simp [hzero]
  2. The ceiling ⌈x⌉₊ is at most u.

    In the case u > 0, rewriting the goal with the characteristic property of the natural ceiling (Nat.ceil_le), which states ⌈x⌉₊ ≤ u ↔ x ≤ u, reduces the claim directly to the hypothesis x ≤ u.

    lines 12–13

    uses Nat.ceil_le

      · have hle : Nat.ceil x ≤ u := by
          rw [Nat.ceil_le]; exact h1
  3. As a real number, the predecessor of u is strictly less than x: ((u - 1 : ℕ) : ℝ) < x.

    From u - x < 1, linear real arithmetic (linarith) gives u - 1 < x. Because u > 0, we have u ≠ 0 (Nat.pos_iff_ne_zero.mp), which implies 1 ≤ u (Nat.one_le_iff_ne_zero.mpr). This allows casting the natural number subtraction to ℝ (Nat.cast_sub), showing that ((u - 1 : ℕ) : ℝ) = (u : ℝ) - 1. Substituting this equality into u - 1 < x yields ((u - 1 : ℕ) : ℝ) < x.

    lines 14–18

    uses Nat.cast_sub, Nat.one_le_iff_ne_zero.mpr, Nat.pos_iff_ne_zero.mp

        have hlt : (u : ℝ) - 1 < x := by linarith
        have hcast : ((u - 1 : ℕ) : ℝ) = (u : ℝ) - 1 := by
          rw [Nat.cast_sub (Nat.one_le_iff_ne_zero.mpr (Nat.pos_iff_ne_zero.mp hu))]
          norm_num
        have hlt' : ((u - 1 : ℕ) : ℝ) < x := by rw [hcast]; exact hlt
  4. u ≤ ⌈x⌉₊.

    Since ((u - 1 : ℕ) : ℝ) < x, the ceiling strict inequality equivalence (Nat.lt_ceil) implies u - 1 < ⌈x⌉₊. Linear integer arithmetic (omega) then deduces that u ≤ ⌈x⌉₊.

    lines 19–21

    uses Nat.lt_ceil

        have hge : u ≤ Nat.ceil x := by
          have h1' : u - 1 < Nat.ceil x := (Nat.lt_ceil).mpr hlt'
          omega
  5. u = ⌈x⌉₊.

    Having established both ⌈x⌉₊ ≤ u and u ≤ ⌈x⌉₊, linear integer arithmetic (omega) concludes that u = ⌈x⌉₊.

    line 22

        omega
Nat.eq_zero_or_pos
Every natural number is either 0 or strictly positive.
Nat.ceil_le
For any real number a and natural number n, ⌈a⌉₊ ≤ n if and only if a ≤ n.
Nat.zero_le
Every natural number is greater than or equal to 0.
le_antisymm
If a ≤ b and b ≤ a in a partial order, then a = b.
Nat.cast_sub
For natural numbers m ≤ n, the cast of their difference into an additive group with one equals the difference of their casts: ↑(n - m) = ↑n - ↑m.
Nat.one_le_iff_ne_zero.mpr
If a natural number is non-zero, then 1 ≤ n.
Nat.pos_iff_ne_zero.mp
If a natural number is strictly positive (0 < n), then n ≠ 0.
Nat.lt_ceil
For a natural number n and real number a, n < ⌈a⌉₊ if and only if n < a.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

/-- An integer u with x <= u and u - x < 1 equals the ceiling of x. -/theorem arrival_nat_ceil_of_dist_lt_one (u : ℕ) (x : ℝ) (h1 : x ≤ u) (h2 : (u : ℝ) - x < 1) :    u = Nat.ceil x := by  rcases Nat.eq_zero_or_pos u with hu | hu  · subst hu    have hx0 : x ≤ 0 := by simpa using h1    have hc0 : Nat.ceil x ≤ 0 := by      rw [Nat.ceil_le]; simpa using hx0    have hcge : 0 ≤ Nat.ceil x := Nat.zero_le _    have hzero : Nat.ceil x = 0 := le_antisymm hc0 hcge    simp [hzero]  · have hle : Nat.ceil x ≤ u := by      rw [Nat.ceil_le]; exact h1    have hlt : (u : ℝ) - 1 < x := by linarith    have hcast : ((u - 1 : ℕ) : ℝ) = (u : ℝ) - 1 := by      rw [Nat.cast_sub (Nat.one_le_iff_ne_zero.mpr (Nat.pos_iff_ne_zero.mp hu))]      norm_num    have hlt' : ((u - 1 : ℕ) : ℝ) < x := by rw [hcast]; exact hlt    have hge : u ≤ Nat.ceil x := by      have h1' : u - 1 < Nat.ceil x := (Nat.lt_ceil).mpr hlt'      omega    omega
See it in the graphDiscuss this resultChallenge it