Theorem: TopCat.GlueData.preimage_image_eq_image
File: Mathlib/Topology/Gluing.lean

tactic: have : D.f _ _ ⁻¹' (𝖣.ι j ⁻¹' (𝖣.ι i '' U)) = (D.t j i ≫ D.f _ _) ⁻¹' U := by
  ext x
  conv_rhs => rw [← Set.preimage_image_eq U (D.ι_injective _)]
  generalize 𝖣.ι i '' U = U' simp only [GlueData.diagram_l, GlueData.diagram_r, Set.mem_preimage, coe_comp,
    Function.comp_apply]
  erw [D.glue_condition_apply]
  rfl
state_before: D : GlueData
i j : D.J
U : Set ↑(D.U i)
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) = ⇑(D.f j i) '' (⇑(D.t j i ≫ D.f i j) ⁻¹' U)
state_after: D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) = ⇑(D.f j i) '' (⇑(D.t j i ≫ D.f i j) ⁻¹' U)

tactic: rw [← this, Set.image_preimage_eq_inter_range]
state_before: D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) = ⇑(D.f j i) '' (⇑(D.t j i ≫ D.f i j) ⁻¹' U)
state_after: D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) = ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ∩ Set.range ⇑(D.f j i)

tactic: symm
state_before: D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) = ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ∩ Set.range ⇑(D.f j i)
state_after: D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ∩ Set.range ⇑(D.f j i) = ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)

tactic: apply Set.inter_eq_self_of_subset_left
state_before: D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ∩ Set.range ⇑(D.f j i) = ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)
state_after: case a
D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ⊆ Set.range ⇑(D.f j i)

tactic: rw [← D.preimage_range i j]
state_before: case a
D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ⊆ Set.range ⇑(D.f j i)
state_after: case a
D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ⊆ ⇑(D.ι j) ⁻¹' Set.range ⇑(D.ι i)

tactic: exact Set.preimage_mono (Set.image_subset_range _ _)
state_before: case a
D : GlueData
i j : D.J
U : Set ↑(D.U i)
this : ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
⊢ ⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U) ⊆ ⇑(D.ι j) ⁻¹' Set.range ⇑(D.ι i)
state_after: no goals

tactic: ext x
state_before: D : GlueData
i j : D.J
U : Set ↑(D.U i)
⊢ ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) = ⇑(D.t j i ≫ D.f i j) ⁻¹' U
state_after: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
⊢ x ∈ ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) ↔ x ∈ ⇑(D.t j i ≫ D.f i j) ⁻¹' U

tactic: conv_rhs => rw [← Set.preimage_image_eq U (D.ι_injective _)]
state_before: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
⊢ x ∈ ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) ↔ x ∈ ⇑(D.t j i ≫ D.f i j) ⁻¹' U
state_after: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
⊢ x ∈ ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) ↔ x ∈ ⇑(D.t j i ≫ D.f i j) ⁻¹' (⇑(D.ι i) ⁻¹' (⇑(D.ι i) '' U))

tactic: generalize 𝖣.ι i '' U = U'
state_before: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
⊢ x ∈ ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' (⇑(D.ι i) '' U)) ↔ x ∈ ⇑(D.t j i ≫ D.f i j) ⁻¹' (⇑(D.ι i) ⁻¹' (⇑(D.ι i) '' U))
state_after: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
U' : Set ↑D.glued
⊢ x ∈ ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' U') ↔ x ∈ ⇑(D.t j i ≫ D.f i j) ⁻¹' (⇑(D.ι i) ⁻¹' U')

tactic: simp only [GlueData.diagram_l, GlueData.diagram_r, Set.mem_preimage, coe_comp,
  Function.comp_apply]
state_before: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
U' : Set ↑D.glued
⊢ x ∈ ⇑(D.f j i) ⁻¹' (⇑(D.ι j) ⁻¹' U') ↔ x ∈ ⇑(D.t j i ≫ D.f i j) ⁻¹' (⇑(D.ι i) ⁻¹' U')
state_after: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
U' : Set ↑D.glued
⊢ (D.ι j) ((D.f j i) x) ∈ U' ↔ (D.ι i) ((D.f i j) ((D.t j i) x)) ∈ U'

tactic: erw [D.glue_condition_apply]
state_before: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
U' : Set ↑D.glued
⊢ (D.ι j) ((D.f j i) x) ∈ U' ↔ (D.ι i) ((D.f i j) ((D.t j i) x)) ∈ U'
state_after: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
U' : Set ↑D.glued
⊢ (D.ι j) ((D.f j i) x) ∈ U' ↔ (D.ι j) ((D.f j i) x) ∈ U'

tactic: rfl
state_before: case h
D : GlueData
i j : D.J
U : Set ↑(D.U i)
x : ↑(D.V (j, i))
U' : Set ↑D.glued
⊢ (D.ι j) ((D.f j i) x) ∈ U' ↔ (D.ι j) ((D.f j i) x) ∈ U'
state_after: no goals