@@ -1310,6 +1310,9 @@ theorem Nonempty.cons_induction {α : Type*} {p : ∀ s : Finset α, s.Nonempty
1310
1310
· exact h₁ t ha ht (h ht)
1311
1311
#align finset.nonempty.cons_induction Finset.Nonempty.cons_induction
1312
1312
1313
+ lemma Nonempty.exists_cons_eq (hs : s.Nonempty) : ∃ t a ha, cons a t ha = s :=
1314
+ hs.cons_induction (fun a ↦ ⟨∅, a, by simp⟩) fun _ _ _ _ _ ↦ ⟨_, _, _, rfl⟩
1315
+
1313
1316
/-- Inserting an element to a finite set is equivalent to the option type. -/
1314
1317
def subtypeInsertEquivOption {t : Finset α} {x : α} (h : x ∉ t) :
1315
1318
{ i // i ∈ insert x t } ≃ Option { i // i ∈ t } := by
@@ -2091,21 +2094,16 @@ theorem erase_injOn' (a : α) : { s : Finset α | a ∈ s }.InjOn fun s => erase
2091
2094
fun s hs t ht (h : s.erase a = _) => by rw [← insert_erase hs, ← insert_erase ht, h]
2092
2095
#align finset.erase_inj_on' Finset.erase_injOn'
2093
2096
2094
- lemma Nonempty.exists_cons_eq (hs : s.Nonempty) : ∃ t a ha, cons a t ha = s := by
2095
- classical
2096
- obtain ⟨a, ha⟩ := hs
2097
- exact ⟨s.erase a, a, not_mem_erase _ _, by simp [insert_erase ha]⟩
2097
+ end Erase
2098
2098
2099
- lemma Nontrivial.exists_cons_eq (hs : s.Nontrivial) :
2099
+ lemma Nontrivial.exists_cons_eq {s : Finset α} (hs : s.Nontrivial) :
2100
2100
∃ t a ha b hb hab, (cons b t hb).cons a (mem_cons.not.2 <| not_or_intro hab ha) = s := by
2101
2101
classical
2102
2102
obtain ⟨a, ha, b, hb, hab⟩ := hs
2103
2103
have : b ∈ s.erase a := mem_erase.2 ⟨hab.symm, hb⟩
2104
2104
refine ⟨(s.erase a).erase b, a, ?_, b, ?_, ?_, ?_⟩ <;>
2105
2105
simp [insert_erase this, insert_erase ha, *]
2106
2106
2107
- end Erase
2108
-
2109
2107
/-! ### sdiff -/
2110
2108
2111
2109
0 commit comments