refactor(library,hott,tests): rename succ_inj to succ.inj, add abbreviation eq_of_succ_eq_succ
This commit is contained in:
parent
679bb8b862
commit
a4a8253f50
8 changed files with 21 additions and 19 deletions
|
@ -65,7 +65,7 @@ nat.rec_on n
|
|||
definition exists_eq_succ_of_ne_zero {n : ℕ} (H : n ≠ 0) : Σk : ℕ, n = succ k :=
|
||||
sigma.mk _ (sum_resolve_right !eq_zero_or_eq_succ_pred H)
|
||||
|
||||
definition succ_inj {n m : ℕ} (H : succ n = succ m) : n = m :=
|
||||
definition succ.inj {n m : ℕ} (H : succ n = succ m) : n = m :=
|
||||
lift.down (nat.no_confusion H (λe, e))
|
||||
|
||||
definition succ_ne_self {n : ℕ} : succ n ≠ n :=
|
||||
|
@ -73,7 +73,7 @@ nat.rec_on n
|
|||
(take H : 1 = 0,
|
||||
have ne : 1 ≠ 0, from !succ_ne_zero,
|
||||
absurd H ne)
|
||||
(take k IH H, IH (succ_inj H))
|
||||
(take k IH H, IH (succ.inj H))
|
||||
|
||||
definition discriminate {B : Type} {n : ℕ} (H1: n = 0 → B) (H2 : ∀m, n = succ m → B) : B :=
|
||||
have H : n = n → B, from nat.cases_on n H1 H2,
|
||||
|
@ -161,7 +161,7 @@ nat.rec_on n
|
|||
succ (n + m) = succ n + m : succ_add
|
||||
... = succ n + k : H
|
||||
... = succ (n + k) : succ_add,
|
||||
have H3 : n + m = n + k, from succ_inj H2,
|
||||
have H3 : n + m = n + k, from succ.inj H2,
|
||||
IH H3)
|
||||
|
||||
definition add.cancel_right {n m k : ℕ} (H : n + m = k + m) : n = k :=
|
||||
|
|
|
@ -61,7 +61,7 @@ lemma mem_all_lists : ∀ {n : nat} {l : list A}, length l = n → l ∈ all_lis
|
|||
| (succ n) (a::l) := assume Peq, begin
|
||||
apply mem_map, apply mem_product,
|
||||
exact fintype.complete a,
|
||||
exact mem_all_lists (succ_inj Peq)
|
||||
exact mem_all_lists (succ.inj Peq)
|
||||
end
|
||||
|
||||
lemma mem_all_nodups [deceqA : decidable_eq A] (n : nat) (l : list A) :
|
||||
|
|
|
@ -441,7 +441,7 @@ lemma not_mem_of_find_eq_length : ∀ {a} {l : list T}, find a l = length l →
|
|||
begin
|
||||
rewrite [find_cons_of_ne l Pne, length_cons, mem_cons_iff],
|
||||
intro Plen, apply (not_or Pne),
|
||||
exact not_mem_of_find_eq_length (succ_inj Plen)
|
||||
exact not_mem_of_find_eq_length (succ.inj Plen)
|
||||
end)
|
||||
|
||||
lemma find_lt_length {a} {l : list T} (Pin : a ∈ l) : find a l < length l :=
|
||||
|
|
|
@ -64,15 +64,17 @@ nat.induction_on n
|
|||
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)
|
||||
|
||||
theorem succ_inj {n m : ℕ} (H : succ n = succ m) : n = m :=
|
||||
theorem succ.inj {n m : ℕ} (H : succ n = succ m) : n = m :=
|
||||
nat.no_confusion H (λe, e)
|
||||
|
||||
abbreviation eq_of_succ_eq_succ := @succ.inj
|
||||
|
||||
theorem succ_ne_self {n : ℕ} : succ n ≠ n :=
|
||||
nat.induction_on n
|
||||
(take H : 1 = 0,
|
||||
have ne : 1 ≠ 0, from !succ_ne_zero,
|
||||
absurd H ne)
|
||||
(take k IH H, IH (succ_inj H))
|
||||
(take k IH H, IH (succ.inj H))
|
||||
|
||||
theorem discriminate {B : Prop} {n : ℕ} (H1: n = 0 → B) (H2 : ∀m, n = succ m → B) : B :=
|
||||
have H : n = n → B, from nat.cases_on n H1 H2,
|
||||
|
@ -160,7 +162,7 @@ nat.induction_on n
|
|||
succ (n + m) = succ n + m : succ_add
|
||||
... = succ n + k : H
|
||||
... = succ (n + k) : succ_add,
|
||||
have H3 : n + m = n + k, from succ_inj H2,
|
||||
have H3 : n + m = n + k, from succ.inj H2,
|
||||
IH H3)
|
||||
|
||||
theorem add.cancel_right {n m k : ℕ} (H : n + m = k + m) : n = k :=
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace vec
|
|||
|
||||
definition tail {n : nat} : vec A (succ n) → vec A n
|
||||
| (tag [] h) := by contradiction
|
||||
| (tag (a::v) h) := tag v (succ_inj h)
|
||||
| (tag (a::v) h) := tag v (succ.inj h)
|
||||
|
||||
theorem head_cons {n : nat} (a : A) (v : vec A n) : head (a :: v) = a :=
|
||||
by induction v; reflexivity
|
||||
|
@ -49,7 +49,7 @@ namespace vec
|
|||
theorem head_lcons {n : nat} (a : A) (l : list A) (h : length (a::l) = succ n) : head (tag (a::l) h) = a :=
|
||||
rfl
|
||||
|
||||
theorem tail_lcons {n : nat} (a : A) (l : list A) (h : length (a::l) = succ n) : tail (tag (a::l) h) = tag l (succ_inj h) :=
|
||||
theorem tail_lcons {n : nat} (a : A) (l : list A) (h : length (a::l) = succ n) : tail (tag (a::l) h) = tag l (succ.inj h) :=
|
||||
rfl
|
||||
|
||||
theorem eta : ∀ {n : nat} (v : vec A (succ n)), head v :: tail v = v
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Nat
|
|||
definition pred (n : Nat) := Nat.rec zero (fun m x, m) n
|
||||
theorem pred_succ (n : Nat) : pred (succ n) = n := rfl
|
||||
|
||||
theorem succ_inj {n m : Nat} (H : succ n = succ m) : n = m
|
||||
theorem succ.inj {n m : Nat} (H : succ n = succ m) : n = m
|
||||
:= calc
|
||||
n = pred (succ n) : pred_succ n⁻¹
|
||||
... = pred (succ m) : {H}
|
||||
|
|
|
@ -70,7 +70,7 @@ theorem discriminate {B : Prop} {n : ℕ} (H1: n = 0 → B) (H2 : ∀m, n = succ
|
|||
(take H3 : n = 0, H1 H3)
|
||||
(take H3 : n = succ (pred n), H2 (pred n) H3)
|
||||
|
||||
theorem succ_inj {n m : ℕ} (H : succ n = succ m) : n = m
|
||||
theorem succ.inj {n m : ℕ} (H : succ n = succ m) : n = m
|
||||
:= calc
|
||||
n = pred (succ n) : (pred_succ n)⁻¹
|
||||
... = pred (succ m) : {H}
|
||||
|
@ -81,7 +81,7 @@ theorem succ_ne_self (n : ℕ) : succ n ≠ n
|
|||
(take H : 1 = 0,
|
||||
have ne : 1 ≠ 0, from succ_ne_zero 0,
|
||||
absurd H ne)
|
||||
(take k IH H, IH (succ_inj H))
|
||||
(take k IH H, IH (succ.inj H))
|
||||
|
||||
theorem decidable_eq [instance] (n m : ℕ) : decidable (n = m)
|
||||
:= have general : ∀n, decidable (n = m), from
|
||||
|
@ -99,7 +99,7 @@ theorem decidable_eq [instance] (n m : ℕ) : decidable (n = m)
|
|||
(assume Heq : n' = m', inl (congr_arg succ Heq))
|
||||
(assume Hne : n' ≠ m',
|
||||
have H1 : succ n' ≠ succ m', from
|
||||
assume Heq, absurd (succ_inj Heq) Hne,
|
||||
assume Heq, absurd (succ.inj Heq) Hne,
|
||||
inr H1))),
|
||||
general n
|
||||
|
||||
|
@ -209,7 +209,7 @@ theorem add_cancel_left {n m k : ℕ} : n + m = n + k → m = k
|
|||
succ (n + m) = succ n + m : symm (succ_add n m)
|
||||
... = succ n + k : H
|
||||
... = succ (n + k) : succ_add n k,
|
||||
have H3 : n + m = n + k, from succ_inj H2,
|
||||
have H3 : n + m = n + k, from succ.inj H2,
|
||||
IH H3)
|
||||
|
||||
--rename to and_cancel_right
|
||||
|
|
|
@ -64,7 +64,7 @@ theorem discriminate {B : Prop} {n : ℕ} (H1: n = 0 → B) (H2 : ∀m, n = succ
|
|||
(take H3 : n = 0, H1 H3)
|
||||
(take H3 : n = succ (pred n), H2 (pred n) H3)
|
||||
|
||||
theorem succ_inj {n m : ℕ} (H : succ n = succ m) : n = m
|
||||
theorem succ.inj {n m : ℕ} (H : succ n = succ m) : n = m
|
||||
:= calc
|
||||
n = pred (succ n) : (pred_succ n)⁻¹
|
||||
... = pred (succ m) : {H}
|
||||
|
@ -75,7 +75,7 @@ theorem succ_ne_self (n : ℕ) : succ n ≠ n
|
|||
(take H : 1 = 0,
|
||||
have ne : 1 ≠ 0, from succ_ne_zero 0,
|
||||
absurd H ne)
|
||||
(take k IH H, IH (succ_inj H))
|
||||
(take k IH H, IH (succ.inj H))
|
||||
|
||||
theorem decidable_eq [instance] (n m : ℕ) : decidable (n = m)
|
||||
:= have general : ∀n, decidable (n = m), from
|
||||
|
@ -93,7 +93,7 @@ theorem decidable_eq [instance] (n m : ℕ) : decidable (n = m)
|
|||
(assume Heq : n' = m', inl (congr_arg succ Heq))
|
||||
(assume Hne : n' ≠ m',
|
||||
have H1 : succ n' ≠ succ m', from
|
||||
assume Heq, absurd (succ_inj Heq) Hne,
|
||||
assume Heq, absurd (succ.inj Heq) Hne,
|
||||
inr H1))),
|
||||
general n
|
||||
|
||||
|
@ -203,7 +203,7 @@ theorem add_cancel_left {n m k : ℕ} : n + m = n + k → m = k
|
|||
succ (n + m) = succ n + m : symm (succ_add n m)
|
||||
... = succ n + k : H
|
||||
... = succ (n + k) : succ_add n k,
|
||||
have H3 : n + m = n + k, from succ_inj H2,
|
||||
have H3 : n + m = n + k, from succ.inj H2,
|
||||
IH H3)
|
||||
|
||||
--rename to and_cancel_right
|
||||
|
|
Loading…
Reference in a new issue