diff --git a/library/data/finset/bigops.lean b/library/data/finset/bigops.lean index 830de89a2..0536c7bc4 100644 --- a/library/data/finset/bigops.lean +++ b/library/data/finset/bigops.lean @@ -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 diff --git a/library/data/finset/comb.lean b/library/data/finset/comb.lean index 3a771740d..d7ff2e4b9 100644 --- a/library/data/finset/comb.lean +++ b/library/data/finset/comb.lean @@ -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 -/