feat(library/data/{set,finset}): add some useful facts

This commit is contained in:
Jeremy Avigad 2016-01-24 16:41:38 -05:00 committed by Leonardo de Moura
parent 69d953126a
commit 53b2d90c90
3 changed files with 33 additions and 0 deletions

View file

@ -191,6 +191,17 @@ theorem insert_eq_of_mem {a : A} {s : finset A} (H : a ∈ s) : insert a s = s :
ext (λ x, eq.substr (mem_insert_eq x a s)
(or_iff_right_of_imp (λH1, eq.substr H1 H)))
theorem singleton_ne_empty (a : A) : '{a} ≠ ∅ :=
begin
intro H,
apply not_mem_empty a,
rewrite -H,
apply mem_insert
end
theorem pair_eq_singleton (a : A) : '{a, a} = '{a} :=
by rewrite [insert_eq_of_mem !mem_singleton]
-- useful in proofs by induction
theorem forall_of_forall_insert {P : A → Prop} {a : A} {s : finset A}
(H : ∀ x, x ∈ insert a s → P x) :

View file

@ -377,6 +377,17 @@ ext (take y, iff.intro
(suppose y ∈ '{x}, or.inl (eq_of_mem_singleton this))
(suppose y ∈ s, or.inr this)))
theorem pair_eq_singleton (a : X) : '{a, a} = '{a} :=
by rewrite [insert_eq_of_mem !mem_singleton]
theorem singleton_ne_empty (a : X) : '{a} ≠ ∅ :=
begin
intro H,
apply not_mem_empty a,
rewrite -H,
apply mem_insert
end
/- separation -/
theorem mem_sep {s : set X} {P : X → Prop} {x : X} (xs : x ∈ s) (Px : P x) : x ∈ {x ∈ s | P x} :=

View file

@ -57,6 +57,17 @@ by rewrite [-finset.to_set_empty]; apply finite_finset
theorem to_finset_empty : to_finset (∅ : set A) = (#finset ∅) :=
to_finset_eq_of_to_set_eq !finset.to_set_empty
theorem to_finset_eq_empty_of_eq_empty {s : set A} [fins : finite s] (H : s = ∅) :
to_finset s = finset.empty := by rewrite [H, to_finset_empty]
theorem eq_empty_of_to_finset_eq_empty {s : set A} [fins : finite s]
(H : to_finset s = finset.empty) :
s = ∅ := by rewrite [-finset.to_set_empty, -H, to_set_to_finset]
theorem to_finset_eq_empty (s : set A) [fins : finite s] :
(to_finset s = finset.empty) ↔ (s = ∅) :=
iff.intro eq_empty_of_to_finset_eq_empty to_finset_eq_empty_of_eq_empty
theorem finite_insert [instance] (a : A) (s : set A) [finite s] : finite (insert a s) :=
exists.intro (finset.insert a (to_finset s))
(by rewrite [finset.to_set_insert, to_set_to_finset])