Skip to content

Commit

Permalink
feat(data/list/basic): λ a, [a] is injective (#16716)
Browse files Browse the repository at this point in the history
Also add a `@[simp]` lemma `list.cons_eq_cons`
  • Loading branch information
urkud committed Oct 1, 2022
1 parent 21347ef commit c2d85ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/data/list/basic.lean
Expand Up @@ -53,6 +53,13 @@ assume l₁ l₂, assume Pe, tail_eq_of_cons_eq Pe
theorem cons_inj (a : α) {l l' : list α} : a::l = a::l' ↔ l = l' :=
cons_injective.eq_iff

theorem cons_eq_cons {a b : α} {l l' : list α} : a::l = b::l' ↔ a = b ∧ l = l' :=
⟨list.cons.inj, λ h, h.1 ▸ h.2 ▸ rfl⟩

lemma singleton_injective : injective (λ a : α, [a]) := λ a b h, (cons_eq_cons.1 h).1

lemma singleton_inj {a b : α} : [a] = [b] ↔ a = b := singleton_injective.eq_iff

theorem exists_cons_of_ne_nil {l : list α} (h : l ≠ nil) : ∃ b L, l = b :: L :=
by { induction l with c l', contradiction, use [c,l'], }

Expand Down

0 comments on commit c2d85ce

Please sign in to comment.