l3lab/ntp-mathlib huggingface dataset:
/-- Given `G` acting on `X`, a functor from the corresponding action groupoid to a group `H`
    can be curried to a group homomorphism `G →* (X → H) ⋊ G`. -/
@[simps]
def curry (F : ActionCategory G X ⥤ SingleObj H) : G →* (X → H) ⋊[mulAutArrow] G :=
  have F_map_eq : ∀ {a b} {f : a ⟶ b}, F.map f = (F.map (homOfPair b.back f.val) : H) := by
    apply ActionCategory.cases
    intros
    rfl
  { toFun := fun g => ⟨fun b => F.map (homOfPair b g), g⟩
    map_one' := by
      congr
      dsimp
      ext1
      ext b
      exact F_map_eq.symm.trans (F.map_id b)
      rfl
    map_mul' := by
      intro g h
      congr
      ext b
      exact F_map_eq.symm.trans (F.map_comp (homOfPair (g⁻¹ • b) h) (homOfPair b g))
      

Proof state:
case right
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : ActionCategory G X ⥤ SingleObj H
F_map_eq : ∀ {a b : ActionCategory G X} {f : a ⟶ b}, F.map f = F.map (homOfPair (ActionCategory.back b) ↑f)
g h : G
⊢ (OneHom.toFun
        { toFun := fun g => { left := fun b => F.map (homOfPair b g), right := g },
          map_one' := (_ : (fun g => { left := fun b => F.map (homOfPair b g), right := g }) 1 = 1) }
        (g * h)).right =
    (OneHom.toFun
          { toFun := fun g => { left := fun b => F.map (homOfPair b g), right := g },
            map_one' := (_ : (fun g => { left := fun b => F.map (homOfPair b g), right := g }) 1 = 1) }
          g *
        OneHom.toFun
          { toFun := fun g => { left := fun b => F.map (homOfPair b g), right := g },
            map_one' := (_ : (fun g => { left := fun b => F.map (homOfPair b g), right := g }) 1 = 1) }
          h).right

Next tactic:
rfl
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    

Proof state:
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x✝ : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
x : ActionCategory G X
⊢ { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map (𝟙 x) =
    𝟙 ({ obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.obj x)

Next tactic:
dsimp
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    dsimp
    

Proof state:
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x✝ : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
x : ActionCategory G X
⊢ left (F 1) (ActionCategory.back x) = 𝟙 ()

Next tactic:
rw [F.map_one]
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    dsimp
    rw [F.map_one]
    

Proof state:
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x✝ : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
x : ActionCategory G X
⊢ left 1 (ActionCategory.back x) = 𝟙 ()

Next tactic:
rfl
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    dsimp
    rw [F.map_one]
    rfl
  map_comp f g := by
    -- porting note: I was not able to use `ActionCategory.cases` here,
    -- but `ActionCategory.cases'` seems as good; the original proof was:
    -- intro x y z f g; revert y z g
    -- refine' action_category.cases _
    -- simp [single_obj.comp_as_mul, sane]
    

Proof state:
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
X✝ Y✝ Z✝ : ActionCategory G X
f : X✝ ⟶ Y✝
g : Y✝ ⟶ Z✝
⊢ { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map (f ≫ g) =
    { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map f ≫
      { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map g

Next tactic:
obtain ⟨_, z, γ₁, rfl, rfl, rfl, rfl⟩ := ActionCategory.cases' g
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    dsimp
    rw [F.map_one]
    rfl
  map_comp f g := by
    -- porting note: I was not able to use `ActionCategory.cases` here,
    -- but `ActionCategory.cases'` seems as good; the original proof was:
    -- intro x y z f g; revert y z g
    -- refine' action_category.cases _
    -- simp [single_obj.comp_as_mul, sane]
    obtain ⟨_, z, γ₁, rfl, rfl, rfl, rfl⟩ := ActionCategory.cases' g
    

Proof state:
case intro.intro.intro.intro.intro.intro
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
X✝ : ActionCategory G X
z : X
γ₁ : G
f : X✝ ⟶ { fst := (), snd := γ₁⁻¹ • z }
⊢ { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
      (f ≫
        eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }) ≫
          homOfPair z γ₁ ≫ eqToHom (_ : { fst := (), snd := z } = { fst := (), snd := z })) =
    { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map f ≫
      { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
        (eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }) ≫
          homOfPair z γ₁ ≫ eqToHom (_ : { fst := (), snd := z } = { fst := (), snd := z }))

Next tactic:
obtain ⟨_, y, γ₂, rfl, hy, rfl, rfl⟩ := ActionCategory.cases' f
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    dsimp
    rw [F.map_one]
    rfl
  map_comp f g := by
    -- porting note: I was not able to use `ActionCategory.cases` here,
    -- but `ActionCategory.cases'` seems as good; the original proof was:
    -- intro x y z f g; revert y z g
    -- refine' action_category.cases _
    -- simp [single_obj.comp_as_mul, sane]
    obtain ⟨_, z, γ₁, rfl, rfl, rfl, rfl⟩ := ActionCategory.cases' g
    obtain ⟨_, y, γ₂, rfl, hy, rfl, rfl⟩ := ActionCategory.cases' f
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
z : X
γ₁ : G
y : X
γ₂ : G
hy : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := y }
⊢ { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
      ((eqToHom (_ : { fst := (), snd := γ₂⁻¹ • y } = { fst := (), snd := γ₂⁻¹ • y }) ≫
          homOfPair y γ₂ ≫ eqToHom (_ : { fst := (), snd := y } = { fst := (), snd := γ₁⁻¹ • z })) ≫
        eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }) ≫
          homOfPair z γ₁ ≫ eqToHom (_ : { fst := (), snd := z } = { fst := (), snd := z })) =
    { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
        (eqToHom (_ : { fst := (), snd := γ₂⁻¹ • y } = { fst := (), snd := γ₂⁻¹ • y }) ≫
          homOfPair y γ₂ ≫ eqToHom (_ : { fst := (), snd := y } = { fst := (), snd := γ₁⁻¹ • z })) ≫
      { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
        (eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }) ≫
          homOfPair z γ₁ ≫ eqToHom (_ : { fst := (), snd := z } = { fst := (), snd := z }))

Next tactic:
obtain rfl : y = γ₁⁻¹ • z := congr_arg Sigma.snd hy.symm
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    dsimp
    rw [F.map_one]
    rfl
  map_comp f g := by
    -- porting note: I was not able to use `ActionCategory.cases` here,
    -- but `ActionCategory.cases'` seems as good; the original proof was:
    -- intro x y z f g; revert y z g
    -- refine' action_category.cases _
    -- simp [single_obj.comp_as_mul, sane]
    obtain ⟨_, z, γ₁, rfl, rfl, rfl, rfl⟩ := ActionCategory.cases' g
    obtain ⟨_, y, γ₂, rfl, hy, rfl, rfl⟩ := ActionCategory.cases' f
    obtain rfl : y = γ₁⁻¹ • z := congr_arg Sigma.snd hy.symm
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
z : X
γ₁ γ₂ : G
hy : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }
⊢ { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
      ((eqToHom (_ : { fst := (), snd := γ₂⁻¹ • γ₁⁻¹ • z } = { fst := (), snd := γ₂⁻¹ • γ₁⁻¹ • z }) ≫
          homOfPair (γ₁⁻¹ • z) γ₂ ≫ eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z })) ≫
        eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }) ≫
          homOfPair z γ₁ ≫ eqToHom (_ : { fst := (), snd := z } = { fst := (), snd := z })) =
    { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
        (eqToHom (_ : { fst := (), snd := γ₂⁻¹ • γ₁⁻¹ • z } = { fst := (), snd := γ₂⁻¹ • γ₁⁻¹ • z }) ≫
          homOfPair (γ₁⁻¹ • z) γ₂ ≫ eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z })) ≫
      { obj := fun x => (), map := fun {x b} f => left (F ↑f) (ActionCategory.back b) }.map
        (eqToHom (_ : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }) ≫
          homOfPair z γ₁ ≫ eqToHom (_ : { fst := (), snd := z } = { fst := (), snd := z }))

Next tactic:
simp [sane]
/-- Given `G` acting on `X`, a group homomorphism `φ : G →* (X → H) ⋊ G` can be uncurried to
    a functor from the action groupoid to `H`, provided that `φ g = (_, g)` for all `g`. -/
@[simps]
def uncurry (F : G →* (X → H) ⋊[mulAutArrow] G) (sane : ∀ g, (F g).right = g) :
    ActionCategory G X ⥤ SingleObj H where
  obj _ := ()
  map {_ b} f := (F f.val).left b.back
  map_id x := by
    dsimp
    rw [F.map_one]
    rfl
  map_comp f g := by
    -- porting note: I was not able to use `ActionCategory.cases` here,
    -- but `ActionCategory.cases'` seems as good; the original proof was:
    -- intro x y z f g; revert y z g
    -- refine' action_category.cases _
    -- simp [single_obj.comp_as_mul, sane]
    obtain ⟨_, z, γ₁, rfl, rfl, rfl, rfl⟩ := ActionCategory.cases' g
    obtain ⟨_, y, γ₂, rfl, hy, rfl, rfl⟩ := ActionCategory.cases' f
    obtain rfl : y = γ₁⁻¹ • z := congr_arg Sigma.snd hy.symm
    simp [sane]
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
M : Type u_1
inst✝⁴ : Monoid M
X : Type u
inst✝³ : MulAction M X
x : X
G : Type u_2
inst✝² : Group G
inst✝¹ : MulAction G X
H : Type u_3
inst✝ : Group H
F : G →* (X → H) ⋊[mulAutArrow] G
sane : ∀ (g : G), (F g).right = g
z : X
γ₁ γ₂ : G
hy : { fst := (), snd := γ₁⁻¹ • z } = { fst := (), snd := γ₁⁻¹ • z }
⊢ left (F γ₁) z * (γ₁ • (F γ₂).left) z = left (F γ₂) (γ₁⁻¹ • z) ≫ left (F γ₁) z

Next tactic:
rfl
theorem surjOn_Ioo_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ioo a b) (Ioo (f a) (f b)) := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
⊢ SurjOn f (Ioo a b) (Ioo (f a) (f b))

Next tactic:
intro p hp
theorem surjOn_Ioo_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ioo a b) (Ioo (f a) (f b)) := by
  intro p hp
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
p : β
hp : p ∈ Ioo (f a) (f b)
⊢ p ∈ f '' Ioo a b

Next tactic:
rcases h_surj p with ⟨x, rfl⟩
theorem surjOn_Ioo_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ioo a b) (Ioo (f a) (f b)) := by
  intro p hp
  rcases h_surj p with ⟨x, rfl⟩
  

Proof state:
case intro
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b x : α
hp : f x ∈ Ioo (f a) (f b)
⊢ f x ∈ f '' Ioo a b

Next tactic:
refine' ⟨x, mem_Ioo.2 _, rfl⟩
theorem surjOn_Ioo_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ioo a b) (Ioo (f a) (f b)) := by
  intro p hp
  rcases h_surj p with ⟨x, rfl⟩
  refine' ⟨x, mem_Ioo.2 _, rfl⟩
  

Proof state:
case intro
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b x : α
hp : f x ∈ Ioo (f a) (f b)
⊢ a < x ∧ x < b

Next tactic:
contrapose! hp
theorem surjOn_Ioo_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ioo a b) (Ioo (f a) (f b)) := by
  intro p hp
  rcases h_surj p with ⟨x, rfl⟩
  refine' ⟨x, mem_Ioo.2 _, rfl⟩
  contrapose! hp
  

Proof state:
case intro
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b x : α
hp : a < x → b ≤ x
⊢ f x ∉ Ioo (f a) (f b)

Next tactic:
exact fun h => h.2.not_le (h_mono <| hp <| h_mono.reflect_lt h.1)
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
⊢ SurjOn f (Ico a b) (Ico (f a) (f b))

Next tactic:
obtain hab | hab := lt_or_le a b
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  obtain hab | hab := lt_or_le a b
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a < b
⊢ SurjOn f (Ico a b) (Ico (f a) (f b))

Next tactic:
intro p hp
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  obtain hab | hab := lt_or_le a b
  · intro p hp
    

Proof state:
case inl
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a < b
p : β
hp : p ∈ Ico (f a) (f b)
⊢ p ∈ f '' Ico a b

Next tactic:
rcases eq_left_or_mem_Ioo_of_mem_Ico hp with (rfl | hp')
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  obtain hab | hab := lt_or_le a b
  · intro p hp
    rcases eq_left_or_mem_Ioo_of_mem_Ico hp with (rfl | hp')
    · 

Proof state:
case inl.inl
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a < b
hp : f a ∈ Ico (f a) (f b)
⊢ f a ∈ f '' Ico a b

Next tactic:
exact mem_image_of_mem f (left_mem_Ico.mpr hab)
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  obtain hab | hab := lt_or_le a b
  · intro p hp
    rcases eq_left_or_mem_Ioo_of_mem_Ico hp with (rfl | hp')
    · exact mem_image_of_mem f (left_mem_Ico.mpr hab)
    · 

Proof state:
case inl.inr
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a < b
p : β
hp : p ∈ Ico (f a) (f b)
hp' : p ∈ Ioo (f a) (f b)
⊢ p ∈ f '' Ico a b

Next tactic:
have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp'
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  obtain hab | hab := lt_or_le a b
  · intro p hp
    rcases eq_left_or_mem_Ioo_of_mem_Ico hp with (rfl | hp')
    · exact mem_image_of_mem f (left_mem_Ico.mpr hab)
    · have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp'
      

Proof state:
case inl.inr
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a < b
p : β
hp : p ∈ Ico (f a) (f b)
hp' : p ∈ Ioo (f a) (f b)
this : p ∈ f '' Ioo a b
⊢ p ∈ f '' Ico a b

Next tactic:
exact image_subset f Ioo_subset_Ico_self this
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  obtain hab | hab := lt_or_le a b
  · intro p hp
    rcases eq_left_or_mem_Ioo_of_mem_Ico hp with (rfl | hp')
    · exact mem_image_of_mem f (left_mem_Ico.mpr hab)
    · have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp'
      exact image_subset f Ioo_subset_Ico_self this
  · 

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : b ≤ a
⊢ SurjOn f (Ico a b) (Ico (f a) (f b))

Next tactic:
rw [Ico_eq_empty (h_mono hab).not_lt]
theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ico a b) (Ico (f a) (f b)) := by
  obtain hab | hab := lt_or_le a b
  · intro p hp
    rcases eq_left_or_mem_Ioo_of_mem_Ico hp with (rfl | hp')
    · exact mem_image_of_mem f (left_mem_Ico.mpr hab)
    · have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp'
      exact image_subset f Ioo_subset_Ico_self this
  · rw [Ico_eq_empty (h_mono hab).not_lt]
    

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : b ≤ a
⊢ SurjOn f (Ico a b) ∅

Next tactic:
exact surjOn_empty f _
theorem surjOn_Ioc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    (a b : α) : SurjOn f (Ioc a b) (Ioc (f a) (f b)) := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
⊢ SurjOn f (Ioc a b) (Ioc (f a) (f b))

Next tactic:
simpa using surjOn_Ico_of_monotone_surjective h_mono.dual h_surj (toDual b) (toDual a)
theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    {a b : α} (hab : a ≤ b) : SurjOn f (Icc a b) (Icc (f a) (f b)) := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a ≤ b
⊢ SurjOn f (Icc a b) (Icc (f a) (f b))

Next tactic:
intro p hp
theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    {a b : α} (hab : a ≤ b) : SurjOn f (Icc a b) (Icc (f a) (f b)) := by
  intro p hp
  

Proof state:
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a ≤ b
p : β
hp : p ∈ Icc (f a) (f b)
⊢ p ∈ f '' Icc a b

Next tactic:
rcases eq_endpoints_or_mem_Ioo_of_mem_Icc hp with (rfl | rfl | hp')
theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    {a b : α} (hab : a ≤ b) : SurjOn f (Icc a b) (Icc (f a) (f b)) := by
  intro p hp
  rcases eq_endpoints_or_mem_Ioo_of_mem_Icc hp with (rfl | rfl | hp')
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a ≤ b
hp : f a ∈ Icc (f a) (f b)
⊢ f a ∈ f '' Icc a b

Next tactic:
exact ⟨a, left_mem_Icc.mpr hab, rfl⟩
theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    {a b : α} (hab : a ≤ b) : SurjOn f (Icc a b) (Icc (f a) (f b)) := by
  intro p hp
  rcases eq_endpoints_or_mem_Ioo_of_mem_Icc hp with (rfl | rfl | hp')
  · exact ⟨a, left_mem_Icc.mpr hab, rfl⟩
  · 

Proof state:
case inr.inl
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a ≤ b
hp : f b ∈ Icc (f a) (f b)
⊢ f b ∈ f '' Icc a b

Next tactic:
exact ⟨b, right_mem_Icc.mpr hab, rfl⟩
theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    {a b : α} (hab : a ≤ b) : SurjOn f (Icc a b) (Icc (f a) (f b)) := by
  intro p hp
  rcases eq_endpoints_or_mem_Ioo_of_mem_Icc hp with (rfl | rfl | hp')
  · exact ⟨a, left_mem_Icc.mpr hab, rfl⟩
  · exact ⟨b, right_mem_Icc.mpr hab, rfl⟩
  · 

Proof state:
case inr.inr
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a ≤ b
p : β
hp : p ∈ Icc (f a) (f b)
hp' : p ∈ Ioo (f a) (f b)
⊢ p ∈ f '' Icc a b

Next tactic:
have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp'
theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f)
    {a b : α} (hab : a ≤ b) : SurjOn f (Icc a b) (Icc (f a) (f b)) := by
  intro p hp
  rcases eq_endpoints_or_mem_Ioo_of_mem_Icc hp with (rfl | rfl | hp')
  · exact ⟨a, left_mem_Icc.mpr hab, rfl⟩
  · exact ⟨b, right_mem_Icc.mpr hab, rfl⟩
  · have := surjOn_Ioo_of_monotone_surjective h_mono h_surj a b hp'
    

Proof state:
case inr.inr
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : PartialOrder β
f : α → β
h_mono : Monotone f
h_surj : Surjective f
a b : α
hab : a ≤ b
p : β
hp : p ∈ Icc (f a) (f b)
hp' : p ∈ Ioo (f a) (f b)
this : p ∈ f '' Ioo a b
⊢ p ∈ f '' Icc a b

Next tactic:
exact image_subset f Ioo_subset_Icc_self this