-- Mathlib/Topology/Order/Basic.lean
theorem Dense.topology_eq_generateFrom [OrderTopology α] [DenselyOrdered α] {s : Set α}
    (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s)

Proof state:
case refine_2.intro.inl
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
x✝ : TopologicalSpace α := generateFrom (Ioi '' s ∪ Iio '' s)
⊢ IsOpen (⋃ y ∈ s ∩ Ioi a, Ioi y)

Tactic:
exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1

Result:
no goals

Proof state:
case refine_2.intro.inr
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (Iio a)

Tactic:
rw [hs.Iio_eq_biUnion]

Result:
case refine_2.intro.inr
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (⋃ y ∈ s ∩ Iio a, Iio y)

Proof state:
case refine_2
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ ∀ s_1 ∈ {s | ∃ a, s = Ioi a ∨ s = Iio a}, IsOpen s_1

Tactic:
rintro _ ⟨a, rfl | rfl⟩

Result:
case refine_2.intro.inl
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (Ioi a)

case refine_2.intro.inr
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (Iio a)

Proof state:
case refine_2.intro.inr
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
x✝ : TopologicalSpace α := generateFrom (Ioi '' s ∪ Iio '' s)
⊢ IsOpen (⋃ y ∈ s ∩ Iio a, Iio y)

Tactic:
exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1

Result:
no goals

Proof state:
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ generateFrom {s | ∃ a, s = Ioi a ∨ s = Iio a} = generateFrom (Ioi '' s ∪ Iio '' s)

Tactic:
refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_)

Result:
case refine_1
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ Ioi '' s ∪ Iio '' s ⊆ {s | ∃ a, s = Ioi a ∨ s = Iio a}

case refine_2
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ ∀ s_1 ∈ {s | ∃ a, s = Ioi a ∨ s = Iio a}, IsOpen s_1

Proof state:
case refine_2.intro.inr
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (⋃ y ∈ s ∩ Iio a, Iio y)

Tactic:
let _ := generateFrom (Ioi '' s ∪ Iio '' s)

Result:
case refine_2.intro.inr
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
x✝ : TopologicalSpace α := generateFrom (Ioi '' s ∪ Iio '' s)
⊢ IsOpen (⋃ y ∈ s ∩ Iio a, Iio y)

Proof state:
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ inst✝³ = generateFrom (Ioi '' s ∪ Iio '' s)

Tactic:
refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_

Result:
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ generateFrom {s | ∃ a, s = Ioi a ∨ s = Iio a} = generateFrom (Ioi '' s ∪ Iio '' s)

Proof state:
case refine_2.intro.inl
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (Ioi a)

Tactic:
rw [hs.Ioi_eq_biUnion]

Result:
case refine_2.intro.inl
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (⋃ y ∈ s ∩ Ioi a, Ioi y)

Proof state:
case refine_2.intro.inl
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
⊢ IsOpen (⋃ y ∈ s ∩ Ioi a, Ioi y)

Tactic:
let _ := generateFrom (Ioi '' s ∪ Iio '' s)

Result:
case refine_2.intro.inl
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
a : α
x✝ : TopologicalSpace α := generateFrom (Ioi '' s ∪ Iio '' s)
⊢ IsOpen (⋃ y ∈ s ∩ Ioi a, Ioi y)

Proof state:
case refine_1
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ s ⊆ Ioi ⁻¹' {s | ∃ a, s = Ioi a ∨ s = Iio a} ∧ s ⊆ Iio ⁻¹' {s | ∃ a, s = Ioi a ∨ s = Iio a}

Tactic:
exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩

Result:
no goals

Proof state:
case refine_1
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ Ioi '' s ∪ Iio '' s ⊆ {s | ∃ a, s = Ioi a ∨ s = Iio a}

Tactic:
simp only [union_subset_iff, image_subset_iff]

Result:
case refine_1
α : Type u
inst✝³ : TopologicalSpace α
inst✝² : LinearOrder α
inst✝¹ : OrderTopology α
inst✝ : DenselyOrdered α
s : Set α
hs : Dense s
⊢ s ⊆ Ioi ⁻¹' {s | ∃ a, s = Ioi a ∨ s = Iio a} ∧ s ⊆ Iio ⁻¹' {s | ∃ a, s = Ioi a ∨ s = Iio a}