Metamath Proof Explorer


Theorem dnizeq0

Description: The distance to nearest integer is zero for integers. (Contributed by Asger C. Ipsen, 15-Jun-2021)

Ref Expression
Hypotheses dnizeq0.t 𝑇 = ( 𝑥 ∈ ℝ ↦ ( abs ‘ ( ( ⌊ ‘ ( 𝑥 + ( 1 / 2 ) ) ) − 𝑥 ) ) )
dnizeq0.1 ( 𝜑𝐴 ∈ ℤ )
Assertion dnizeq0 ( 𝜑 → ( 𝑇𝐴 ) = 0 )

Proof

Step Hyp Ref Expression
1 dnizeq0.t 𝑇 = ( 𝑥 ∈ ℝ ↦ ( abs ‘ ( ( ⌊ ‘ ( 𝑥 + ( 1 / 2 ) ) ) − 𝑥 ) ) )
2 dnizeq0.1 ( 𝜑𝐴 ∈ ℤ )
3 2 zred ( 𝜑𝐴 ∈ ℝ )
4 1 dnival ( 𝐴 ∈ ℝ → ( 𝑇𝐴 ) = ( abs ‘ ( ( ⌊ ‘ ( 𝐴 + ( 1 / 2 ) ) ) − 𝐴 ) ) )
5 3 4 syl ( 𝜑 → ( 𝑇𝐴 ) = ( abs ‘ ( ( ⌊ ‘ ( 𝐴 + ( 1 / 2 ) ) ) − 𝐴 ) ) )
6 halfre ( 1 / 2 ) ∈ ℝ
7 6 a1i ( 𝜑 → ( 1 / 2 ) ∈ ℝ )
8 2 7 jca ( 𝜑 → ( 𝐴 ∈ ℤ ∧ ( 1 / 2 ) ∈ ℝ ) )
9 flzadd ( ( 𝐴 ∈ ℤ ∧ ( 1 / 2 ) ∈ ℝ ) → ( ⌊ ‘ ( 𝐴 + ( 1 / 2 ) ) ) = ( 𝐴 + ( ⌊ ‘ ( 1 / 2 ) ) ) )
10 8 9 syl ( 𝜑 → ( ⌊ ‘ ( 𝐴 + ( 1 / 2 ) ) ) = ( 𝐴 + ( ⌊ ‘ ( 1 / 2 ) ) ) )
11 6 rexri ( 1 / 2 ) ∈ ℝ*
12 0re 0 ∈ ℝ
13 halfgt0 0 < ( 1 / 2 )
14 12 6 13 ltleii 0 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