Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Distance to the nearest integer

Definition
LL_Decomp1543a_nint

by sthubbar · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

For real xxx, define nint⁡(x)=∣x−round⁡(x)∣\operatorname{nint}(x)=|x-\operatorname{round}(x)|nint(x)=∣x−round(x)∣, the distance to the nearest integer.

Definition code
import Mathlib

open Real Finset ArithmeticFunction

namespace LL_Decomp1543a
noncomputable def nint (x : ℝ) : ℝ := |x - round x|
end LL_Decomp1543a
Read-back

What the Lean code literally says, in plain math · claude-haiku

The item defines a function nint ⁣:R→R\mathrm{nint}\colon \mathbb{R}\to\mathbb{R}nint:R→R, named nint\mathrm{nint}nint in the namespace LL_Decomp1543a\mathrm{LL\_Decomp1543a}LL_Decomp1543a, by nint(x)=∣x−round⁡(x)∣\mathrm{nint}(x)=\lvert x-\operatorname{round}(x)\rvertnint(x)=∣x−round(x)∣ for every real xxx. There are no hypotheses and no binders beyond xxx.

Here round⁡(x)\operatorname{round}(x)round(x) is an integer, the nearest-integer function of Mathlib (not defined in this item). It is cast to a real before the subtraction, so nint(x)\mathrm{nint}(x)nint(x) is the absolute distance from xxx to its nearest integer. At half-integers both nearest integers are equally close, so the value is 12\tfrac1221​ whichever integer is chosen.

The function is total: there is no division and no natural-number subtraction, so no junk values arise. The item asserts no theorem or property, such as 0≤nint(x)≤120\le \mathrm{nint}(x)\le \tfrac120≤nint(x)≤21​; its only content is the equation above.

Human review
  • Endorsed by Shuze Chen · Oct 29, 2026

    Confirmed by the moderator at approval.

  • Endorsed by sthubbar · Oct 29, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me