refactor(library/data/nat/basic): rename pred.zero and pred.succ
This commit is contained in:
parent
50f03c5a09
commit
42c328e781
3 changed files with 14 additions and 14 deletions
|
@ -53,17 +53,17 @@ assume H, no_confusion H
|
|||
|
||||
-- add_rewrite succ_ne_zero
|
||||
|
||||
theorem pred.zero : pred 0 = 0 :=
|
||||
theorem pred_zero : pred 0 = 0 :=
|
||||
rfl
|
||||
|
||||
theorem pred.succ (n : ℕ) : pred (succ n) = n :=
|
||||
theorem pred_succ (n : ℕ) : pred (succ n) = n :=
|
||||
rfl
|
||||
|
||||
theorem eq_zero_or_eq_succ_pred (n : ℕ) : n = 0 ∨ n = succ (pred n) :=
|
||||
induction_on n
|
||||
(or.inl rfl)
|
||||
(take m IH, or.inr
|
||||
(show succ m = succ (pred (succ m)), from congr_arg succ !pred.succ⁻¹))
|
||||
(show succ m = succ (pred (succ m)), from congr_arg succ !pred_succ⁻¹))
|
||||
|
||||
theorem exists_eq_succ_of_ne_zero {n : ℕ} (H : n ≠ 0) : ∃k : ℕ, n = succ k :=
|
||||
exists.intro _ (or_resolve_right !eq_zero_or_eq_succ_pred H)
|
||||
|
|
|
@ -285,16 +285,16 @@ nat.cases_on n
|
|||
(assume H : pred 0 ≤ m, !zero_le)
|
||||
(take n',
|
||||
assume H : pred (succ n') ≤ m,
|
||||
have H1 : n' ≤ m, from pred.succ n' ▸ H,
|
||||
have H1 : n' ≤ m, from pred_succ n' ▸ H,
|
||||
succ_le_succ H1)
|
||||
|
||||
theorem pred_le_of_le_succ {n m : ℕ} : n ≤ succ m → pred n ≤ m :=
|
||||
nat.cases_on n
|
||||
(assume H, !pred.zero⁻¹ ▸ zero_le m)
|
||||
(assume H, !pred_zero⁻¹ ▸ zero_le m)
|
||||
(take n',
|
||||
assume H : succ n' ≤ succ m,
|
||||
have H1 : n' ≤ m, from le_of_succ_le_succ H,
|
||||
!pred.succ⁻¹ ▸ H1)
|
||||
!pred_succ⁻¹ ▸ H1)
|
||||
|
||||
theorem succ_le_of_le_pred {n m : ℕ} : succ n ≤ m → n ≤ pred m :=
|
||||
nat.cases_on m
|
||||
|
@ -302,14 +302,14 @@ nat.cases_on m
|
|||
(take m',
|
||||
assume H : succ n ≤ succ m',
|
||||
have H1 : n ≤ m', from le_of_succ_le_succ H,
|
||||
!pred.succ⁻¹ ▸ H1)
|
||||
!pred_succ⁻¹ ▸ H1)
|
||||
|
||||
theorem pred_le_pred_of_le {n m : ℕ} : n ≤ m → pred n ≤ pred m :=
|
||||
nat.cases_on n
|
||||
(assume H, pred.zero⁻¹ ▸ zero_le (pred m))
|
||||
(assume H, pred_zero⁻¹ ▸ zero_le (pred m))
|
||||
(take n',
|
||||
assume H : succ n' ≤ m,
|
||||
!pred.succ⁻¹ ▸ succ_le_of_le_pred H)
|
||||
!pred_succ⁻¹ ▸ succ_le_of_le_pred H)
|
||||
|
||||
theorem le_or_eq_succ_of_le_succ {n m : ℕ} (H : n ≤ succ m) : n ≤ m ∨ n = succ m :=
|
||||
or_of_or_of_imp_left (succ_le_or_eq_of_le H)
|
||||
|
@ -317,8 +317,8 @@ or_of_or_of_imp_left (succ_le_or_eq_of_le H)
|
|||
|
||||
theorem le_pred_self (n : ℕ) : pred n ≤ n :=
|
||||
cases_on n
|
||||
(pred.zero⁻¹ ▸ !le.refl)
|
||||
(take k : ℕ, (!pred.succ)⁻¹ ▸ !self_le_succ)
|
||||
(pred_zero⁻¹ ▸ !le.refl)
|
||||
(take k : ℕ, (!pred_succ)⁻¹ ▸ !self_le_succ)
|
||||
|
||||
theorem succ_pos (n : ℕ) : 0 < succ n :=
|
||||
!zero_lt_succ
|
||||
|
|
|
@ -33,7 +33,7 @@ induction_on n !sub_zero_right
|
|||
calc
|
||||
0 - succ k = pred (0 - k) : !sub_succ_right
|
||||
... = pred 0 : {IH}
|
||||
... = 0 : pred.zero)
|
||||
... = 0 : pred_zero)
|
||||
|
||||
theorem sub_succ_succ (n m : ℕ) : succ n - succ m = n - m :=
|
||||
succ_sub_succ_eq_sub n m
|
||||
|
@ -118,14 +118,14 @@ theorem succ_sub_one (n : ℕ) : succ n - 1 = n :=
|
|||
theorem mul_pred_left (n m : ℕ) : pred n * m = n * m - m :=
|
||||
induction_on n
|
||||
(calc
|
||||
pred 0 * m = 0 * m : {pred.zero}
|
||||
pred 0 * m = 0 * m : {pred_zero}
|
||||
... = 0 : !zero_mul
|
||||
... = 0 - m : !sub_zero_left⁻¹
|
||||
... = 0 * m - m : {!zero_mul⁻¹})
|
||||
(take k : nat,
|
||||
assume IH : pred k * m = k * m - m,
|
||||
calc
|
||||
pred (succ k) * m = k * m : {!pred.succ}
|
||||
pred (succ k) * m = k * m : {!pred_succ}
|
||||
... = k * m + m - m : !sub_add_left⁻¹
|
||||
... = succ k * m - m : {!succ_mul⁻¹})
|
||||
|
||||
|
|
Loading…
Reference in a new issue