feat(library/data/finset/{bigops,comb}): add two theorems for Haitao

This commit is contained in:
Jeremy Avigad 2015-07-11 11:58:20 +10:00 committed by Leonardo de Moura
parent 70407473c2
commit e8ad284ead
2 changed files with 25 additions and 0 deletions

View file

@ -117,6 +117,19 @@ section deceqA
finset.induction_on s
(by rewrite Union_empty)
(take s1 a Pa IH, by rewrite [image_insert, *Union_insert, IH])
lemma Union_const [deceqB : decidable_eq B] {f : A → finset B} {s : finset A} {t : finset B}
(a : A) : s ≠ ∅ → (∀ x, x ∈ s → f x = t) → Union s f = t :=
begin
induction s with a' s' H IH,
{intros [H1, H2], exfalso, apply H1 !rfl},
intros [H1, H2],
rewrite [Union_insert, H2 _ !mem_insert],
cases (decidable.em (s' = ∅)) with [seq, sne],
{rewrite [seq, Union_empty, union_empty] },
have H3 : ∀ x, x ∈ s' → f x = t, from (λ x H', H2 x (mem_insert_of_mem _ H')),
rewrite [IH sne H3, union_self]
end
end deceqA
end union

View file

@ -74,6 +74,18 @@ ext (take y, iff.intro
show y ∈ image f (insert a s), from eq.subst (eq.symm H2) H3)
(assume H2 : y ∈ image f s,
show y ∈ image f (insert a s), from mem_image_of_mem_image_of_subset H2 !subset_insert)))
lemma image_compose {C : Type} [deceqC : decidable_eq C] {f : B → C} {g : A → B} {s : finset A} :
image (f∘g) s = image f (image g s) :=
ext (take z, iff.intro
(assume Hz : z ∈ image (f∘g) s,
obtain x (Hx : x ∈ s) (Hgfx : f (g x) = z), from exists_of_mem_image Hz,
by rewrite -Hgfx; apply mem_image_of_mem _ (mem_image_of_mem _ Hx))
(assume Hz : z ∈ image f (image g s),
obtain y (Hy : y ∈ image g s) (Hfy : f y = z), from exists_of_mem_image Hz,
obtain x (Hx : x ∈ s) (Hgx : g x = y), from exists_of_mem_image Hy,
mem_image_of_mem_of_eq Hx (by esimp; rewrite [Hgx, Hfy])))
end image
/- filter and set-builder notation -/