Skip to content

Commit f59312e

Browse files
committed
feat: preimage of a product by restrict (#22558)
The preimage of a product of sets by a restriction is the product of the same sets extended with `Set.univ` outside of the restriction.
1 parent 0e29a68 commit f59312e

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

Mathlib/Data/Finset/Pi.lean

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,30 +165,50 @@ def restrict (s : Finset ι) (f : (i : ι) → π i) : (i : s) → π i := fun x
165165

166166
theorem restrict_def (s : Finset ι) : s.restrict (π := π) = fun f x ↦ f x := rfl
167167

168-
theorem _root_.Set.piCongrLeft_comp_restrict {s : Finset ι} :
168+
variable {s t u : Finset ι}
169+
170+
theorem _root_.Set.piCongrLeft_comp_restrict :
169171
(s.equivToSet.symm.piCongrLeft (fun i : s.toSet ↦ π i)) ∘ s.toSet.restrict = s.restrict := rfl
170172

171-
theorem piCongrLeft_comp_restrict {s : Finset ι} :
173+
theorem piCongrLeft_comp_restrict :
172174
(s.equivToSet.piCongrLeft (fun i : s ↦ π i)) ∘ s.restrict = s.toSet.restrict := rfl
173175

174176
/-- If a function `f` is restricted to a finite set `t`, and `s ⊆ t`,
175177
this is the restriction to `s`. -/
176178
@[simp]
177-
def restrict₂ {s t : Finset ι} (hst : s ⊆ t) (f : (i : t) → π i) : (i : s) → π i :=
178-
fun x ↦ f ⟨x.1, hst x.2
179+
def restrict₂ (hst : s ⊆ t) (f : (i : t) → π i) (i : s) : π i := f ⟨i.1, hst i.2
179180

180-
theorem restrict₂_def {s t : Finset ι} (hst : s ⊆ t) :
181-
restrict₂ (π := π) hst = fun f x ↦ f ⟨x.1, hst x.2⟩ := rfl
181+
theorem restrict₂_def (hst : s ⊆ t) : restrict₂ (π := π) hst = fun f x ↦ f ⟨x.1, hst x.2⟩ := rfl
182182

183-
theorem restrict₂_comp_restrict {s t : Finset ι} (hst : s ⊆ t) :
183+
theorem restrict₂_comp_restrict (hst : s ⊆ t) :
184184
(restrict₂ (π := π) hst) ∘ t.restrict = s.restrict := rfl
185185

186-
theorem restrict₂_comp_restrict₂ {s t u : Finset ι} (hst : s ⊆ t) (htu : t ⊆ u) :
186+
theorem restrict₂_comp_restrict₂ (hst : s ⊆ t) (htu : t ⊆ u) :
187187
(restrict₂ (π := π) hst) ∘ (restrict₂ htu) = restrict₂ (hst.trans htu) := rfl
188188

189189
lemma dependsOn_restrict (s : Finset ι) : DependsOn (s.restrict (π := π)) s :=
190190
(s : Set ι).dependsOn_restrict
191191

192+
lemma restrict_preimage [DecidablePred (· ∈ s)] (t : (i : s) → Set (π i)) :
193+
s.restrict ⁻¹' (Set.univ.pi t) =
194+
Set.pi s (fun i ↦ if h : i ∈ s then t ⟨i, h⟩ else Set.univ) := by
195+
ext x
196+
simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, restrict, forall_const, Subtype.forall,
197+
mem_coe]
198+
refine ⟨fun h i hi ↦ by simpa [hi] using h i hi, fun h i hi ↦ ?_⟩
199+
convert h i hi
200+
rw [dif_pos hi]
201+
202+
lemma restrict₂_preimage [DecidablePred (· ∈ s)] (hst : s ⊆ t) (u : (i : s) → Set (π i)) :
203+
(restrict₂ hst) ⁻¹' (Set.univ.pi u) =
204+
(@Set.univ t).pi (fun j ↦ if h : j.1 ∈ s then u ⟨j.1, h⟩ else Set.univ) := by
205+
ext x
206+
simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, restrict₂, forall_const, Subtype.forall]
207+
refine ⟨fun h i hi ↦ ?_, fun h i i_mem ↦ by simpa [i_mem] using h i (hst i_mem)⟩
208+
split_ifs with i_mem
209+
· exact h i i_mem
210+
· trivial
211+
192212
end Pi
193213

194214
end Finset

0 commit comments

Comments
 (0)