@@ -443,11 +443,12 @@ lemma piecewise_apply {β : Type*} {f : ι → α → β} (x : α) : hs.piecewis
443443
444444open Function
445445
446+ variable {β : Type *} {f : ι → α → β}
447+
446448/-- A family of injective functions with pairwise disjoint
447449domains and pairwise disjoint ranges can be glued together
448450to form an injective function. -/
449- theorem piecewise_inj {β : Type *} {f : ι → α → β}
450- (h_injOn : ∀ i, InjOn (f i) (s i))
451+ theorem piecewise_inj (h_injOn : ∀ i, InjOn (f i) (s i))
451452 (h_disjoint : PairwiseDisjoint (univ : Set ι) fun i => (f i) '' (s i)) :
452453 Injective (piecewise hs f) := by
453454 intro x y h
@@ -461,23 +462,64 @@ theorem piecewise_inj {β : Type*} {f : ι → α → β}
461462/-- A family of bijective functions with pairwise disjoint
462463domains and pairwise disjoint ranges can be glued together
463464to form a bijective function. -/
464- theorem piecewise_bij {β : Type *} {f : ι → α → β}
465- {t : ι → Set β} (ht : IndexedPartition t)
465+ theorem piecewise_bij {t : ι → Set β} (ht : IndexedPartition t)
466466 (hf : ∀ i, BijOn (f i) (s i) (t i)) :
467467 Bijective (piecewise hs f) := by
468468 set g := piecewise hs f with hg
469- have hg_bij : ∀ i, BijOn g (s i) (t i) := by
470- intro i
471- refine BijOn.congr (hf i) ?_
472- intro x hx
469+ have hg_bij (i) : BijOn g (s i) (t i) := by
470+ refine (hf i).congr fun x hx => ?_
473471 rw [hg, piecewise_apply, hs.mem_iff_index_eq.mp hx]
474472 have hg_inj : InjOn g (⋃ i, s i) := by
475- refine injOn_of_injective ?_
476- refine piecewise_inj hs (fun i ↦ BijOn.injOn (hf i)) ?h_disjoint
473+ refine injOn_of_injective (piecewise_inj hs (fun i ↦ BijOn.injOn (hf i)) ?_)
477474 simp only [fun i ↦ BijOn.image_eq (hf i)]
478475 rintro i - j - hij
479476 exact ht.disjoint hij
480477 rw [← bijOn_univ, ← hs.iUnion, ← ht.iUnion]
481478 exact bijOn_iUnion hg_bij hg_inj
482479
480+ theorem piecewise_preimage (f : ι → α → β) (t : Set β) :
481+ hs.piecewise f ⁻¹' t = ⋃ i, s i ∩ (f i ⁻¹' t) := by
482+ refine ext fun x => ⟨fun hx => ?_, fun ⟨a, ⟨i, hi⟩, ha⟩ => ?_⟩
483+ · rw [mem_preimage, piecewise_apply, ← mem_preimage] at hx
484+ exact mem_iUnion_of_mem (hs.index x) (mem_inter (hs.mem_index x) hx)
485+ · rw [← hi, ← (mem_iff_index_eq hs).mp ha.1 ] at ha
486+ simp_all [piecewise_apply]
487+
488+ theorem range_piecewise (f : ι → α → β) : range (hs.piecewise f) = ⋃ i, f i '' s i := by
489+ refine ext fun x => ⟨?_, fun ⟨t, ⟨i, hi⟩, ht⟩ ↦ ?_⟩
490+ · rintro ⟨x, rfl⟩
491+ exact mem_iUnion_of_mem (hs.index x) ⟨x, hs.mem_index x, rfl⟩
492+ · simp only [← hi, mem_image] at ht
493+ obtain ⟨a, ha1, ha2⟩ := ht
494+ refine ⟨a, ?_⟩
495+ simp only [hs.mem_iff_index_eq] at ha1
496+ simpa [hs.mem_iff_index_eq, ← ha1] using ha2
497+
498+ theorem range_piecewise_subset (f : ι → α → β) : range (hs.piecewise f) ⊆ ⋃ i, range (f i) :=
499+ fun x ⟨y, hy⟩ => by simpa [IndexedPartition.piecewise_apply] using ⟨hs.index y, y, hy⟩
500+
501+ /-- Given a collections of sets `s : ι → Set α` that forms an indexed partition, we can group
502+ some of the sets to obtain a coarser partition. -/
503+ noncomputable def coarserPartition (hs : IndexedPartition s) {κ : Type *} (g : ι → κ)
504+ (hg : g.Surjective) :
505+ IndexedPartition (fun k : κ => ⋃ i ∈ g ⁻¹' {k}, s i) where
506+ eq_of_mem {_x _i _j} hxi hxj := by
507+ obtain ⟨a, ⟨c, hc⟩, ha⟩ := hxi
508+ obtain ⟨b, ⟨d, hd⟩, hb⟩ := hxj
509+ simp only [← hc, mem_iUnion] at ha
510+ simp only [← hd, mem_iUnion] at hb
511+ have : c = d := hs.eq_of_mem ha.2 hb.2
512+ by_contra!
513+ have : c ≠ d := disjoint_iff_forall_ne.mp ((disjoint_singleton.mpr this).preimage g) ha.1 hb.1
514+ grind
515+ some k := hs.some ((singleton_nonempty k).preimage hg).some
516+ some_mem k := by
517+ refine mem_iUnion_of_mem ((singleton_nonempty k).preimage hg).some ?_
518+ simp only [mem_preimage, mem_singleton_iff, mem_iUnion, exists_prop]
519+ constructor
520+ · simpa using ((singleton_nonempty k).preimage hg).some_mem
521+ · exact hs.some_mem ((singleton_nonempty k).preimage hg).some
522+ index x := g (hs.index x)
523+ mem_index x := mem_iUnion_of_mem (hs.index x) (by simp [hs.mem_index])
524+
483525end IndexedPartition
0 commit comments