l3lab/ntp-mathlib huggingface dataset:
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  

Proof state:
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
⊢ ∃ b, IsLeast {g | g ∈ H ∧ 0 < g} b

Next tactic:
classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical 

Proof state:
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
⊢ ∃ b, IsLeast {g | g ∈ H ∧ 0 < g} b

Next tactic:
rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  

Proof state:
case mk.intro.intro.intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
⊢ ∃ b, IsLeast {g | g ∈ H ∧ 0 < g} b

Next tactic:
by_contra hxmin
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  by_contra hxmin
  

Proof state:
case mk.intro.intro.intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
hxmin : ¬∃ b, IsLeast {g | g ∈ H ∧ 0 < g} b
⊢ False

Next tactic:
simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
    not_le] at hxmin
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  by_contra hxmin
  simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
    not_le] at hxmin
  

Proof state:
case mk.intro.intro.intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
hxmin : ∀ (x : G), x ∈ H ∧ 0 < x → ∃ x_1, ∃ (_ : x_1 ∈ H ∧ 0 < x_1), x_1 < x
⊢ False

Next tactic:
rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  by_contra hxmin
  simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
    not_le] at hxmin
  rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
  

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
hxmin : ∀ (x : G), x ∈ H ∧ 0 < x → ∃ x_1, ∃ (_ : x_1 ∈ H ∧ 0 < x_1), x_1 < x
y : G
hxy : y < x
hyH : y ∈ H
hy₀ : 0 < y
⊢ False

Next tactic:
rcases hex y hy₀ with ⟨m, hm⟩
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  by_contra hxmin
  simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
    not_le] at hxmin
  rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
  rcases hex y hy₀ with ⟨m, hm⟩
  

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
hxmin : ∀ (x : G), x ∈ H ∧ 0 < x → ∃ x_1, ∃ (_ : x_1 ∈ H ∧ 0 < x_1), x_1 < x
y : G
hxy : y < x
hyH : y ∈ H
hy₀ : 0 < y
m : ℕ
hm : y ∈ Ioc (m • a) ((m + 1) • a)
⊢ False

Next tactic:
cases' lt_or_le m n with hmn hnm
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  by_contra hxmin
  simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
    not_le] at hxmin
  rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
  rcases hex y hy₀ with ⟨m, hm⟩
  cases' lt_or_le m n with hmn hnm
  · 

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro.inl
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
hxmin : ∀ (x : G), x ∈ H ∧ 0 < x → ∃ x_1, ∃ (_ : x_1 ∈ H ∧ 0 < x_1), x_1 < x
y : G
hxy : y < x
hyH : y ∈ H
hy₀ : 0 < y
m : ℕ
hm : y ∈ Ioc (m • a) ((m + 1) • a)
hmn : m < n
⊢ False

Next tactic:
exact hmin m hmn ⟨y, hyH, hm⟩
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  by_contra hxmin
  simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
    not_le] at hxmin
  rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
  rcases hex y hy₀ with ⟨m, hm⟩
  cases' lt_or_le m n with hmn hnm
  · exact hmin m hmn ⟨y, hyH, hm⟩
  · 

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro.inr
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
hxmin : ∀ (x : G), x ∈ H ∧ 0 < x → ∃ x_1, ∃ (_ : x_1 ∈ H ∧ 0 < x_1), x_1 < x
y : G
hxy : y < x
hyH : y ∈ H
hy₀ : 0 < y
m : ℕ
hm : y ∈ Ioc (m • a) ((m + 1) • a)
hnm : n ≤ m
⊢ False

Next tactic:
refine disjoint_left.1 hd (sub_mem hxH hyH) ⟨sub_pos.2 hxy, sub_lt_iff_lt_add'.2 ?_⟩
/-- If a nontrivial additive subgroup of a linear ordered additive commutative group is disjoint
with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive elements of this
group admits the least element. -/
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
  -- todo: move to a lemma?
  have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by
    rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩
    simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm'
    lift m to ℕ
    · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul]
      exact hg.trans_le hm
    · simp only [← Nat.cast_succ, coe_nat_zsmul] at hm hm'
      exact ⟨m, hm', hm⟩
  have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by
    rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩
    rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩
    exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩
  classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
  by_contra hxmin
  simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
    not_le] at hxmin
  rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
  rcases hex y hy₀ with ⟨m, hm⟩
  cases' lt_or_le m n with hmn hnm
  · exact hmin m hmn ⟨y, hyH, hm⟩
  · refine disjoint_left.1 hd (sub_mem hxH hyH) ⟨sub_pos.2 hxy, sub_lt_iff_lt_add'.2 ?_⟩
    

Proof state:
case mk.intro.intro.intro.intro.intro.intro.intro.intro.inr
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
hbot : H ≠ ⊥
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hex : ∀ g > 0, ∃ n, g ∈ Ioc (n • a) ((n + 1) • a)
this : ∃ n, Set.Nonempty (↑H ∩ Ioc (n • a) ((n + 1) • a))
n : ℕ
hmin : ∀ m < n, ¬Set.Nonempty (↑H ∩ Ioc (m • a) ((m + 1) • a))
x : G
hxH : x ∈ ↑H
hnx : n • a < x
hxn : x ≤ (n + 1) • a
hxmin : ∀ (x : G), x ∈ H ∧ 0 < x → ∃ x_1, ∃ (_ : x_1 ∈ H ∧ 0 < x_1), x_1 < x
y : G
hxy : y < x
hyH : y ∈ H
hy₀ : 0 < y
m : ℕ
hm : y ∈ Ioc (m • a) ((m + 1) • a)
hnm : n ≤ m
⊢ x < y + a

Next tactic:
calc x ≤ (n + 1) • a := hxn
    _ ≤ (m + 1) • a := nsmul_le_nsmul_left h₀.le (add_le_add_right hnm _)
    _ = m • a + a := succ_nsmul' _ _
    _ < y + a := add_lt_add_right hm.1 _
/-- If an additive subgroup of a linear ordered additive commutative group is disjoint with the
interval `Set.Ioo 0 a` for some positive `a`, then this is a cyclic subgroup. -/
theorem AddSubgroup.cyclic_of_isolated_zero {H : AddSubgroup G} {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, H = closure {b} := by
  

Proof state:
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
⊢ ∃ b, H = closure {b}

Next tactic:
rcases eq_or_ne H ⊥ with rfl | hbot
/-- If an additive subgroup of a linear ordered additive commutative group is disjoint with the
interval `Set.Ioo 0 a` for some positive `a`, then this is a cyclic subgroup. -/
theorem AddSubgroup.cyclic_of_isolated_zero {H : AddSubgroup G} {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, H = closure {b} := by
  rcases eq_or_ne H ⊥ with rfl | hbot
  · 

Proof state:
case inl
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
a : G
h₀ : 0 < a
hd : Disjoint (↑⊥) (Ioo 0 a)
⊢ ∃ b, ⊥ = closure {b}

Next tactic:
exact ⟨0, closure_singleton_zero.symm⟩
/-- If an additive subgroup of a linear ordered additive commutative group is disjoint with the
interval `Set.Ioo 0 a` for some positive `a`, then this is a cyclic subgroup. -/
theorem AddSubgroup.cyclic_of_isolated_zero {H : AddSubgroup G} {a : G} (h₀ : 0 < a)
    (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, H = closure {b} := by
  rcases eq_or_ne H ⊥ with rfl | hbot
  · exact ⟨0, closure_singleton_zero.symm⟩
  · 

Proof state:
case inr
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
a : G
h₀ : 0 < a
hd : Disjoint (↑H) (Ioo 0 a)
hbot : H ≠ ⊥
⊢ ∃ b, H = closure {b}

Next tactic:
exact (exists_isLeast_pos hbot h₀ hd).imp fun _ => cyclic_of_min
/-- Every subgroup of `ℤ` is cyclic. -/
theorem Int.subgroup_cyclic (H : AddSubgroup ℤ) : ∃ a, H = AddSubgroup.closure {a} :=
  have : Ioo (0 : ℤ) 1 = ∅ := eq_empty_of_forall_not_mem fun m hm =>
    hm.1.not_le (lt_add_one_iff.1 hm.2)
  AddSubgroup.cyclic_of_isolated_zero one_pos <| by 

Proof state:
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup ℤ
this : Ioo 0 1 = ∅
⊢ Disjoint (↑H) (Ioo 0 1)

Next tactic:
simp [this]
@[simp]
theorem abs_neg (a : α) : |(-a)| = |a| := by 

Proof state:
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
a : α
⊢ |(-a)| = |a|

Next tactic:
rw [abs_eq_max_neg, max_comm, neg_neg, abs_eq_max_neg]
theorem eq_or_eq_neg_of_abs_eq {a b : α} (h : |a| = b) : a = b ∨ a = -b := by
  

Proof state:
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
a b : α
h : |a| = b
⊢ a = b ∨ a = -b

Next tactic:
simpa only [← h, eq_comm (a := |a|), neg_eq_iff_eq_neg] using abs_choice a
theorem abs_eq_abs {a b : α} : |a| = |b| ↔ a = b ∨ a = -b := by
  

Proof state:
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
a b : α
⊢ |a| = |b| ↔ a = b ∨ a = -b

Next tactic:
refine' ⟨fun h => _, fun h => _⟩
theorem abs_eq_abs {a b : α} : |a| = |b| ↔ a = b ∨ a = -b := by
  refine' ⟨fun h => _, fun h => _⟩
  · 

Proof state:
case refine'_1
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
a b : α
h : |a| = |b|
⊢ a = b ∨ a = -b

Next tactic:
obtain rfl | rfl := eq_or_eq_neg_of_abs_eq h
theorem abs_eq_abs {a b : α} : |a| = |b| ↔ a = b ∨ a = -b := by
  refine' ⟨fun h => _, fun h => _⟩
  · obtain rfl | rfl := eq_or_eq_neg_of_abs_eq h <;>
      

Proof state:
case refine'_1.inl
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
b : α
h : |(|b|)| = |b|
⊢ |b| = b ∨ |b| = -b

Next tactic:
simpa only [neg_eq_iff_eq_neg (a := |b|), neg_inj, or_comm] using abs_choice b
theorem abs_eq_abs {a b : α} : |a| = |b| ↔ a = b ∨ a = -b := by
  refine' ⟨fun h => _, fun h => _⟩
  · obtain rfl | rfl := eq_or_eq_neg_of_abs_eq h <;>
      

Proof state:
case refine'_1.inr
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
b : α
h : |(-|b|)| = |b|
⊢ -|b| = b ∨ -|b| = -b

Next tactic:
simpa only [neg_eq_iff_eq_neg (a := |b|), neg_inj, or_comm] using abs_choice b
theorem abs_eq_abs {a b : α} : |a| = |b| ↔ a = b ∨ a = -b := by
  refine' ⟨fun h => _, fun h => _⟩
  · obtain rfl | rfl := eq_or_eq_neg_of_abs_eq h <;>
      simpa only [neg_eq_iff_eq_neg (a := |b|), neg_inj, or_comm] using abs_choice b
  · 

Proof state:
case refine'_2
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
a b : α
h : a = b ∨ a = -b
⊢ |a| = |b|

Next tactic:
cases' h with h h
theorem abs_eq_abs {a b : α} : |a| = |b| ↔ a = b ∨ a = -b := by
  refine' ⟨fun h => _, fun h => _⟩
  · obtain rfl | rfl := eq_or_eq_neg_of_abs_eq h <;>
      simpa only [neg_eq_iff_eq_neg (a := |b|), neg_inj, or_comm] using abs_choice b
  · cases' h with h h <;>
    

Proof state:
case refine'_2.inl
α : Type u_1
inst✝¹ : AddGroup α
inst✝ : LinearOrder α
a b : α
h : a = b
⊢ |a| = |b|

Next tactic:
simp [h, abs_neg]