l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : diag s = image (fun a => (a, a)) s
⊢ card (image (fun a => (a, a)) s) = card s

Next tactic:
apply card_image_of_injOn
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    

Proof state:
case H
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : diag s = image (fun a => (a, a)) s
⊢ Set.InjOn (fun a => (a, a)) ↑s

Next tactic:
exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ diag s = image (fun a => (a, a)) s

Next tactic:
ext ⟨a₁, a₂⟩
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  

Proof state:
case a.mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂) ∈ diag s ↔ (a₁, a₂) ∈ image (fun a => (a, a)) s

Next tactic:
rw [mem_diag]
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  

Proof state:
case a.mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2 ↔ (a₁, a₂) ∈ image (fun a => (a, a)) s

Next tactic:
constructor
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> 

Proof state:
case a.mk.mp
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2 → (a₁, a₂) ∈ image (fun a => (a, a)) s

Next tactic:
intro h
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> 

Proof state:
case a.mk.mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂) ∈ image (fun a => (a, a)) s → (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

Next tactic:
intro h
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> 

Proof state:
case a.mk.mp
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
⊢ (a₁, a₂) ∈ image (fun a => (a, a)) s

Next tactic:
rw [Finset.mem_image] at *
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> 

Proof state:
case a.mk.mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂) ∈ image (fun a => (a, a)) s
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

Next tactic:
rw [Finset.mem_image] at *
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> rw [Finset.mem_image] at *
  · 

Proof state:
case a.mk.mp
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
⊢ ∃ a ∈ s, (a, a) = (a₁, a₂)

Next tactic:
use a₁
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> rw [Finset.mem_image] at *
  · use a₁
    

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
⊢ a₁ ∈ s ∧ (a₁, a₁) = (a₁, a₂)

Next tactic:
simpa using h
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> rw [Finset.mem_image] at *
  · use a₁
    simpa using h
  · 

Proof state:
case a.mk.mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : ∃ a ∈ s, (a, a) = (a₁, a₂)
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

Next tactic:
rcases h with ⟨a, h1, h2⟩
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> rw [Finset.mem_image] at *
  · use a₁
    simpa using h
  · rcases h with ⟨a, h1, h2⟩
    

Proof state:
case a.mk.mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

Next tactic:
have h := Prod.mk.inj h2
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> rw [Finset.mem_image] at *
  · use a₁
    simpa using h
  · rcases h with ⟨a, h1, h2⟩
    have h := Prod.mk.inj h2
    

Proof state:
case a.mk.mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
h : a = a₁ ∧ a = a₂
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

Next tactic:
rw [← h.1, ← h.2]
@[simp]
theorem diag_card : (diag s).card = s.card := by
  suffices diag s = s.image fun a => (a, a) by
    rw [this]
    apply card_image_of_injOn
    exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
  ext ⟨a₁, a₂⟩
  rw [mem_diag]
  constructor <;> intro h <;> rw [Finset.mem_image] at *
  · use a₁
    simpa using h
  · rcases h with ⟨a, h1, h2⟩
    have h := Prod.mk.inj h2
    rw [← h.1, ← h.2]
    

Proof state:
case a.mk.mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
h : a = a₁ ∧ a = a₂
⊢ (a, a).1 ∈ s ∧ (a, a).1 = (a, a).2

Next tactic:
use h1
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => { rw [← s.diag_card] }
    simp only [diag_card] at *
    rw [tsub_eq_of_eq_add_rev]
    rw [this]
  by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ card (diag s) + card (offDiag s) = card s * card s

Next tactic:
rw [← card_product, diag, offDiag]
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => { rw [← s.diag_card] }
    simp only [diag_card] at *
    rw [tsub_eq_of_eq_add_rev]
    rw [this]
  by rw [← card_product, diag, offDiag]
     

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ card (filter (fun a => a.1 = a.2) (s ×ˢ s)) + card (filter (fun a => a.1 ≠ a.2) (s ×ˢ s)) = card (s ×ˢ s)

Next tactic:
conv_rhs => rw [← filter_card_add_filter_neg_card_eq_card (fun a => a.1 = a.2)]
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => { rw [← s.diag_card] }
    simp only [diag_card] at *
    rw [tsub_eq_of_eq_add_rev]
    rw [this]
  by rw [← card_product, diag, offDiag]
     conv_rhs => 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
| card (s ×ˢ s)

Next tactic:
rw [← filter_card_add_filter_neg_card_eq_card (fun a => a.1 = a.2)]
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : card (diag s) + card (offDiag s) = card s * card s
⊢ card (offDiag s) = card s * card s - card s

Next tactic:
conv_rhs => { rw [← s.diag_card] }
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : card (diag s) + card (offDiag s) = card s * card s
| card s * card s - card s

Next tactic:
{ rw [← s.diag_card] }
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => { 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : card (diag s) + card (offDiag s) = card s * card s
| card s * card s - card s

Next tactic:
rw [← s.diag_card]
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => { rw [← s.diag_card] }
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : card (diag s) + card (offDiag s) = card s * card s
⊢ card (offDiag s) = card (diag s) * card (diag s) - card (diag s)

Next tactic:
simp only [diag_card] at *
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => { rw [← s.diag_card] }
    simp only [diag_card] at *
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : card s + card (offDiag s) = card s * card s
⊢ card (offDiag s) = card s * card s - card s

Next tactic:
rw [tsub_eq_of_eq_add_rev]
@[simp]
theorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=
  suffices (diag s).card + (offDiag s).card = s.card * s.card by
    conv_rhs => { rw [← s.diag_card] }
    simp only [diag_card] at *
    rw [tsub_eq_of_eq_add_rev]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : card s + card (offDiag s) = card s * card s
⊢ card s * card s = card s + card (offDiag s)

Next tactic:
rw [this]
@[simp]
theorem diag_union_offDiag : s.diag ∪ s.offDiag = s ×ˢ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ diag s ∪ offDiag s = s ×ˢ s

Next tactic:
conv_rhs => rw [← filter_union_filter_neg_eq (fun a => a.1 = a.2) (s ×ˢ s)]
@[simp]
theorem diag_union_offDiag : s.diag ∪ s.offDiag = s ×ˢ s := by
  conv_rhs => 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
| s ×ˢ s

Next tactic:
rw [← filter_union_filter_neg_eq (fun a => a.1 = a.2) (s ×ˢ s)]
theorem product_sdiff_diag : s ×ˢ s \ s.diag = s.offDiag := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ s ×ˢ s \ diag s = offDiag s

Next tactic:
rw [← diag_union_offDiag, union_comm, union_sdiff_self,
    sdiff_eq_self_of_disjoint (disjoint_diag_offDiag _).symm]
theorem product_sdiff_offDiag : s ×ˢ s \ s.offDiag = s.diag := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ s ×ˢ s \ offDiag s = diag s

Next tactic:
rw [← diag_union_offDiag, union_sdiff_self, sdiff_eq_self_of_disjoint (disjoint_diag_offDiag _)]
theorem diag_inter : (s ∩ t).diag = s.diag ∩ t.diag :=
  ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x✝ x : α × α
⊢ x ∈ diag (s ∩ t) ↔ x ∈ diag s ∩ diag t

Next tactic:
simpa only [mem_diag, mem_inter] using and_and_right
theorem offDiag_inter : (s ∩ t).offDiag = s.offDiag ∩ t.offDiag :=
  coe_injective <| by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ ↑(offDiag (s ∩ t)) = ↑(offDiag s ∩ offDiag t)

Next tactic:
push_cast
theorem offDiag_inter : (s ∩ t).offDiag = s.offDiag ∩ t.offDiag :=
  coe_injective <| by
    push_cast
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ Set.offDiag (↑s ∩ ↑t) = Set.offDiag ↑s ∩ Set.offDiag ↑t

Next tactic:
exact Set.offDiag_inter _ _
theorem diag_union : (s ∪ t).diag = s.diag ∪ t.diag := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ diag (s ∪ t) = diag s ∪ diag t

Next tactic:
ext ⟨i, j⟩
theorem diag_union : (s ∪ t).diag = s.diag ∪ t.diag := by
  ext ⟨i, j⟩
  

Proof state:
case a.mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
i j : α
⊢ (i, j) ∈ diag (s ∪ t) ↔ (i, j) ∈ diag s ∪ diag t

Next tactic:
simp only [mem_diag, mem_union, or_and_right]
theorem offDiag_union (h : Disjoint s t) :
    (s ∪ t).offDiag = s.offDiag ∪ t.offDiag ∪ s ×ˢ t ∪ t ×ˢ s :=
  coe_injective <| by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
h : _root_.Disjoint s t
⊢ ↑(offDiag (s ∪ t)) = ↑(offDiag s ∪ offDiag t ∪ s ×ˢ t ∪ t ×ˢ s)

Next tactic:
push_cast
theorem offDiag_union (h : Disjoint s t) :
    (s ∪ t).offDiag = s.offDiag ∪ t.offDiag ∪ s ×ˢ t ∪ t ×ˢ s :=
  coe_injective <| by
    push_cast
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
h : _root_.Disjoint s t
⊢ Set.offDiag (↑s ∪ ↑t) = Set.offDiag ↑s ∪ Set.offDiag ↑t ∪ ↑s ×ˢ ↑t ∪ ↑t ×ˢ ↑s

Next tactic:
exact Set.offDiag_union (disjoint_coe.2 h)
@[simp]
theorem offDiag_singleton : ({a} : Finset α).offDiag = ∅ := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a : α
⊢ offDiag {a} = ∅

Next tactic:
simp [← Finset.card_eq_zero]
theorem diag_singleton : ({a} : Finset α).diag = {(a, a)} := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a : α
⊢ diag {a} = {(a, a)}

Next tactic:
rw [← product_sdiff_offDiag, offDiag_singleton, sdiff_empty, singleton_product_singleton]
theorem diag_insert : (insert a s).diag = insert (a, a) s.diag := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a : α
⊢ diag (insert a s) = insert (a, a) (diag s)

Next tactic:
rw [insert_eq, insert_eq, diag_union, diag_singleton]
theorem offDiag_insert (has : a ∉ s) : (insert a s).offDiag = s.offDiag ∪ {a} ×ˢ s ∪ s ×ˢ {a} := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a : α
has : a ∉ s
⊢ offDiag (insert a s) = offDiag s ∪ {a} ×ˢ s ∪ s ×ˢ {a}

Next tactic:
rw [insert_eq, union_comm, offDiag_union (disjoint_singleton_right.2 has), offDiag_singleton,
    union_empty, union_right_comm]
/-- Unit ball in a non unital semi normed ring as a bundled `Subsemigroup`. -/
def Subsemigroup.unitBall (𝕜 : Type*) [NonUnitalSeminormedRing 𝕜] : Subsemigroup 𝕜
    where
  carrier := ball (0 : 𝕜) 1
  mul_mem' hx hy := by
    

Proof state:
𝕜✝ : Type u_1
𝕜 : Type u_2
inst✝ : NonUnitalSeminormedRing 𝕜
a✝ b✝ : 𝕜
hx : a✝ ∈ ball 0 1
hy : b✝ ∈ ball 0 1
⊢ a✝ * b✝ ∈ ball 0 1

Next tactic:
rw [mem_ball_zero_iff] at *
/-- Unit ball in a non unital semi normed ring as a bundled `Subsemigroup`. -/
def Subsemigroup.unitBall (𝕜 : Type*) [NonUnitalSeminormedRing 𝕜] : Subsemigroup 𝕜
    where
  carrier := ball (0 : 𝕜) 1
  mul_mem' hx hy := by
    rw [mem_ball_zero_iff] at *
    

Proof state:
𝕜✝ : Type u_1
𝕜 : Type u_2
inst✝ : NonUnitalSeminormedRing 𝕜
a✝ b✝ : 𝕜
hx : ‖a✝‖ < 1
hy : ‖b✝‖ < 1
⊢ ‖a✝ * b✝‖ < 1

Next tactic:
exact (norm_mul_le _ _).trans_lt (mul_lt_one_of_nonneg_of_lt_one_left (norm_nonneg _) hx hy.le)
/-- Closed unit ball in a non unital semi normed ring as a bundled `Subsemigroup`. -/
def Subsemigroup.unitClosedBall (𝕜 : Type*) [NonUnitalSeminormedRing 𝕜] : Subsemigroup 𝕜
    where
  carrier := closedBall 0 1
  mul_mem' hx hy := by
    

Proof state:
𝕜✝ : Type u_1
𝕜 : Type u_2
inst✝ : NonUnitalSeminormedRing 𝕜
a✝ b✝ : 𝕜
hx : a✝ ∈ closedBall 0 1
hy : b✝ ∈ closedBall 0 1
⊢ a✝ * b✝ ∈ closedBall 0 1

Next tactic:
rw [mem_closedBall_zero_iff] at *
/-- Closed unit ball in a non unital semi normed ring as a bundled `Subsemigroup`. -/
def Subsemigroup.unitClosedBall (𝕜 : Type*) [NonUnitalSeminormedRing 𝕜] : Subsemigroup 𝕜
    where
  carrier := closedBall 0 1
  mul_mem' hx hy := by
    rw [mem_closedBall_zero_iff] at *
    

Proof state:
𝕜✝ : Type u_1
𝕜 : Type u_2
inst✝ : NonUnitalSeminormedRing 𝕜
a✝ b✝ : 𝕜
hx : ‖a✝‖ ≤ 1
hy : ‖b✝‖ ≤ 1
⊢ ‖a✝ * b✝‖ ≤ 1

Next tactic:
exact (norm_mul_le _ _).trans (mul_le_one hx (norm_nonneg _) hy)
/-- Unit sphere in a normed division ring as a bundled `Submonoid`. -/
def Submonoid.unitSphere (𝕜 : Type*) [NormedDivisionRing 𝕜] : Submonoid 𝕜
    where
  carrier := sphere (0 : 𝕜) 1
  mul_mem' hx hy := by
    

Proof state:
𝕜✝ : Type u_1
𝕜 : Type u_2
inst✝ : NormedDivisionRing 𝕜
a✝ b✝ : 𝕜
hx : a✝ ∈ sphere 0 1
hy : b✝ ∈ sphere 0 1
⊢ a✝ * b✝ ∈ sphere 0 1

Next tactic:
rw [mem_sphere_zero_iff_norm] at *
/-- Unit sphere in a normed division ring as a bundled `Submonoid`. -/
def Submonoid.unitSphere (𝕜 : Type*) [NormedDivisionRing 𝕜] : Submonoid 𝕜
    where
  carrier := sphere (0 : 𝕜) 1
  mul_mem' hx hy := by
    rw [mem_sphere_zero_iff_norm] at *
    

Proof state:
𝕜✝ : Type u_1
𝕜 : Type u_2
inst✝ : NormedDivisionRing 𝕜
a✝ b✝ : 𝕜
hx : ‖a✝‖ = 1
hy : ‖b✝‖ = 1
⊢ ‖a✝ * b✝‖ = 1

Next tactic:
simp [*]
instance Metric.unitSphere.inv [NormedDivisionRing 𝕜] : Inv (sphere (0 : 𝕜) 1) :=
  ⟨fun x =>
    ⟨x⁻¹,
      mem_sphere_zero_iff_norm.2 <| by
        

Proof state:
𝕜 : Type u_1
inst✝ : NormedDivisionRing 𝕜
x : ↑(sphere 0 1)
⊢ ‖(↑x)⁻¹‖ = 1

Next tactic:
rw [norm_inv, mem_sphere_zero_iff_norm.1 x.coe_prop, inv_one]
instance Metric.unitSphere.div [NormedDivisionRing 𝕜] : Div (sphere (0 : 𝕜) 1) :=
  ⟨fun x y =>
    ⟨x / y,
      mem_sphere_zero_iff_norm.2 <| by
        

Proof state:
𝕜 : Type u_1
inst✝ : NormedDivisionRing 𝕜
x y : ↑(sphere 0 1)
⊢ ‖↑x / ↑y‖ = 1

Next tactic:
rw [norm_div, mem_sphere_zero_iff_norm.1 x.coe_prop, mem_sphere_zero_iff_norm.1 y.coe_prop,
          div_one]
instance Metric.unitSphere.pow [NormedDivisionRing 𝕜] : Pow (sphere (0 : 𝕜) 1) ℤ :=
  ⟨fun x n =>
    ⟨(x : 𝕜) ^ n, by
      

Proof state:
𝕜 : Type u_1
inst✝ : NormedDivisionRing 𝕜
x : ↑(sphere 0 1)
n : ℤ
⊢ ↑x ^ n ∈ sphere 0 1

Next tactic:
rw [mem_sphere_zero_iff_norm, norm_zpow, mem_sphere_zero_iff_norm.1 x.coe_prop, one_zpow]
theorem unitSphereToUnits_injective [NormedDivisionRing 𝕜] :
    Function.Injective (unitSphereToUnits 𝕜) := fun x y h =>
  Subtype.eq <| by 

Proof state:
𝕜 : Type u_1
inst✝ : NormedDivisionRing 𝕜
x y : ↑(sphere 0 1)
h : (unitSphereToUnits 𝕜) x = (unitSphereToUnits 𝕜) y
⊢ ↑x = ↑y

Next tactic:
convert congr_arg Units.val h
/-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there
exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G}
    (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by
  

Proof state:
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
a : G
ha : IsLeast {g | g ∈ H ∧ 0 < g} a
⊢ H = closure {a}

Next tactic:
obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha
/-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there
exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G}
    (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by
  obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha
  

Proof state:
case intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
a : G
a_min : a ∈ lowerBounds {g | g ∈ H ∧ 0 < g}
a_in : a ∈ H
a_pos : 0 < a
⊢ H = closure {a}

Next tactic:
refine' le_antisymm _ (H.closure_le.mpr <| by simp [a_in])
/-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there
exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G}
    (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by
  obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha
  refine' le_antisymm _ (H.closure_le.mpr <| by 

Proof state:
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
a : G
a_min : a ∈ lowerBounds {g | g ∈ H ∧ 0 < g}
a_in : a ∈ H
a_pos : 0 < a
⊢ {a} ⊆ ↑H

Next tactic:
simp [a_in]
/-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there
exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G}
    (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by
  obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha
  refine' le_antisymm _ (H.closure_le.mpr <| by simp [a_in])
  

Proof state:
case intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
a : G
a_min : a ∈ lowerBounds {g | g ∈ H ∧ 0 < g}
a_in : a ∈ H
a_pos : 0 < a
⊢ H ≤ closure {a}

Next tactic:
intro g g_in
/-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there
exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G}
    (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by
  obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha
  refine' le_antisymm _ (H.closure_le.mpr <| by simp [a_in])
  intro g g_in
  

Proof state:
case intro.intro
G : Type u_1
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : Archimedean G
H : AddSubgroup G
a : G
a_min : a ∈ lowerBounds {g | g ∈ H ∧ 0 < g}
a_in : a ∈ H
a_pos : 0 < a
g : G
g_in : g ∈ H
⊢ g ∈ closure {a}

Next tactic:
obtain ⟨k, ⟨nonneg, lt⟩, _⟩ := existsUnique_zsmul_near_of_pos' a_pos g