Skip to content

Commit

Permalink
feat(data/fin): zero_eq_one_iff and one_eq_zero_iff (#4255)
Browse files Browse the repository at this point in the history
Just a pair of little lemmas that were handy to me. The main benefit is that `simp` can now prove `if (0 : fin 2) = 1 then 1 else 0 = 0`, which should help with calculations using `data.matrix.notation`.
  • Loading branch information
Vierkantor committed Sep 25, 2020
1 parent 3a591e8 commit 85bbf8a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/data/fin.lean
Expand Up @@ -416,6 +416,18 @@ lemma one_pos : (0 : fin (n + 2)) < 1 := succ_pos 0

lemma zero_ne_one : (0 : fin (n + 2)) ≠ 1 := ne_of_lt one_pos

@[simp] lemma zero_eq_one_iff : (0 : fin (n + 1)) = 1 ↔ n = 0 :=
begin
split,
{ cases n; intro h,
{ refl },
{ have := zero_ne_one, contradiction } },
{ rintro rfl, refl }
end

@[simp] lemma one_eq_zero_iff : (1 : fin (n + 1)) = 0 ↔ n = 0 :=
by rw [eq_comm, zero_eq_one_iff]

lemma cast_succ_fin_succ (n : ℕ) (j : fin n) :
cast_succ (fin.succ j) = fin.succ (cast_succ j) :=
by { simp [fin.ext_iff], }
Expand Down

0 comments on commit 85bbf8a

Please sign in to comment.