x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ (n * p - succ x) / n = p - succ (x / n)
x n p : Nat
h₁ : x < n * p
⊢ (n * p - succ x) / n = p - succ (x / n)
have npos : 0 < n := (eq_zero_or_pos _).resolve_left fun n0 => by
  rw [n0, Nat.zero_mul] at h₁; exact not_lt_zero _ h₁
case lo
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ (p - succ (x / n)) * n ≤ n * p - succ x

case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ n * p - succ x < succ (p - succ (x / n)) * n
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ (n * p - succ x) / n = p - succ (x / n)
apply Nat.div_eq_of_lt_le
x n p : Nat
h₁ : x < 0
n0 : n = 0
⊢ False
x n p : Nat
h₁ : x < n * p
n0 : n = 0
⊢ False
rw [n0, Nat.zero_mul] at h₁
no goals
x n p : Nat
h₁ : x < 0
n0 : n = 0
⊢ False
exact not_lt_zero _ h₁
case lo
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ n * p - succ (x / n) * n ≤ n * p - succ x
case lo
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ (p - succ (x / n)) * n ≤ n * p - succ x
rw [Nat.mul_sub_right_distrib, Nat.mul_comm]
no goals
case lo
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ n * p - succ (x / n) * n ≤ n * p - succ x
exact Nat.sub_le_sub_left _ <| (div_lt_iff_lt_mul npos).1 (lt_succ_self _)
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ succ (pred (n * p - x)) ≤ succ (pred (p - x / n)) * n
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ n * p - succ x < succ (p - succ (x / n)) * n
show succ (pred (n * p - x)) ≤ (succ (pred (p - x / n))) * n
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ n * p - x ≤ (p - x / n) * n

case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ x / n < p
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ succ (pred (n * p - x)) ≤ succ (pred (p - x / n)) * n
rw [succ_pred_eq_of_pos (Nat.sub_pos_of_lt h₁),
  fun h => succ_pred_eq_of_pos (Nat.sub_pos_of_lt h)]
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ p * n - x ≤ p * n - x / n * n
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ n * p - x ≤ (p - x / n) * n
rw [Nat.mul_sub_right_distrib, Nat.mul_comm]
no goals
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ p * n - x ≤ p * n - x / n * n
exact Nat.sub_le_sub_left _ <| div_mul_le_self ..
no goals
case hi
x n p : Nat
h₁ : x < n * p
npos : 0 < n
⊢ x / n < p
rwa [div_lt_iff_lt_mul npos, Nat.mul_comm]