l3lab/ntp-mathlib huggingface dataset:
/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/
@[simps]
def toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where
  toFun := i.hom
  invFun := i.inv
  left_inv x := by
    -- porting note: was `by tidy`
    change (i.hom ≫ i.inv) x = x
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
i : X ≅ Y
x : ↑X
⊢ (i.hom ≫ i.inv) x = x

Next tactic:
simp only [hom_inv_id]
/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/
@[simps]
def toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where
  toFun := i.hom
  invFun := i.inv
  left_inv x := by
    -- porting note: was `by tidy`
    change (i.hom ≫ i.inv) x = x
    simp only [hom_inv_id]
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
i : X ≅ Y
x : ↑X
⊢ (𝟙 X) x = x

Next tactic:
erw [id_apply]
/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/
@[simps]
def toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where
  toFun := i.hom
  invFun := i.inv
  left_inv x := by
    -- porting note: was `by tidy`
    change (i.hom ≫ i.inv) x = x
    simp only [hom_inv_id]
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [id_apply]
  right_inv x := by
    -- porting note: was `by tidy`
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
i : X ≅ Y
x : ↑Y
⊢ i.hom (i.inv x) = x

Next tactic:
change (i.inv ≫ i.hom) x = x
/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/
@[simps]
def toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where
  toFun := i.hom
  invFun := i.inv
  left_inv x := by
    -- porting note: was `by tidy`
    change (i.hom ≫ i.inv) x = x
    simp only [hom_inv_id]
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [id_apply]
  right_inv x := by
    -- porting note: was `by tidy`
    change (i.inv ≫ i.hom) x = x
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
i : X ≅ Y
x : ↑Y
⊢ (i.inv ≫ i.hom) x = x

Next tactic:
simp only [inv_hom_id]
/-- Build a `AlgEquiv` from an isomorphism in the category `AlgebraCat R`. -/
@[simps]
def toAlgEquiv {X Y : AlgebraCat R} (i : X ≅ Y) : X ≃ₐ[R] Y where
  toFun := i.hom
  invFun := i.inv
  left_inv x := by
    -- porting note: was `by tidy`
    change (i.hom ≫ i.inv) x = x
    simp only [hom_inv_id]
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [id_apply]
  right_inv x := by
    -- porting note: was `by tidy`
    change (i.inv ≫ i.hom) x = x
    simp only [inv_hom_id]
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
i : X ≅ Y
x : ↑Y
⊢ (𝟙 Y) x = x

Next tactic:
erw [id_apply]
instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where
  reflects {X Y} f _ := by
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
f : X ⟶ Y
x✝ : IsIso ((forget (AlgebraCat R)).map f)
⊢ IsIso f

Next tactic:
let i := asIso ((forget (AlgebraCat.{u} R)).map f)
instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where
  reflects {X Y} f _ := by
    let i := asIso ((forget (AlgebraCat.{u} R)).map f)
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
f : X ⟶ Y
x✝ : IsIso ((forget (AlgebraCat R)).map f)
i : (forget (AlgebraCat R)).obj X ≅ (forget (AlgebraCat R)).obj Y := asIso ((forget (AlgebraCat R)).map f)
⊢ IsIso f

Next tactic:
let e : X ≃ₐ[R] Y := { f, i.toEquiv with }
instance AlgebraCat.forget_reflects_isos : ReflectsIsomorphisms (forget (AlgebraCat.{u} R)) where
  reflects {X Y} f _ := by
    let i := asIso ((forget (AlgebraCat.{u} R)).map f)
    let e : X ≃ₐ[R] Y := { f, i.toEquiv with }
    

Proof state:
R : Type u
inst✝ : CommRing R
X₁ X₂ : Type u
X Y : AlgebraCat R
f : X ⟶ Y
x✝ : IsIso ((forget (AlgebraCat R)).map f)
i : (forget (AlgebraCat R)).obj X ≅ (forget (AlgebraCat R)).obj Y := asIso ((forget (AlgebraCat R)).map f)
e : ↑X ≃ₐ[R] ↑Y :=
  let src := i.toEquiv;
  {
    toEquiv :=
      { toFun := f.toFun, invFun := src.invFun, left_inv := (_ : Function.LeftInverse src.invFun src.toFun),
        right_inv := (_ : Function.RightInverse src.invFun src.toFun) },
    map_mul' := (_ : ∀ (x y : ↑X), OneHom.toFun (↑↑↑f) (x * y) = OneHom.toFun (↑↑↑f) x * OneHom.toFun (↑↑↑f) y),
    map_add' := (_ : ∀ (x y : ↑X), OneHom.toFun (↑↑↑f) (x + y) = OneHom.toFun (↑↑↑f) x + OneHom.toFun (↑↑↑f) y),
    commutes' := (_ : ∀ (r : R), OneHom.toFun (↑↑↑f) ((algebraMap R ↑X) r) = (algebraMap R ↑Y) r) }
⊢ IsIso f

Next tactic:
exact ⟨(IsIso.of_iso e.toAlgebraIso).1⟩
theorem isAddFundamentalDomain_Ioc {T : ℝ} (hT : 0 < T) (t : ℝ)
    (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.zmultiples T) (Ioc t (t + T)) μ := by
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
⊢ IsAddFundamentalDomain (↥(zmultiples T)) (Ioc t (t + T))

Next tactic:
refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
theorem isAddFundamentalDomain_Ioc {T : ℝ} (hT : 0 < T) (t : ℝ)
    (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.zmultiples T) (Ioc t (t + T)) μ := by
  refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
x : ℝ
⊢ ∃! g, g +ᵥ x ∈ Ioc t (t + T)

Next tactic:
have : Bijective (codRestrict (fun n : ℤ => n • T) (AddSubgroup.zmultiples T) _) :=
    (Equiv.ofInjective (fun n : ℤ => n • T) (zsmul_strictMono_left hT).injective).bijective
theorem isAddFundamentalDomain_Ioc {T : ℝ} (hT : 0 < T) (t : ℝ)
    (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.zmultiples T) (Ioc t (t + T)) μ := by
  refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
  have : Bijective (codRestrict (fun n : ℤ => n • T) (AddSubgroup.zmultiples T) _) :=
    (Equiv.ofInjective (fun n : ℤ => n • T) (zsmul_strictMono_left hT).injective).bijective
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
x : ℝ
this : Bijective (codRestrict (fun n => n • T) ↑(zmultiples T) (_ : ∀ (x : ℤ), ∃ y, y • T = x • T))
⊢ ∃! g, g +ᵥ x ∈ Ioc t (t + T)

Next tactic:
refine' this.existsUnique_iff.2 _
theorem isAddFundamentalDomain_Ioc {T : ℝ} (hT : 0 < T) (t : ℝ)
    (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.zmultiples T) (Ioc t (t + T)) μ := by
  refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
  have : Bijective (codRestrict (fun n : ℤ => n • T) (AddSubgroup.zmultiples T) _) :=
    (Equiv.ofInjective (fun n : ℤ => n • T) (zsmul_strictMono_left hT).injective).bijective
  refine' this.existsUnique_iff.2 _
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
x : ℝ
this : Bijective (codRestrict (fun n => n • T) ↑(zmultiples T) (_ : ∀ (x : ℤ), ∃ y, y • T = x • T))
⊢ ∃! x_1, codRestrict (fun n => n • T) ↑(zmultiples T) (_ : ∀ (x : ℤ), ∃ y, y • T = x • T) x_1 +ᵥ x ∈ Ioc t (t + T)

Next tactic:
simpa only [add_comm x] using existsUnique_add_zsmul_mem_Ioc hT x t
theorem isAddFundamentalDomain_Ioc' {T : ℝ} (hT : 0 < T) (t : ℝ) (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.op <| .zmultiples T) (Ioc t (t + T)) μ := by
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
⊢ IsAddFundamentalDomain (↥(AddSubgroup.op (zmultiples T))) (Ioc t (t + T))

Next tactic:
refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
theorem isAddFundamentalDomain_Ioc' {T : ℝ} (hT : 0 < T) (t : ℝ) (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.op <| .zmultiples T) (Ioc t (t + T)) μ := by
  refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
x : ℝ
⊢ ∃! g, g +ᵥ x ∈ Ioc t (t + T)

Next tactic:
have : Bijective (codRestrict (fun n : ℤ => n • T) (AddSubgroup.zmultiples T) _) :=
    (Equiv.ofInjective (fun n : ℤ => n • T) (zsmul_strictMono_left hT).injective).bijective
theorem isAddFundamentalDomain_Ioc' {T : ℝ} (hT : 0 < T) (t : ℝ) (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.op <| .zmultiples T) (Ioc t (t + T)) μ := by
  refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
  have : Bijective (codRestrict (fun n : ℤ => n • T) (AddSubgroup.zmultiples T) _) :=
    (Equiv.ofInjective (fun n : ℤ => n • T) (zsmul_strictMono_left hT).injective).bijective
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
x : ℝ
this : Bijective (codRestrict (fun n => n • T) ↑(zmultiples T) (_ : ∀ (x : ℤ), ∃ y, y • T = x • T))
⊢ ∃! g, g +ᵥ x ∈ Ioc t (t + T)

Next tactic:
refine' (AddSubgroup.equivOp _).bijective.comp this |>.existsUnique_iff.2 _
theorem isAddFundamentalDomain_Ioc' {T : ℝ} (hT : 0 < T) (t : ℝ) (μ : Measure ℝ := by volume_tac) :
    IsAddFundamentalDomain (AddSubgroup.op <| .zmultiples T) (Ioc t (t + T)) μ := by
  refine' IsAddFundamentalDomain.mk' measurableSet_Ioc.nullMeasurableSet fun x => _
  have : Bijective (codRestrict (fun n : ℤ => n • T) (AddSubgroup.zmultiples T) _) :=
    (Equiv.ofInjective (fun n : ℤ => n • T) (zsmul_strictMono_left hT).injective).bijective
  refine' (AddSubgroup.equivOp _).bijective.comp this |>.existsUnique_iff.2 _
  

Proof state:
T : ℝ
hT : 0 < T
t : ℝ
μ : autoParam (Measure ℝ) _auto✝
x : ℝ
this : Bijective (codRestrict (fun n => n • T) ↑(zmultiples T) (_ : ∀ (x : ℤ), ∃ y, y • T = x • T))
⊢ ∃! x_1,
    (⇑(equivOp (zmultiples T)) ∘ codRestrict (fun n => n • T) ↑(zmultiples T) (_ : ∀ (x : ℤ), ∃ y, y • T = x • T))
          x_1 +ᵥ
        x ∈
      Ioc t (t + T)

Next tactic:
simpa using existsUnique_add_zsmul_mem_Ioc hT x t
@[simp]
protected theorem measure_univ : volume (Set.univ : Set (AddCircle T)) = ENNReal.ofReal T := by
  

Proof state:
T : ℝ
hT : Fact (0 < T)
⊢ ↑↑volume univ = ENNReal.ofReal T

Next tactic:
dsimp [volume]
@[simp]
protected theorem measure_univ : volume (Set.univ : Set (AddCircle T)) = ENNReal.ofReal T := by
  dsimp [volume]
  

Proof state:
T : ℝ
hT : Fact (0 < T)
⊢ ENNReal.ofReal T * ↑↑(addHaarMeasure ⊤) univ = ENNReal.ofReal T

Next tactic:
rw [← PositiveCompacts.coe_top]
@[simp]
protected theorem measure_univ : volume (Set.univ : Set (AddCircle T)) = ENNReal.ofReal T := by
  dsimp [volume]
  rw [← PositiveCompacts.coe_top]
  

Proof state:
T : ℝ
hT : Fact (0 < T)
⊢ ENNReal.ofReal T * ↑↑(addHaarMeasure ⊤) ↑⊤ = ENNReal.ofReal T

Next tactic:
simp [addHaarMeasure_self (G := AddCircle T), -PositiveCompacts.coe_top]
instance : IsAddHaarMeasure (volume : Measure (AddCircle T)) :=
  IsAddHaarMeasure.smul _ (by 

Proof state:
T : ℝ
hT : Fact (0 < T)
⊢ ENNReal.ofReal T ≠ 0

Next tactic:
simp [hT.out]
instance isFiniteMeasure : IsFiniteMeasure (volume : Measure (AddCircle T)) where
  measure_univ_lt_top := by 

Proof state:
T : ℝ
hT : Fact (0 < T)
⊢ ↑↑volume univ < ⊤

Next tactic:
simp
/-- The covering map from `ℝ` to the "additive circle" `ℝ ⧸ (ℤ ∙ T)` is measure-preserving,
considered with respect to the standard measure (defined to be the Haar measure of total mass `T`)
on the additive circle, and with respect to the restriction of Lebsegue measure on `ℝ` to an
interval (t, t + T]. -/
protected theorem measurePreserving_mk (t : ℝ) :
    MeasurePreserving (β := AddCircle T) ((↑) : ℝ → AddCircle T)
      (volume.restrict (Ioc t (t + T))) := by
  

Proof state:
T : ℝ
hT : Fact (0 < T)
t : ℝ
⊢ MeasurePreserving QuotientAddGroup.mk

Next tactic:
apply MeasurePreservingQuotientAddGroup.mk'
/-- The covering map from `ℝ` to the "additive circle" `ℝ ⧸ (ℤ ∙ T)` is measure-preserving,
considered with respect to the standard measure (defined to be the Haar measure of total mass `T`)
on the additive circle, and with respect to the restriction of Lebsegue measure on `ℝ` to an
interval (t, t + T]. -/
protected theorem measurePreserving_mk (t : ℝ) :
    MeasurePreserving (β := AddCircle T) ((↑) : ℝ → AddCircle T)
      (volume.restrict (Ioc t (t + T))) := by
  apply MeasurePreservingQuotientAddGroup.mk'
  · 

Proof state:
case h𝓕
T : ℝ
hT : Fact (0 < T)
t : ℝ
⊢ IsAddFundamentalDomain (↥(AddSubgroup.op (zmultiples T))) (Ioc t (t + T))

Next tactic:
exact isAddFundamentalDomain_Ioc' hT.out t
/-- The covering map from `ℝ` to the "additive circle" `ℝ ⧸ (ℤ ∙ T)` is measure-preserving,
considered with respect to the standard measure (defined to be the Haar measure of total mass `T`)
on the additive circle, and with respect to the restriction of Lebsegue measure on `ℝ` to an
interval (t, t + T]. -/
protected theorem measurePreserving_mk (t : ℝ) :
    MeasurePreserving (β := AddCircle T) ((↑) : ℝ → AddCircle T)
      (volume.restrict (Ioc t (t + T))) := by
  apply MeasurePreservingQuotientAddGroup.mk'
  · exact isAddFundamentalDomain_Ioc' hT.out t
  · 

Proof state:
case h𝓕_finite
T : ℝ
hT : Fact (0 < T)
t : ℝ
⊢ ↑↑volume (Ioc t (t + T)) < ⊤

Next tactic:
simp
/-- The covering map from `ℝ` to the "additive circle" `ℝ ⧸ (ℤ ∙ T)` is measure-preserving,
considered with respect to the standard measure (defined to be the Haar measure of total mass `T`)
on the additive circle, and with respect to the restriction of Lebsegue measure on `ℝ` to an
interval (t, t + T]. -/
protected theorem measurePreserving_mk (t : ℝ) :
    MeasurePreserving (β := AddCircle T) ((↑) : ℝ → AddCircle T)
      (volume.restrict (Ioc t (t + T))) := by
  apply MeasurePreservingQuotientAddGroup.mk'
  · exact isAddFundamentalDomain_Ioc' hT.out t
  · simp
  · 

Proof state:
case h
T : ℝ
hT : Fact (0 < T)
t : ℝ
⊢ ↑↑volume (Ioc t (t + T) ∩ ⇑(QuotientAddGroup.mk' (zmultiples T)) ⁻¹' ↑⊤) = ↑(Real.toNNReal T)

Next tactic:
haveI : CompactSpace (ℝ ⧸ zmultiples T) := inferInstanceAs (CompactSpace (AddCircle T))
/-- The covering map from `ℝ` to the "additive circle" `ℝ ⧸ (ℤ ∙ T)` is measure-preserving,
considered with respect to the standard measure (defined to be the Haar measure of total mass `T`)
on the additive circle, and with respect to the restriction of Lebsegue measure on `ℝ` to an
interval (t, t + T]. -/
protected theorem measurePreserving_mk (t : ℝ) :
    MeasurePreserving (β := AddCircle T) ((↑) : ℝ → AddCircle T)
      (volume.restrict (Ioc t (t + T))) := by
  apply MeasurePreservingQuotientAddGroup.mk'
  · exact isAddFundamentalDomain_Ioc' hT.out t
  · simp
  · haveI : CompactSpace (ℝ ⧸ zmultiples T) := inferInstanceAs (CompactSpace (AddCircle T))
    

Proof state:
case h
T : ℝ
hT : Fact (0 < T)
t : ℝ
this : CompactSpace (ℝ ⧸ zmultiples T)
⊢ ↑↑volume (Ioc t (t + T) ∩ ⇑(QuotientAddGroup.mk' (zmultiples T)) ⁻¹' ↑⊤) = ↑(Real.toNNReal T)

Next tactic:
simp [← ENNReal.ofReal_coe_nnreal, Real.coe_toNNReal T hT.out.le, -Real.coe_toNNReal']
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
⊢ ↑↑volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε))

Next tactic:
have hT' : |T| = T := abs_eq_self.mpr hT.out.le
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
⊢ ↑↑volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε))

Next tactic:
let I := Ioc (-(T / 2)) (T / 2)
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
⊢ ↑↑volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε))

Next tactic:
have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; constructor <;> linarith
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
⊢ ε < T / 2 → Metric.closedBall 0 ε ∩ I = Metric.closedBall 0 ε

Next tactic:
intro hε
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
hε : ε < T / 2
⊢ Metric.closedBall 0 ε ∩ I = Metric.closedBall 0 ε

Next tactic:
rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
hε : ε < T / 2
⊢ Icc (-ε) ε ⊆ I

Next tactic:
rintro y ⟨hy₁, hy₂⟩
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; 

Proof state:
case intro
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
hε : ε < T / 2
y : ℝ
hy₁ : -ε ≤ y
hy₂ : y ≤ ε
⊢ y ∈ I

Next tactic:
constructor
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; constructor <;> 

Proof state:
case intro.left
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
hε : ε < T / 2
y : ℝ
hy₁ : -ε ≤ y
hy₂ : y ≤ ε
⊢ -(T / 2) < y

Next tactic:
linarith
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; constructor <;> 

Proof state:
case intro.right
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
hε : ε < T / 2
y : ℝ
hy₁ : -ε ≤ y
hy₂ : y ≤ ε
⊢ y ≤ T / 2

Next tactic:
linarith
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; constructor <;> linarith
  

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
h₁ : ε < T / 2 → Metric.closedBall 0 ε ∩ I = Metric.closedBall 0 ε
⊢ ↑↑volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε))

Next tactic:
have h₂ : (↑) ⁻¹' Metric.closedBall (0 : AddCircle T) ε ∩ I =
      if ε < T / 2 then Metric.closedBall (0 : ℝ) ε else I := by
    conv_rhs => rw [← if_ctx_congr (Iff.rfl : ε < T / 2 ↔ ε < T / 2) h₁ fun _ => rfl, ← hT']
    apply coe_real_preimage_closedBall_inter_eq
    simpa only [hT', Real.closedBall_eq_Icc, zero_add, zero_sub] using Ioc_subset_Icc_self
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; constructor <;> linarith
  have h₂ : (↑) ⁻¹' Metric.closedBall (0 : AddCircle T) ε ∩ I =
      if ε < T / 2 then Metric.closedBall (0 : ℝ) ε else I := by
    

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
h₁ : ε < T / 2 → Metric.closedBall 0 ε ∩ I = Metric.closedBall 0 ε
⊢ QuotientAddGroup.mk ⁻¹' Metric.closedBall 0 ε ∩ I = if ε < T / 2 then Metric.closedBall 0 ε else I

Next tactic:
conv_rhs => rw [← if_ctx_congr (Iff.rfl : ε < T / 2 ↔ ε < T / 2) h₁ fun _ => rfl, ← hT']
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; constructor <;> linarith
  have h₂ : (↑) ⁻¹' Metric.closedBall (0 : AddCircle T) ε ∩ I =
      if ε < T / 2 then Metric.closedBall (0 : ℝ) ε else I := by
    conv_rhs => 

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
h₁ : ε < T / 2 → Metric.closedBall 0 ε ∩ I = Metric.closedBall 0 ε
| if ε < T / 2 then Metric.closedBall 0 ε else I

Next tactic:
rw [← if_ctx_congr (Iff.rfl : ε < T / 2 ↔ ε < T / 2) h₁ fun _ => rfl, ← hT']
theorem volume_closedBall {x : AddCircle T} (ε : ℝ) :
    volume (Metric.closedBall x ε) = ENNReal.ofReal (min T (2 * ε)) := by
  have hT' : |T| = T := abs_eq_self.mpr hT.out.le
  let I := Ioc (-(T / 2)) (T / 2)
  have h₁ : ε < T / 2 → Metric.closedBall (0 : ℝ) ε ∩ I = Metric.closedBall (0 : ℝ) ε := by
    intro hε
    rw [inter_eq_left, Real.closedBall_eq_Icc, zero_sub, zero_add]
    rintro y ⟨hy₁, hy₂⟩; constructor <;> linarith
  have h₂ : (↑) ⁻¹' Metric.closedBall (0 : AddCircle T) ε ∩ I =
      if ε < T / 2 then Metric.closedBall (0 : ℝ) ε else I := by
    conv_rhs => rw [← if_ctx_congr (Iff.rfl : ε < T / 2 ↔ ε < T / 2) h₁ fun _ => rfl, ← hT']
    

Proof state:
T : ℝ
hT : Fact (0 < T)
x : AddCircle T
ε : ℝ
hT' : |T| = T
I : Set ℝ := Ioc (-(T / 2)) (T / 2)
h₁ : ε < T / 2 → Metric.closedBall 0 ε ∩ I = Metric.closedBall 0 ε
⊢ QuotientAddGroup.mk ⁻¹' Metric.closedBall 0 ε ∩ I = if ε < |T| / 2 then Metric.closedBall 0 ε ∩ I else I

Next tactic:
apply coe_real_preimage_closedBall_inter_eq