taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.4-3

Exercise 1.2.4-3

proved in Lean solution written

RatingM10
MarkersM (mathematical)
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.4 of Volume 1. Companion chapter: Integer functions and elementary number theory

The task

Prove six equivalences that connect a floor or a ceiling to a plain inequality, for an integer nn and a real xx.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Start from the definitions: ⌊x⌋\lfloor x \rfloor is the greatest integer ≤x\le x, and ⌈x⌉\lceil x \rceil is the least integer ≥x\ge x.

Hint 2

Prove part (b) first. The other parts follow from (b), from the mirror statement for ceilings and from the fact that no integer lies strictly between nn and n+1n + 1.

Solution

Show the solution

(b) Suppose n≤⌊x⌋n \le \lfloor x \rfloor. Since ⌊x⌋≤x\lfloor x \rfloor \le x, it follows that n≤xn \le x. Suppose n≤xn \le x. Then nn is an integer that is at most xx, and ⌊x⌋\lfloor x \rfloor is the greatest such integer, so n≤⌊x⌋n \le \lfloor x \rfloor.

(a) Negate (b): ⌊x⌋<n\lfloor x \rfloor < n if and only if x<nx < n.

(c) Apply (a) with n+1n + 1 in place of nn: ⌊x⌋<n+1\lfloor x \rfloor < n + 1 if and only if x<n+1x < n + 1. For integers, ⌊x⌋<n+1\lfloor x \rfloor < n + 1 means ⌊x⌋≤n\lfloor x \rfloor \le n.

(d) The ceiling is the least integer ≥x\ge x. Suppose n<⌈x⌉n < \lceil x \rceil. If n≥xn \ge x, then nn is an integer that is at least xx, so ⌈x⌉≤n\lceil x \rceil \le n, which is false. So n<xn < x. Suppose n<xn < x. Then ⌈x⌉≥x>n\lceil x \rceil \ge x > n. So the two statements are equivalent.

(e) Suppose ⌊x⌋=n\lfloor x \rfloor = n. Then n≤xn \le x by (b). Also ⌊x⌋≤n\lfloor x \rfloor \le n, so x<n+1x < n + 1 by (c). Conversely, n≤xn \le x gives n≤⌊x⌋n \le \lfloor x \rfloor by (b), and x<n+1x < n + 1 gives ⌊x⌋≤n\lfloor x \rfloor \le n by (c). So ⌊x⌋=n\lfloor x \rfloor = n if and only if n≤x<n+1n \le x < n + 1. Since x<n+1x < n + 1 is the same as x−1<nx - 1 < n, this is also the statement x−1<n≤xx - 1 < n \le x.

(f) Suppose ⌈x⌉=n\lceil x \rceil = n. Then x≤nx \le n since nn is at least xx. Also n−1<⌈x⌉n - 1 < \lceil x \rceil, so n−1<xn - 1 < x by (d) with n−1n - 1. Conversely n−1<x≤nn - 1 < x \le n gives ⌈x⌉≤n\lceil x \rceil \le n (as n≥xn \ge x is an integer) and ⌈x⌉>n−1\lceil x \rceil > n - 1 by (d), so ⌈x⌉=n\lceil x \rceil = n. The second form: n−1<xn - 1 < x is n<x+1n < x + 1, and x≤nx \le n is x−1≤n−1x - 1 \le n - 1, so ⌈x⌉=n\lceil x \rceil = n if and only if x≤n<x+1x \le n < x + 1.

Check

Take x=2.5x = 2.5. Then ⌊x⌋=2\lfloor x \rfloor = 2, and 2≤2.5<32 \le 2.5 < 3, and 1.5<2≤2.51.5 < 2 \le 2.5. Also ⌈x⌉=3\lceil x \rceil = 3, and 2<2.5≤32 < 2.5 \le 3, and 2.5≤3<3.52.5 \le 3 < 3.5. For x=−0.5x = -0.5: ⌊x⌋=−1\lfloor x \rfloor = -1 and −1≤−0.5<0-1 \le -0.5 < 0, while ⌈x⌉=0\lceil x \rceil = 0 and −1<−0.5≤0-1 < -0.5 \le 0.

Remarks

These equivalences are the base of most proofs about floors and ceilings. The next exercise and Exercises 1.2.4-6, 1.2.4-35 and 1.2.4-38 use them directly.

This solution is checked, and a person has not reviewed it yet. The source.

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.