[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.CompleteLattice.Lemmas).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
theorem iSup_bool_eq {f : Bool → α} : ⨆ b : Bool, f b = f true ⊔ f false
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_bool_eq (L56-L58)
theorem iInf_bool_eq {f : Bool → α} : ⨅ b : Bool, f b = f true ⊓ f false :=
@iSup_bool_eq αᵒᵈ _ _
```

-- snippet 2
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.sup_eq_iSup (L59-L61)
theorem sup_eq_iSup (x y : α) : x ⊔ y = ⨆ b : Bool, cond b x y := by
rw [iSup_bool_eq, Bool.cond_true, Bool.cond_false]
```

-- snippet 3
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.inf_eq_iInf (L62-L69)
theorem inf_eq_iInf (x y : α) : x ⊓ y = ⨅ b : Bool, cond b x y :=
@sup_eq_iSup αᵒᵈ _ _ _

/-!
### `iSup` and `iInf` under `ℕ`
-/
```

-- snippet 4
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_ge_eq_iSup_nat_add (L70-L76)
theorem iSup_ge_eq_iSup_nat_add (u : ℕ → α) (n : ℕ) : ⨆ i ≥ n, u i = ⨆ i, u (i + n) := by
apply le_antisymm <;> simp only [iSup_le_iff]
  · refine fun i hi => le_sSup ⟨i - n, ?_⟩
    dsimp only
    rw [Nat.sub_add_cancel hi]
  · exact fun i => le_sSup ⟨i + n, iSup_pos (Nat.le_add_left _ _)⟩
```

-- snippet 5
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_ge_eq_iInf_nat_add (L77-L79)
theorem iInf_ge_eq_iInf_nat_add (u : ℕ → α) (n : ℕ) : ⨅ i ≥ n, u i = ⨅ i, u (i + n) :=
@iSup_ge_eq_iSup_nat_add αᵒᵈ _ _ _
```

-- snippet 6
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.Monotone (L80-L82)
theorem Monotone.iSup_nat_add {f : ℕ → α} (hf : Monotone f) (k : ℕ) : ⨆ n, f (n + k) = ⨆ n, f n :=
le_antisymm (iSup_le fun i => le_iSup _ (i + k)) <| iSup_mono fun i => hf <| Nat.le_add_right i k
```

-- snippet 7
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.Antitone (L83-L88)
theorem Antitone.iInf_nat_add {f : ℕ → α} (hf : Antitone f) (k : ℕ) : ⨅ n, f (n + k) = ⨅ n, f n :=
hf.dual_right.iSup_nat_add k

-- Not `@[simp]` since the subterm `?f (i + ?k)` produces an ugly higher-order unification problem.
-- (Although the `simpNF` linter does not complain.)
-- See: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/complete_lattice.20and.20has_sup/near/316497982
```

-- snippet 8
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_iInf_ge_nat_add (L89-L97)
theorem iSup_iInf_ge_nat_add (f : ℕ → α) (k : ℕ) :
    ⨆ n, ⨅ i ≥ n, f (i + k) = ⨆ n, ⨅ i ≥ n, f i := by
have hf : Monotone fun n => ⨅ i ≥ n, f i := fun n m h => biInf_mono fun i => h.trans
  rw [← Monotone.iSup_nat_add hf k]
  · simp_rw [iInf_ge_eq_iInf_nat_add, ← Nat.add_assoc]

-- Not `@[simp]` since the subterm `?f (i + ?k)` produces an ugly higher-order unification problem.
-- (Although the `simpNF` linter does not complain.)
-- See: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/complete_lattice.20and.20has_sup/near/316497982
```

-- snippet 9
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_iSup_ge_nat_add (L98-L101)
theorem iInf_iSup_ge_nat_add :
    ∀ (f : ℕ → α) (k : ℕ), ⨅ n, ⨆ i ≥ n, f (i + k) = ⨅ n, ⨆ i ≥ n, f i :=
@iSup_iInf_ge_nat_add αᵒᵈ _
```

-- snippet 10
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.sup_iSup_nat_succ (L102-L107)
theorem sup_iSup_nat_succ (u : ℕ → α) : (u 0 ⊔ ⨆ i, u (i + 1)) = ⨆ i, u i :=
calc
    (u 0 ⊔ ⨆ i, u (i + 1)) = ⨆ x ∈ {0} ∪ range Nat.succ, u x := by
      { rw [iSup_union, iSup_singleton, iSup_range] }
    _ = ⨆ i, u i := by rw [Nat.zero_union_range_succ, iSup_univ]
```

-- snippet 11
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.inf_iInf_nat_succ (L108-L110)
theorem inf_iInf_nat_succ (u : ℕ → α) : (u 0 ⊓ ⨅ i, u (i + 1)) = ⨅ i, u i :=
@sup_iSup_nat_succ αᵒᵈ _ u
```

-- snippet 12
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_nat_gt_zero_eq (L111-L114)
theorem iInf_nat_gt_zero_eq (f : ℕ → α) : ⨅ i > 0, f i = ⨅ i, f (i + 1) := by
rw [← iInf_range, Nat.range_succ]
  simp
```

-- snippet 13
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_nat_gt_zero_eq (L115-L117)
theorem iSup_nat_gt_zero_eq (f : ℕ → α) : ⨆ i > 0, f i = ⨆ i, f (i + 1) :=
@iInf_nat_gt_zero_eq αᵒᵈ _ f
```

-- snippet 14
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.sup_sInf_le_iInf_sup (L129-L132)
theorem sup_sInf_le_iInf_sup : a ⊔ sInf s ≤ ⨅ b ∈ s, a ⊔ b :=
le_iInf₂ fun _ h => sup_le_sup_left (sInf_le h) _

/-- This is a weaker version of `inf_sSup_eq` -/
```

-- snippet 15
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_inf_le_inf_sSup (L133-L136)
theorem iSup_inf_le_inf_sSup : ⨆ b ∈ s, a ⊓ b ≤ a ⊓ sSup s :=
@sup_sInf_le_iInf_sup αᵒᵈ _ _ _

/-- This is a weaker version of `sInf_sup_eq` -/
```

-- snippet 16
```lean
-- Mathlib.Order.CompleteLattice.Basic.biSup_congr (L161-L164)
theorem biSup_congr {p : ι → Prop} (h : ∀ i, p i → f i = g i) :
    ⨆ (i) (_ : p i), f i = ⨆ (i) (_ : p i), g i :=
iSup_congr fun i ↦ iSup_congr (h i)
```

-- snippet 17
```lean
-- Mathlib.Order.CompleteLattice.Basic.iSup_congr (L157-L159)
theorem iSup_congr (h : ∀ i, f i = g i) : ⨆ i, f i = ⨆ i, g i :=
congr_arg _ <| funext h
```

-- snippet 18
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_le_sSup_of_subset_insert_bot (L97-L99)
theorem sSup_le_sSup_of_subset_insert_bot (h : s ⊆ insert ⊥ t) : sSup s ≤ sSup t :=
(sSup_le_sSup h).trans_eq (sSup_insert.trans (bot_sup_eq _))
```

-- snippet 19
```lean
-- Mathlib.Order.CompleteLattice.Basic.eq_singleton_bot_of_sSup_eq_bot_of_nonempty (L119-L128)
theorem eq_singleton_bot_of_sSup_eq_bot_of_nonempty {s : Set α} (h_sup : sSup s = ⊥)
    (hne : s.Nonempty) : s = {⊥} := by
rw [Set.eq_singleton_iff_nonempty_unique_mem]
  rw [sSup_eq_bot] at h_sup
  exact ⟨hne, h_sup⟩

/-- Introduction rule to prove that `b` is the supremum of `s`: it suffices to check that `b`
is larger than all elements of `s`, and that this is not the case of any `w < b`.
See `csSup_eq_of_forall_le_of_forall_lt_exists_gt` for a version in conditionally complete
lattices. -/
```

-- snippet 20
```lean
-- Mathlib.Order.CompleteLattice.Basic.Function (L172-L177)
theorem Function.Surjective.iSup_comp {f : ι → ι'} (hf : Surjective f) (g : ι' → α) :
    ⨆ x, g (f x) = ⨆ y, g y := by
simp only [iSup.eq_1]
  congr
  exact hf.range_comp g
```

-- snippet 21
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_insert (L93-L95)
theorem sSup_insert {a : α} {s : Set α} : sSup (insert a s) = a ⊔ sSup s :=
((isLUB_sSup s).insert a).sSup_eq
```

-- snippet 22
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_diff_singleton_bot (L101-L104)
theorem sSup_diff_singleton_bot (s : Set α) : sSup (s \ {⊥}) = sSup s :=
(sSup_le_sSup diff_subset).antisymm <|
    sSup_le_sSup_of_subset_insert_bot <| subset_insert_diff_singleton _ _
```

-- snippet 23
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_of_forall_le_of_forall_lt_exists_gt (L134-L139)
theorem sSup_eq_of_forall_le_of_forall_lt_exists_gt (h₁ : ∀ a ∈ s, a ≤ b)
    (h₂ : ∀ w, w < b → ∃ a ∈ s, w < a) : sSup s = b :=
(sSup_le h₁).eq_of_not_lt fun h =>
    let ⟨_, ha, ha'⟩ := h₂ _ h
    ((le_sSup ha).trans_lt ha').false
```

-- snippet 24
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_univ (L88-L91)
theorem sSup_univ : sSup univ = (⊤ : α) :=
(@isLUB_univ α _ _).sSup_eq

-- TODO(Jeremy): get this automatically
```

-- snippet 25
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_le_sSup_of_isCofinalFor (L53-L56)
theorem sSup_le_sSup_of_isCofinalFor (h : IsCofinalFor s t) : sSup s ≤ sSup t :=
IsLeast.mono (isLUB_sSup t) (isLUB_sSup s) <| upperBounds_mono_of_isCofinalFor h

-- We will generalize this to conditionally complete lattices in `csSup_singleton`.
```

-- snippet 26
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_empty (L84-L86)
theorem sSup_empty : sSup ∅ = (⊥ : α) :=
(@isLUB_empty α _ _).sSup_eq
```

-- snippet 27
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_iSup' (L154-L155)
theorem sSup_eq_iSup' (s : Set α) : sSup s = ⨆ a : s, (a : α) := by rw [iSup, Subtype.range_coe]
```

-- snippet 28
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_range (L150-L152)
theorem sSup_range : sSup (range f) = iSup f :=
rfl
```

-- snippet 29
```lean
-- Mathlib.Order.CompleteLattice.Basic.sInf_le_sSup_of_nonempty_inter (L72-L74)
theorem sInf_le_sSup_of_nonempty_inter (h : (s ∩ t).Nonempty) : sInf s ≤ sSup t :=
isGLB_le_isLUB_of_nonempty_inter h (isGLB_sInf s) (isLUB_sSup t)
```

-- snippet 30
```lean
-- Mathlib.Order.CompleteLattice.Basic.iSup_congr_Prop (L194-L199)
theorem iSup_congr_Prop {p q : Prop} {f₁ : p → α} {f₂ : q → α} (pq : p ↔ q)
    (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iSup f₁ = iSup f₂ := by
obtain rfl := propext pq
  congr with x
  apply f
```

-- snippet 31
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_bot' (L115-L117)
lemma sSup_eq_bot' {s : Set α} : sSup s = ⊥ ↔ s = ∅ ∨ s = {⊥} := by
rw [sSup_eq_bot, ← subset_singleton_iff_eq, subset_singleton_iff]
```

-- snippet 32
```lean
-- Mathlib.Order.CompleteLattice.Basic.sInf_le_sSup (L69-L71)
theorem sInf_le_sSup (hs : s.Nonempty) : sInf s ≤ sSup s :=
isGLB_le_isLUB (isGLB_sInf s) (isLUB_sSup s) hs
```

-- snippet 33
```lean
-- Mathlib.Order.CompleteLattice.Basic.iSup_plift_up (L201-L203)
theorem iSup_plift_up (f : PLift ι → α) : ⨆ i, f (PLift.up i) = ⨆ i, f i :=
(PLift.up_surjective.iSup_congr _) fun _ => rfl
```

-- snippet 34
```lean
-- Mathlib.Order.CompleteLattice.Basic.Equiv (L179-L181)
theorem Equiv.iSup_comp {g : ι' → α} (e : ι ≃ ι') : ⨆ x, g (e x) = ⨆ y, g y :=
e.surjective.iSup_comp _
```

-- snippet 35
```lean
-- Mathlib.Order.CompleteLattice.Basic.biSup_congr' (L166-L170)
theorem biSup_congr' {p : ι → Prop} {f g : (i : ι) → p i → α}
    (h : ∀ i (hi : p i), f i hi = g i hi) :
    ⨆ i, ⨆ (hi : p i), f i hi = ⨆ i, ⨆ (hi : p i), g i hi := by
grind
```

-- snippet 36
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_bot (L110-L113)
theorem sSup_eq_bot : sSup s = ⊥ ↔ ∀ a ∈ s, a = ⊥ :=
⟨fun h _ ha => bot_unique <| h ▸ le_sSup ha, fun h =>
    bot_unique <| sSup_le fun a ha => le_bot_iff.2 <| h a ha⟩
```

-- snippet 37
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_inter_le (L80-L82)
theorem sSup_inter_le {s t : Set α} : sSup (s ∩ t) ≤ sSup s ⊓ sSup t :=
sSup_le fun _ hb => le_inf (le_sSup hb.1) (le_sSup hb.2)
```

-- snippet 38
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_union (L76-L78)
theorem sSup_union {s t : Set α} : sSup (s ∪ t) = sSup s ⊔ sSup t :=
((isLUB_sSup s).union (isLUB_sSup t)).sSup_eq
```

-- snippet 39
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_singleton (L58-L60)
theorem sSup_singleton {a : α} : sSup {a} = a :=
isLUB_singleton.sSup_eq
```

-- snippet 40
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_pair (L106-L108)
theorem sSup_pair {a b : α} : sSup {a, b} = a ⊔ b :=
(@isLUB_pair α _ a b).sSup_eq
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.CompleteLattice.Lemmas).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem iSup_bool_eq {f : Bool → α} : ⨆ b : Bool, f b = f true ⊔ f false
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_bool_eq (L56-L58)
theorem iInf_bool_eq {f : Bool → α} : ⨅ b : Bool, f b = f true ⊓ f false :=
@iSup_bool_eq αᵒᵈ _ _
```

-- snippet 2
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.sup_eq_iSup (L59-L61)
theorem sup_eq_iSup (x y : α) : x ⊔ y = ⨆ b : Bool, cond b x y := by
rw [iSup_bool_eq, Bool.cond_true, Bool.cond_false]
```

-- snippet 3
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.inf_eq_iInf (L62-L69)
theorem inf_eq_iInf (x y : α) : x ⊓ y = ⨅ b : Bool, cond b x y :=
@sup_eq_iSup αᵒᵈ _ _ _

/-!
### `iSup` and `iInf` under `ℕ`
-/
```

-- snippet 4
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_ge_eq_iSup_nat_add (L70-L76)
theorem iSup_ge_eq_iSup_nat_add (u : ℕ → α) (n : ℕ) : ⨆ i ≥ n, u i = ⨆ i, u (i + n) := by
apply le_antisymm <;> simp only [iSup_le_iff]
  · refine fun i hi => le_sSup ⟨i - n, ?_⟩
    dsimp only
    rw [Nat.sub_add_cancel hi]
  · exact fun i => le_sSup ⟨i + n, iSup_pos (Nat.le_add_left _ _)⟩
```

-- snippet 5
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_ge_eq_iInf_nat_add (L77-L79)
theorem iInf_ge_eq_iInf_nat_add (u : ℕ → α) (n : ℕ) : ⨅ i ≥ n, u i = ⨅ i, u (i + n) :=
@iSup_ge_eq_iSup_nat_add αᵒᵈ _ _ _
```

-- snippet 6
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.Monotone (L80-L82)
theorem Monotone.iSup_nat_add {f : ℕ → α} (hf : Monotone f) (k : ℕ) : ⨆ n, f (n + k) = ⨆ n, f n :=
le_antisymm (iSup_le fun i => le_iSup _ (i + k)) <| iSup_mono fun i => hf <| Nat.le_add_right i k
```

-- snippet 7
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.Antitone (L83-L88)
theorem Antitone.iInf_nat_add {f : ℕ → α} (hf : Antitone f) (k : ℕ) : ⨅ n, f (n + k) = ⨅ n, f n :=
hf.dual_right.iSup_nat_add k

-- Not `@[simp]` since the subterm `?f (i + ?k)` produces an ugly higher-order unification problem.
-- (Although the `simpNF` linter does not complain.)
-- See: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/complete_lattice.20and.20has_sup/near/316497982
```

-- snippet 8
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_iInf_ge_nat_add (L89-L97)
theorem iSup_iInf_ge_nat_add (f : ℕ → α) (k : ℕ) :
    ⨆ n, ⨅ i ≥ n, f (i + k) = ⨆ n, ⨅ i ≥ n, f i := by
have hf : Monotone fun n => ⨅ i ≥ n, f i := fun n m h => biInf_mono fun i => h.trans
  rw [← Monotone.iSup_nat_add hf k]
  · simp_rw [iInf_ge_eq_iInf_nat_add, ← Nat.add_assoc]

-- Not `@[simp]` since the subterm `?f (i + ?k)` produces an ugly higher-order unification problem.
-- (Although the `simpNF` linter does not complain.)
-- See: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/complete_lattice.20and.20has_sup/near/316497982
```

-- snippet 9
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_iSup_ge_nat_add (L98-L101)
theorem iInf_iSup_ge_nat_add :
    ∀ (f : ℕ → α) (k : ℕ), ⨅ n, ⨆ i ≥ n, f (i + k) = ⨅ n, ⨆ i ≥ n, f i :=
@iSup_iInf_ge_nat_add αᵒᵈ _
```

-- snippet 10
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.sup_iSup_nat_succ (L102-L107)
theorem sup_iSup_nat_succ (u : ℕ → α) : (u 0 ⊔ ⨆ i, u (i + 1)) = ⨆ i, u i :=
calc
    (u 0 ⊔ ⨆ i, u (i + 1)) = ⨆ x ∈ {0} ∪ range Nat.succ, u x := by
      { rw [iSup_union, iSup_singleton, iSup_range] }
    _ = ⨆ i, u i := by rw [Nat.zero_union_range_succ, iSup_univ]
```

-- snippet 11
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.inf_iInf_nat_succ (L108-L110)
theorem inf_iInf_nat_succ (u : ℕ → α) : (u 0 ⊓ ⨅ i, u (i + 1)) = ⨅ i, u i :=
@sup_iSup_nat_succ αᵒᵈ _ u
```

-- snippet 12
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iInf_nat_gt_zero_eq (L111-L114)
theorem iInf_nat_gt_zero_eq (f : ℕ → α) : ⨅ i > 0, f i = ⨅ i, f (i + 1) := by
rw [← iInf_range, Nat.range_succ]
  simp
```

-- snippet 13
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_nat_gt_zero_eq (L115-L117)
theorem iSup_nat_gt_zero_eq (f : ℕ → α) : ⨆ i > 0, f i = ⨆ i, f (i + 1) :=
@iInf_nat_gt_zero_eq αᵒᵈ _ f
```

-- snippet 14
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.sup_sInf_le_iInf_sup (L129-L132)
theorem sup_sInf_le_iInf_sup : a ⊔ sInf s ≤ ⨅ b ∈ s, a ⊔ b :=
le_iInf₂ fun _ h => sup_le_sup_left (sInf_le h) _

/-- This is a weaker version of `inf_sSup_eq` -/
```

-- snippet 15
```lean
-- Mathlib.Order.CompleteLattice.Lemmas.iSup_inf_le_inf_sSup (L133-L136)
theorem iSup_inf_le_inf_sSup : ⨆ b ∈ s, a ⊓ b ≤ a ⊓ sSup s :=
@sup_sInf_le_iInf_sup αᵒᵈ _ _ _

/-- This is a weaker version of `sInf_sup_eq` -/
```

-- snippet 16
```lean
-- Mathlib.Order.CompleteLattice.Basic.biSup_congr (L161-L164)
theorem biSup_congr {p : ι → Prop} (h : ∀ i, p i → f i = g i) :
    ⨆ (i) (_ : p i), f i = ⨆ (i) (_ : p i), g i :=
iSup_congr fun i ↦ iSup_congr (h i)
```

-- snippet 17
```lean
-- Mathlib.Order.CompleteLattice.Basic.iSup_congr (L157-L159)
theorem iSup_congr (h : ∀ i, f i = g i) : ⨆ i, f i = ⨆ i, g i :=
congr_arg _ <| funext h
```

-- snippet 18
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_le_sSup_of_subset_insert_bot (L97-L99)
theorem sSup_le_sSup_of_subset_insert_bot (h : s ⊆ insert ⊥ t) : sSup s ≤ sSup t :=
(sSup_le_sSup h).trans_eq (sSup_insert.trans (bot_sup_eq _))
```

-- snippet 19
```lean
-- Mathlib.Order.CompleteLattice.Basic.eq_singleton_bot_of_sSup_eq_bot_of_nonempty (L119-L128)
theorem eq_singleton_bot_of_sSup_eq_bot_of_nonempty {s : Set α} (h_sup : sSup s = ⊥)
    (hne : s.Nonempty) : s = {⊥} := by
rw [Set.eq_singleton_iff_nonempty_unique_mem]
  rw [sSup_eq_bot] at h_sup
  exact ⟨hne, h_sup⟩

/-- Introduction rule to prove that `b` is the supremum of `s`: it suffices to check that `b`
is larger than all elements of `s`, and that this is not the case of any `w < b`.
See `csSup_eq_of_forall_le_of_forall_lt_exists_gt` for a version in conditionally complete
lattices. -/
```

-- snippet 20
```lean
-- Mathlib.Order.CompleteLattice.Basic.Function (L172-L177)
theorem Function.Surjective.iSup_comp {f : ι → ι'} (hf : Surjective f) (g : ι' → α) :
    ⨆ x, g (f x) = ⨆ y, g y := by
simp only [iSup.eq_1]
  congr
  exact hf.range_comp g
```

-- snippet 21
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_insert (L93-L95)
theorem sSup_insert {a : α} {s : Set α} : sSup (insert a s) = a ⊔ sSup s :=
((isLUB_sSup s).insert a).sSup_eq
```

-- snippet 22
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_diff_singleton_bot (L101-L104)
theorem sSup_diff_singleton_bot (s : Set α) : sSup (s \ {⊥}) = sSup s :=
(sSup_le_sSup diff_subset).antisymm <|
    sSup_le_sSup_of_subset_insert_bot <| subset_insert_diff_singleton _ _
```

-- snippet 23
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_of_forall_le_of_forall_lt_exists_gt (L134-L139)
theorem sSup_eq_of_forall_le_of_forall_lt_exists_gt (h₁ : ∀ a ∈ s, a ≤ b)
    (h₂ : ∀ w, w < b → ∃ a ∈ s, w < a) : sSup s = b :=
(sSup_le h₁).eq_of_not_lt fun h =>
    let ⟨_, ha, ha'⟩ := h₂ _ h
    ((le_sSup ha).trans_lt ha').false
```

-- snippet 24
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_univ (L88-L91)
theorem sSup_univ : sSup univ = (⊤ : α) :=
(@isLUB_univ α _ _).sSup_eq

-- TODO(Jeremy): get this automatically
```

-- snippet 25
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_le_sSup_of_isCofinalFor (L53-L56)
theorem sSup_le_sSup_of_isCofinalFor (h : IsCofinalFor s t) : sSup s ≤ sSup t :=
IsLeast.mono (isLUB_sSup t) (isLUB_sSup s) <| upperBounds_mono_of_isCofinalFor h

-- We will generalize this to conditionally complete lattices in `csSup_singleton`.
```

-- snippet 26
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_empty (L84-L86)
theorem sSup_empty : sSup ∅ = (⊥ : α) :=
(@isLUB_empty α _ _).sSup_eq
```

-- snippet 27
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_iSup' (L154-L155)
theorem sSup_eq_iSup' (s : Set α) : sSup s = ⨆ a : s, (a : α) := by rw [iSup, Subtype.range_coe]
```

-- snippet 28
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_range (L150-L152)
theorem sSup_range : sSup (range f) = iSup f :=
rfl
```

-- snippet 29
```lean
-- Mathlib.Order.CompleteLattice.Basic.sInf_le_sSup_of_nonempty_inter (L72-L74)
theorem sInf_le_sSup_of_nonempty_inter (h : (s ∩ t).Nonempty) : sInf s ≤ sSup t :=
isGLB_le_isLUB_of_nonempty_inter h (isGLB_sInf s) (isLUB_sSup t)
```

-- snippet 30
```lean
-- Mathlib.Order.CompleteLattice.Basic.iSup_congr_Prop (L194-L199)
theorem iSup_congr_Prop {p q : Prop} {f₁ : p → α} {f₂ : q → α} (pq : p ↔ q)
    (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iSup f₁ = iSup f₂ := by
obtain rfl := propext pq
  congr with x
  apply f
```

-- snippet 31
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_bot' (L115-L117)
lemma sSup_eq_bot' {s : Set α} : sSup s = ⊥ ↔ s = ∅ ∨ s = {⊥} := by
rw [sSup_eq_bot, ← subset_singleton_iff_eq, subset_singleton_iff]
```

-- snippet 32
```lean
-- Mathlib.Order.CompleteLattice.Basic.sInf_le_sSup (L69-L71)
theorem sInf_le_sSup (hs : s.Nonempty) : sInf s ≤ sSup s :=
isGLB_le_isLUB (isGLB_sInf s) (isLUB_sSup s) hs
```

-- snippet 33
```lean
-- Mathlib.Order.CompleteLattice.Basic.iSup_plift_up (L201-L203)
theorem iSup_plift_up (f : PLift ι → α) : ⨆ i, f (PLift.up i) = ⨆ i, f i :=
(PLift.up_surjective.iSup_congr _) fun _ => rfl
```

-- snippet 34
```lean
-- Mathlib.Order.CompleteLattice.Basic.Equiv (L179-L181)
theorem Equiv.iSup_comp {g : ι' → α} (e : ι ≃ ι') : ⨆ x, g (e x) = ⨆ y, g y :=
e.surjective.iSup_comp _
```

-- snippet 35
```lean
-- Mathlib.Order.CompleteLattice.Basic.biSup_congr' (L166-L170)
theorem biSup_congr' {p : ι → Prop} {f g : (i : ι) → p i → α}
    (h : ∀ i (hi : p i), f i hi = g i hi) :
    ⨆ i, ⨆ (hi : p i), f i hi = ⨆ i, ⨆ (hi : p i), g i hi := by
grind
```

-- snippet 36
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_eq_bot (L110-L113)
theorem sSup_eq_bot : sSup s = ⊥ ↔ ∀ a ∈ s, a = ⊥ :=
⟨fun h _ ha => bot_unique <| h ▸ le_sSup ha, fun h =>
    bot_unique <| sSup_le fun a ha => le_bot_iff.2 <| h a ha⟩
```

-- snippet 37
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_inter_le (L80-L82)
theorem sSup_inter_le {s t : Set α} : sSup (s ∩ t) ≤ sSup s ⊓ sSup t :=
sSup_le fun _ hb => le_inf (le_sSup hb.1) (le_sSup hb.2)
```

-- snippet 38
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_union (L76-L78)
theorem sSup_union {s t : Set α} : sSup (s ∪ t) = sSup s ⊔ sSup t :=
((isLUB_sSup s).union (isLUB_sSup t)).sSup_eq
```

-- snippet 39
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_singleton (L58-L60)
theorem sSup_singleton {a : α} : sSup {a} = a :=
isLUB_singleton.sSup_eq
```

-- snippet 40
```lean
-- Mathlib.Order.CompleteLattice.Basic.sSup_pair (L106-L108)
theorem sSup_pair {a b : α} : sSup {a, b} = a ⊔ b :=
(@isLUB_pair α _ a b).sSup_eq
```
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.RingTheory.Derivation.Basic).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
theorem leibniz_inv (a : K) : D a⁻¹ = -a⁻¹ ^ 2 • D a
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.RingTheory.Derivation.Basic.toFun_eq_coe (L75-L78)
theorem toFun_eq_coe : D.toFun = ⇑D :=
rfl

/-- See Note [custom simps projection] -/
```

-- snippet 2
```lean
-- Mathlib.RingTheory.Derivation.Basic.Simps (L79-L82)
def Simps.apply (D : Derivation R A M) : A → M := D
initialize_simps_projections Derivation (toFun → apply)
```

-- snippet 3
```lean
-- Mathlib.RingTheory.Derivation.Basic.hasCoeToLinearMap (L85-L87)
instance hasCoeToLinearMap : Coe (Derivation R A M) (A →ₗ[R] M) :=
⟨fun D => D.toLinearMap⟩
```

-- snippet 4
```lean
-- Mathlib.RingTheory.Derivation.Basic.mk_coe (L89-L91)
theorem mk_coe (f : A →ₗ[R] M) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : Derivation R A M) : A → M) = f :=
rfl
```

-- snippet 5
```lean
-- Mathlib.RingTheory.Derivation.Basic.coeFn_coe (L93-L95)
theorem coeFn_coe (f : Derivation R A M) : ⇑(f : A →ₗ[R] M) = f :=
rfl
```

-- snippet 6
```lean
-- Mathlib.RingTheory.Derivation.Basic.coe_injective (L96-L98)
theorem coe_injective : @Function.Injective (Derivation R A M) (A → M) DFunLike.coe :=
DFunLike.coe_injective
```

-- snippet 7
```lean
-- Mathlib.RingTheory.Derivation.Basic.ext (L100-L102)
theorem ext (H : ∀ a, D1 a = D2 a) : D1 = D2 :=
DFunLike.ext _ _ H
```

-- snippet 8
```lean
-- Mathlib.RingTheory.Derivation.Basic.congr_fun (L103-L111)
theorem congr_fun (h : D1 = D2) (a : A) : D1 a = D2 a :=
DFunLike.congr_fun h a

protected theorem map_add : D (a + b) = D a + D b :=
  map_add D a b

protected theorem map_zero : D 0 = 0 :=
  map_zero D
```

-- snippet 9
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_smul (L113-L115)
theorem map_smul : D (r • a) = r • D a :=
D.toLinearMap.map_smul r a
```

-- snippet 10
```lean
-- Mathlib.RingTheory.Derivation.Basic.leibniz (L117-L119)
theorem leibniz : D (a * b) = a • D b + b • D a :=
D.leibniz' _ _
```

-- snippet 11
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_smul_of_tower (L121-L124)
theorem map_smul_of_tower {S : Type*} [SMul S A] [SMul S M] [LinearMap.CompatibleSMul A M S R]
    (D : Derivation R A M) (r : S) (a : A) : D (r • a) = r • D a :=
D.toLinearMap.map_smul_of_tower r a
```

-- snippet 12
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_one_eq_zero (L126-L128)
theorem map_one_eq_zero : D 1 = 0 :=
D.map_one_eq_zero'
```

-- snippet 13
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_algebraMap (L130-L132)
theorem map_algebraMap : D (algebraMap R A r) = 0 := by
rw [← mul_one r, map_mul, map_one, ← smul_def, map_smul, map_one_eq_zero, smul_zero]
```

-- snippet 14
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_natCast (L134-L136)
theorem map_natCast (n : ℕ) : D (n : A) = 0 := by
rw [← nsmul_one, D.map_smul_of_tower n, map_one_eq_zero, smul_zero]
```

-- snippet 15
```lean
-- Mathlib.RingTheory.Derivation.Basic.leibniz_pow (L138-L148)
theorem leibniz_pow (n : ℕ) : D (a ^ n) = n • a ^ (n - 1) • D a := by
induction n with
  | zero => rw [pow_zero, map_one_eq_zero, zero_smul]
  | succ n ihn =>
    rcases (zero_le n).eq_or_lt with (rfl | hpos)
    · simp
    · have : a * a ^ (n - 1) = a ^ n := by rw [← pow_succ', Nat.sub_add_cancel hpos]
      simp only [pow_succ', leibniz, ihn, smul_comm a n (_ : M), smul_smul a, add_smul, this,
        Nat.add_succ_sub_one, add_zero, one_nsmul]

open Polynomial in
```

-- snippet 16
```lean
-- Mathlib.RingTheory.Derivation.Lie.mk (L102-L105)
def mk (x : Derivation R A' A') (y : Derivation R A A)
  (h : x ∘ (Algebra.ofId A A') = (Algebra.ofId A A') ∘ y) : couple R A A' :=
⟨(x, y), (Compatible.mem _).mpr h⟩
```

-- snippet 17
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_monomial (L70-L73)
lemma mapCoeffs_monomial (n : ℕ) (x : A) :
    d.mapCoeffs (monomial n x) = .single A n (d x) := Finsupp.ext fun _ ↦ by
simp [coeff_monomial, apply_ite d, PolynomialModule.single_apply]
```

-- snippet 18
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.Differential (L80-L87)
def Differential.equiv {R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂]
    (h : R ≃+* R₂) : Differential R :=
⟨Derivation.mk' (h.symm.toAddMonoidHom.toIntLinearMap ∘ₗ
    Differential.deriv.toLinearMap ∘ₗ h.toAddMonoidHom.toIntLinearMap) (by simp)⟩

/--
Transfer a `DifferentialAlgebra` instance across a `AlgEquiv`.
-/
```

-- snippet 19
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.coeff_mapCoeffs (L127-L129)
lemma coeff_mapCoeffs (p : A[X]) (i) :
    coeff (mapCoeffs p) i = (coeff p i)′ := rfl
```

-- snippet 20
```lean
-- Mathlib.RingTheory.Derivation.Lie.mk_right (L109-L111)
lemma mk_right (x : Derivation R A' A') (y : Derivation R A A)
    (h : x ∘ (Algebra.ofId A A') = (Algebra.ofId A A') ∘ y) : (mk x y h).1.2 = y := rfl
```

-- snippet 21
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_C (L79-L84)
lemma mapCoeffs_C (x : A) :
    d.mapCoeffs (C x) = .single A 0 (d x) := by simp [← monomial_zero_left]
variable {B M' : Type*} [CommRing B] [Algebra R B] [Algebra A B]
    [AddCommGroup M'] [Module B M'] [Module R M'] [Module A M']
```

-- snippet 22
```lean
-- Mathlib.RingTheory.Derivation.Lie.bracket_eq_fun (L73-L81)
lemma bracket_eq_fun (X : Derivation R A A) (a : A) : ⁅X, a⁆ = X a := rfl
section CompatibleDerivations
variable {A' : Type*} [CommRing A'] [Algebra R A'] [Algebra A A'] [IsScalarTower R A A']

variable (R A A') in
/-- Let `σ : A → A'` be a an homomorphism. A derivation `d : A → A` and a derivation
`d' : A' → A'` are called compatible if `d' ∘ σ = σ ∘ d`. Couples of derivations
with this property form a Lie subalgebra of all couples of derivations. -/
```

-- snippet 23
```lean
-- Mathlib.RingTheory.Derivation.Lie.mem (L95-L101)
lemma mem (x : (Derivation R A' A') × (Derivation R A A)) :
    x ∈ couple R A A' ↔ x.1 ∘ Algebra.ofId A A' = Algebra.ofId A A' ∘ x.2 := by
constructor
  · intro hx; ext a; exact congrArg (· a) hx
  · intro hx; ext a; exact congrArg (· a) hx

/-- Generate an element of `couple` from `x y` satisfying the compatibility equation. -/
```

-- snippet 24
```lean
-- Mathlib.RingTheory.Derivation.Lie.commutator_apply (L48-L50)
theorem commutator_apply : ⁅D1, D2⁆ a = D1 (D2 a) - D2 (D1 a) :=
rfl
```

-- snippet 25
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_X (L75-L77)
lemma mapCoeffs_X :
    d.mapCoeffs (X : A[X]) = 0 := by simp [← monomial_one_one_eq_X]
```

-- snippet 26
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_apply (L66-L68)
lemma mapCoeffs_apply (p : A[X]) (i) :
    d.mapCoeffs p i = d (coeff p i) := rfl
```

-- snippet 27
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.mem_range_of_deriv_eq_zero (L67-L71)
lemma mem_range_of_deriv_eq_zero (A : Type*) {B : Type*} [CommRing A] [CommRing B] [Algebra A B]
    [Differential B] [Differential.ContainConstants A B] {x : B} (h : x′ = 0) :
    x ∈ (algebraMap A B).range :=
Differential.ContainConstants.mem_range_of_deriv_eq_zero h
```

-- snippet 28
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.algebraMap (L53-L66)
lemma algebraMap.coe_deriv {A : Type*} {B : Type*} [CommRing A] [CommRing B] [Algebra A B]
    [Differential A] [Differential B] [DifferentialAlgebra A B] (a : A) :
    (a′ : A) = (a : B)′ :=
(DifferentialAlgebra.deriv_algebraMap _).symm

/--
A differential ring `A` and an algebra over it `B` share constants if all
constants in B are in the range of `algebraMap A B`.
-/
class Differential.ContainConstants (A B : Type*) [CommRing A] [CommRing B]
    [Algebra A B] [Differential B] : Prop where
  /-- If the derivative of x is 0, then it's in the range of `algebraMap A B`. -/
  protected mem_range_of_deriv_eq_zero {x : B} (h : x′ = 0) : x ∈ (algebraMap A B).range
```

-- snippet 29
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.DifferentialAlgebra (L88-L100)
lemma DifferentialAlgebra.equiv {A : Type*} [CommRing A] [Differential A]
    {R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂] [Algebra A R]
    [Algebra A R₂] [DifferentialAlgebra A R₂] (h : R ≃ₐ[A] R₂) :
    letI := Differential.equiv h.toRingEquiv
DifferentialAlgebra A R :=
  letI := Differential.equiv h.toRingEquiv
  ⟨fun a ↦ by
    change (LinearMap.comp ..) _ = _
    simp only [AlgEquiv.toRingEquiv_eq_coe, RingHom.toAddMonoidHom_eq_coe,
      RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_toRingHom, LinearMap.coe_comp,
      AddMonoidHom.coe_toIntLinearMap, AddMonoidHom.coe_coe, RingHom.coe_coe, Derivation.coeFn_coe,
      Function.comp_apply, AlgEquiv.commutes, deriv_algebraMap]
    apply h.symm.commutes⟩
```

-- snippet 30
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.deriv_aeval_eq (L145-L154)
theorem deriv_aeval_eq (x : R) (p : A[X]) :
    (aeval x p)′ = aeval x (mapCoeffs p) + aeval x (derivative p) * x′ := by
convert Derivation.apply_aeval_eq' Differential.deriv _ (Algebra.linearMap A R) ..
  · simp [mapCoeffs]
  · simp [deriv_algebraMap]

/--
The unique derivation which can be made to a `DifferentialAlgebra` on `A[X]` with
`X′ = v`.
-/
```

-- snippet 31
```lean
-- Mathlib.RingTheory.Derivation.Lie.mk_left (L106-L108)
lemma mk_left (x : Derivation R A' A') (y : Derivation R A A)
    (h : x ∘ (Algebra.ofId A A') = (Algebra.ofId A A') ∘ y) : (mk x y h).1.1 = x := rfl
```

-- snippet 32
```lean
-- Mathlib.RingTheory.Derivation.Lie.apply (L112-L122)
lemma apply (x : couple R A A') (a : A) :
    x.1.1 (Algebra.ofId A A' a) = (Algebra.ofId A A')  (x.1.2 a) := by
exact congrArg (· a) x.2

end Compatible

end CompatibleDerivations

end LieStructures

end Derivation
```

-- snippet 33
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.apply_eval_eq (L109-L122)
theorem apply_eval_eq (x : A) (p : A[X]) :
    d (eval x p) = PolynomialModule.eval x (d.mapCoeffs p) + eval x (derivative p) • d x :=
apply_aeval_eq d x p

end Derivation

namespace Differential

variable {A : Type*} [CommRing A] [Differential A]

set_option backward.isDefEq.respectTransparency false in
/--
A specialization of `Derivation.mapCoeffs` for the case of a differential ring.
-/
```

-- snippet 34
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.apply_aeval_eq' (L85-L97)
theorem apply_aeval_eq' (d' : Derivation R B M') (f : M →ₗ[A] M')
    (h : ∀ a, f (d a) = d' (algebraMap A B a)) (x : B) (p : A[X]) :
    d' (aeval x p) = PolynomialModule.eval x (PolynomialModule.map B f (d.mapCoeffs p)) +
      aeval x (derivative p) • d' x := by
induction p using Polynomial.induction_on' with
  | add => simp_all only [map_add, add_smul]; abel
  | monomial =>
    simp only [aeval_monomial, leibniz, leibniz_pow, mapCoeffs_monomial,
      PolynomialModule.map_single, PolynomialModule.eval_single, derivative_monomial, map_mul,
      _root_.map_natCast, h]
    rw [add_comm, ← smul_smul, ← smul_smul, Nat.cast_smul_eq_nsmul]
```

-- snippet 35
```lean
-- Mathlib.RingTheory.Derivation.Lie.commutator_coe_linear_map (L45-L47)
theorem commutator_coe_linear_map : ↑⁅D1, D2⁆ = ⁅(D1 : Module.End R A), (D2 : Module.End R A)⁆ :=
rfl
```

-- snippet 36
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.apply_aeval_eq (L98-L108)
theorem apply_aeval_eq [IsScalarTower R A B] [IsScalarTower A B M'] (d : Derivation R B M')
    (x : B) (p : A[X]) :
    d (aeval x p) = PolynomialModule.eval x ((d.compAlgebraMap A).mapCoeffs p) +
      aeval x (derivative p) • d x := by
convert apply_aeval_eq' (d.compAlgebraMap A) d LinearMap.id _ x p
  · apply Finsupp.ext
    intro x
    rfl
  · intro a
    rfl
```

-- snippet 37
```lean
-- Mathlib.RingTheory.Derivation.Lie.instLieAlgebra (L57-L61)
instance instLieAlgebra : LieAlgebra R (Derivation R A A) :=
{ Derivation.instModule with
    lie_smul := fun r d e => by
      ext a; simp only [commutator_apply, map_smul, smul_sub, smul_apply] }
```

-- snippet 38
```lean
-- Mathlib.RingTheory.Derivation.Lie.couple (L82-L94)
def couple : LieSubalgebra R  (Derivation R A' A' × Derivation R A A) where
  carrier := { x | x.fst.compAlgebraMapL R A A' A' = (Algebra.ofId A A').toLinearMap.compDer x.snd }
add_mem' := by simp_all
  zero_mem' := by simp
  smul_mem' := by simp_all
  lie_mem' {x y} hx hy := by
    have hxx (a : A) := congrArg (fun f => f a) hx
    have hyy (a : A) := congrArg (fun f => f a) hy
    ext z
    simp at hxx hyy
    simp [Derivation.commutator_apply, hxx, hyy]

namespace Compatible
```

-- snippet 39
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs (L38-L64)
def mapCoeffs : Derivation R A[X] (PolynomialModule A M) where
  __ := (PolynomialModule.map A d.toLinearMap).comp
PolynomialModule.equivPolynomial.symm.toLinearMap
  map_one_eq_zero' := show (Finsupp.single 0 1).mapRange (d : A → M) d.map_zero = 0 by simp
  leibniz' p q := by
    dsimp
    induction p using Polynomial.induction_on' with
    | add => simp only [add_mul, map_add, add_smul, smul_add, add_add_add_comm, *]
    | monomial n a =>
      induction q using Polynomial.induction_on' with
      | add => simp only [mul_add, map_add, add_smul, smul_add, add_add_add_comm, *]
      | monomial m b =>
        refine Finsupp.ext fun i ↦ ?_
        dsimp [PolynomialModule.equivPolynomial, PolynomialModule.map]
        simp only [toFinsupp_mul, toFinsupp_monomial, AddMonoidAlgebra.single_mul_single]
        change d _ = _ + _
        -- TODO: copy more `Finsupp` API to `PolynomialModule`.
        -- We have to do a bit of work to go through the identification
        -- `PolynomialModule A M = ℕ →₀ M`...
        dsimp only [PolynomialModule, Finsupp.mapRange.linearMap_apply, coeFn_coe]
        rw [Finsupp.mapRange_single, Finsupp.mapRange_single]
        -- ... and here we go back through the identification.
        change _ = (_ • PolynomialModule.single A _ _) _ + (_ • PolynomialModule.single A _ _) i
        simp only [PolynomialModule.monomial_smul_single, AddMonoidAlgebra.single_apply,
          apply_ite d, leibniz, map_zero, PolynomialModule.single_apply, ite_add_zero,
          add_comm m n]
```

-- snippet 40
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.implicitDeriv (L155-L158)
def implicitDeriv (v : A[X]) :
    Derivation ℤ A[X] A[X] :=
mapCoeffs + v • derivative'.restrictScalars ℤ
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.RingTheory.Derivation.Basic).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem leibniz_inv (a : K) : D a⁻¹ = -a⁻¹ ^ 2 • D a
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.RingTheory.Derivation.Basic.toFun_eq_coe (L75-L78)
theorem toFun_eq_coe : D.toFun = ⇑D :=
rfl

/-- See Note [custom simps projection] -/
```

-- snippet 2
```lean
-- Mathlib.RingTheory.Derivation.Basic.Simps (L79-L82)
def Simps.apply (D : Derivation R A M) : A → M := D
initialize_simps_projections Derivation (toFun → apply)
```

-- snippet 3
```lean
-- Mathlib.RingTheory.Derivation.Basic.hasCoeToLinearMap (L85-L87)
instance hasCoeToLinearMap : Coe (Derivation R A M) (A →ₗ[R] M) :=
⟨fun D => D.toLinearMap⟩
```

-- snippet 4
```lean
-- Mathlib.RingTheory.Derivation.Basic.mk_coe (L89-L91)
theorem mk_coe (f : A →ₗ[R] M) (h₁ h₂) : ((⟨f, h₁, h₂⟩ : Derivation R A M) : A → M) = f :=
rfl
```

-- snippet 5
```lean
-- Mathlib.RingTheory.Derivation.Basic.coeFn_coe (L93-L95)
theorem coeFn_coe (f : Derivation R A M) : ⇑(f : A →ₗ[R] M) = f :=
rfl
```

-- snippet 6
```lean
-- Mathlib.RingTheory.Derivation.Basic.coe_injective (L96-L98)
theorem coe_injective : @Function.Injective (Derivation R A M) (A → M) DFunLike.coe :=
DFunLike.coe_injective
```

-- snippet 7
```lean
-- Mathlib.RingTheory.Derivation.Basic.ext (L100-L102)
theorem ext (H : ∀ a, D1 a = D2 a) : D1 = D2 :=
DFunLike.ext _ _ H
```

-- snippet 8
```lean
-- Mathlib.RingTheory.Derivation.Basic.congr_fun (L103-L111)
theorem congr_fun (h : D1 = D2) (a : A) : D1 a = D2 a :=
DFunLike.congr_fun h a

protected theorem map_add : D (a + b) = D a + D b :=
  map_add D a b

protected theorem map_zero : D 0 = 0 :=
  map_zero D
```

-- snippet 9
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_smul (L113-L115)
theorem map_smul : D (r • a) = r • D a :=
D.toLinearMap.map_smul r a
```

-- snippet 10
```lean
-- Mathlib.RingTheory.Derivation.Basic.leibniz (L117-L119)
theorem leibniz : D (a * b) = a • D b + b • D a :=
D.leibniz' _ _
```

-- snippet 11
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_smul_of_tower (L121-L124)
theorem map_smul_of_tower {S : Type*} [SMul S A] [SMul S M] [LinearMap.CompatibleSMul A M S R]
    (D : Derivation R A M) (r : S) (a : A) : D (r • a) = r • D a :=
D.toLinearMap.map_smul_of_tower r a
```

-- snippet 12
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_one_eq_zero (L126-L128)
theorem map_one_eq_zero : D 1 = 0 :=
D.map_one_eq_zero'
```

-- snippet 13
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_algebraMap (L130-L132)
theorem map_algebraMap : D (algebraMap R A r) = 0 := by
rw [← mul_one r, map_mul, map_one, ← smul_def, map_smul, map_one_eq_zero, smul_zero]
```

-- snippet 14
```lean
-- Mathlib.RingTheory.Derivation.Basic.map_natCast (L134-L136)
theorem map_natCast (n : ℕ) : D (n : A) = 0 := by
rw [← nsmul_one, D.map_smul_of_tower n, map_one_eq_zero, smul_zero]
```

-- snippet 15
```lean
-- Mathlib.RingTheory.Derivation.Basic.leibniz_pow (L138-L148)
theorem leibniz_pow (n : ℕ) : D (a ^ n) = n • a ^ (n - 1) • D a := by
induction n with
  | zero => rw [pow_zero, map_one_eq_zero, zero_smul]
  | succ n ihn =>
    rcases (zero_le n).eq_or_lt with (rfl | hpos)
    · simp
    · have : a * a ^ (n - 1) = a ^ n := by rw [← pow_succ', Nat.sub_add_cancel hpos]
      simp only [pow_succ', leibniz, ihn, smul_comm a n (_ : M), smul_smul a, add_smul, this,
        Nat.add_succ_sub_one, add_zero, one_nsmul]

open Polynomial in
```

-- snippet 16
```lean
-- Mathlib.RingTheory.Derivation.Lie.mk (L102-L105)
def mk (x : Derivation R A' A') (y : Derivation R A A)
  (h : x ∘ (Algebra.ofId A A') = (Algebra.ofId A A') ∘ y) : couple R A A' :=
⟨(x, y), (Compatible.mem _).mpr h⟩
```

-- snippet 17
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_monomial (L70-L73)
lemma mapCoeffs_monomial (n : ℕ) (x : A) :
    d.mapCoeffs (monomial n x) = .single A n (d x) := Finsupp.ext fun _ ↦ by
simp [coeff_monomial, apply_ite d, PolynomialModule.single_apply]
```

-- snippet 18
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.Differential (L80-L87)
def Differential.equiv {R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂]
    (h : R ≃+* R₂) : Differential R :=
⟨Derivation.mk' (h.symm.toAddMonoidHom.toIntLinearMap ∘ₗ
    Differential.deriv.toLinearMap ∘ₗ h.toAddMonoidHom.toIntLinearMap) (by simp)⟩

/--
Transfer a `DifferentialAlgebra` instance across a `AlgEquiv`.
-/
```

-- snippet 19
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.coeff_mapCoeffs (L127-L129)
lemma coeff_mapCoeffs (p : A[X]) (i) :
    coeff (mapCoeffs p) i = (coeff p i)′ := rfl
```

-- snippet 20
```lean
-- Mathlib.RingTheory.Derivation.Lie.mk_right (L109-L111)
lemma mk_right (x : Derivation R A' A') (y : Derivation R A A)
    (h : x ∘ (Algebra.ofId A A') = (Algebra.ofId A A') ∘ y) : (mk x y h).1.2 = y := rfl
```

-- snippet 21
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_C (L79-L84)
lemma mapCoeffs_C (x : A) :
    d.mapCoeffs (C x) = .single A 0 (d x) := by simp [← monomial_zero_left]
variable {B M' : Type*} [CommRing B] [Algebra R B] [Algebra A B]
    [AddCommGroup M'] [Module B M'] [Module R M'] [Module A M']
```

-- snippet 22
```lean
-- Mathlib.RingTheory.Derivation.Lie.bracket_eq_fun (L73-L81)
lemma bracket_eq_fun (X : Derivation R A A) (a : A) : ⁅X, a⁆ = X a := rfl
section CompatibleDerivations
variable {A' : Type*} [CommRing A'] [Algebra R A'] [Algebra A A'] [IsScalarTower R A A']

variable (R A A') in
/-- Let `σ : A → A'` be a an homomorphism. A derivation `d : A → A` and a derivation
`d' : A' → A'` are called compatible if `d' ∘ σ = σ ∘ d`. Couples of derivations
with this property form a Lie subalgebra of all couples of derivations. -/
```

-- snippet 23
```lean
-- Mathlib.RingTheory.Derivation.Lie.mem (L95-L101)
lemma mem (x : (Derivation R A' A') × (Derivation R A A)) :
    x ∈ couple R A A' ↔ x.1 ∘ Algebra.ofId A A' = Algebra.ofId A A' ∘ x.2 := by
constructor
  · intro hx; ext a; exact congrArg (· a) hx
  · intro hx; ext a; exact congrArg (· a) hx

/-- Generate an element of `couple` from `x y` satisfying the compatibility equation. -/
```

-- snippet 24
```lean
-- Mathlib.RingTheory.Derivation.Lie.commutator_apply (L48-L50)
theorem commutator_apply : ⁅D1, D2⁆ a = D1 (D2 a) - D2 (D1 a) :=
rfl
```

-- snippet 25
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_X (L75-L77)
lemma mapCoeffs_X :
    d.mapCoeffs (X : A[X]) = 0 := by simp [← monomial_one_one_eq_X]
```

-- snippet 26
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs_apply (L66-L68)
lemma mapCoeffs_apply (p : A[X]) (i) :
    d.mapCoeffs p i = d (coeff p i) := rfl
```

-- snippet 27
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.mem_range_of_deriv_eq_zero (L67-L71)
lemma mem_range_of_deriv_eq_zero (A : Type*) {B : Type*} [CommRing A] [CommRing B] [Algebra A B]
    [Differential B] [Differential.ContainConstants A B] {x : B} (h : x′ = 0) :
    x ∈ (algebraMap A B).range :=
Differential.ContainConstants.mem_range_of_deriv_eq_zero h
```

-- snippet 28
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.algebraMap (L53-L66)
lemma algebraMap.coe_deriv {A : Type*} {B : Type*} [CommRing A] [CommRing B] [Algebra A B]
    [Differential A] [Differential B] [DifferentialAlgebra A B] (a : A) :
    (a′ : A) = (a : B)′ :=
(DifferentialAlgebra.deriv_algebraMap _).symm

/--
A differential ring `A` and an algebra over it `B` share constants if all
constants in B are in the range of `algebraMap A B`.
-/
class Differential.ContainConstants (A B : Type*) [CommRing A] [CommRing B]
    [Algebra A B] [Differential B] : Prop where
  /-- If the derivative of x is 0, then it's in the range of `algebraMap A B`. -/
  protected mem_range_of_deriv_eq_zero {x : B} (h : x′ = 0) : x ∈ (algebraMap A B).range
```

-- snippet 29
```lean
-- Mathlib.RingTheory.Derivation.DifferentialRing.DifferentialAlgebra (L88-L100)
lemma DifferentialAlgebra.equiv {A : Type*} [CommRing A] [Differential A]
    {R R₂ : Type*} [CommRing R] [CommRing R₂] [Differential R₂] [Algebra A R]
    [Algebra A R₂] [DifferentialAlgebra A R₂] (h : R ≃ₐ[A] R₂) :
    letI := Differential.equiv h.toRingEquiv
DifferentialAlgebra A R :=
  letI := Differential.equiv h.toRingEquiv
  ⟨fun a ↦ by
    change (LinearMap.comp ..) _ = _
    simp only [AlgEquiv.toRingEquiv_eq_coe, RingHom.toAddMonoidHom_eq_coe,
      RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_toRingHom, LinearMap.coe_comp,
      AddMonoidHom.coe_toIntLinearMap, AddMonoidHom.coe_coe, RingHom.coe_coe, Derivation.coeFn_coe,
      Function.comp_apply, AlgEquiv.commutes, deriv_algebraMap]
    apply h.symm.commutes⟩
```

-- snippet 30
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.deriv_aeval_eq (L145-L154)
theorem deriv_aeval_eq (x : R) (p : A[X]) :
    (aeval x p)′ = aeval x (mapCoeffs p) + aeval x (derivative p) * x′ := by
convert Derivation.apply_aeval_eq' Differential.deriv _ (Algebra.linearMap A R) ..
  · simp [mapCoeffs]
  · simp [deriv_algebraMap]

/--
The unique derivation which can be made to a `DifferentialAlgebra` on `A[X]` with
`X′ = v`.
-/
```

-- snippet 31
```lean
-- Mathlib.RingTheory.Derivation.Lie.mk_left (L106-L108)
lemma mk_left (x : Derivation R A' A') (y : Derivation R A A)
    (h : x ∘ (Algebra.ofId A A') = (Algebra.ofId A A') ∘ y) : (mk x y h).1.1 = x := rfl
```

-- snippet 32
```lean
-- Mathlib.RingTheory.Derivation.Lie.apply (L112-L122)
lemma apply (x : couple R A A') (a : A) :
    x.1.1 (Algebra.ofId A A' a) = (Algebra.ofId A A')  (x.1.2 a) := by
exact congrArg (· a) x.2

end Compatible

end CompatibleDerivations

end LieStructures

end Derivation
```

-- snippet 33
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.apply_eval_eq (L109-L122)
theorem apply_eval_eq (x : A) (p : A[X]) :
    d (eval x p) = PolynomialModule.eval x (d.mapCoeffs p) + eval x (derivative p) • d x :=
apply_aeval_eq d x p

end Derivation

namespace Differential

variable {A : Type*} [CommRing A] [Differential A]

set_option backward.isDefEq.respectTransparency false in
/--
A specialization of `Derivation.mapCoeffs` for the case of a differential ring.
-/
```

-- snippet 34
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.apply_aeval_eq' (L85-L97)
theorem apply_aeval_eq' (d' : Derivation R B M') (f : M →ₗ[A] M')
    (h : ∀ a, f (d a) = d' (algebraMap A B a)) (x : B) (p : A[X]) :
    d' (aeval x p) = PolynomialModule.eval x (PolynomialModule.map B f (d.mapCoeffs p)) +
      aeval x (derivative p) • d' x := by
induction p using Polynomial.induction_on' with
  | add => simp_all only [map_add, add_smul]; abel
  | monomial =>
    simp only [aeval_monomial, leibniz, leibniz_pow, mapCoeffs_monomial,
      PolynomialModule.map_single, PolynomialModule.eval_single, derivative_monomial, map_mul,
      _root_.map_natCast, h]
    rw [add_comm, ← smul_smul, ← smul_smul, Nat.cast_smul_eq_nsmul]
```

-- snippet 35
```lean
-- Mathlib.RingTheory.Derivation.Lie.commutator_coe_linear_map (L45-L47)
theorem commutator_coe_linear_map : ↑⁅D1, D2⁆ = ⁅(D1 : Module.End R A), (D2 : Module.End R A)⁆ :=
rfl
```

-- snippet 36
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.apply_aeval_eq (L98-L108)
theorem apply_aeval_eq [IsScalarTower R A B] [IsScalarTower A B M'] (d : Derivation R B M')
    (x : B) (p : A[X]) :
    d (aeval x p) = PolynomialModule.eval x ((d.compAlgebraMap A).mapCoeffs p) +
      aeval x (derivative p) • d x := by
convert apply_aeval_eq' (d.compAlgebraMap A) d LinearMap.id _ x p
  · apply Finsupp.ext
    intro x
    rfl
  · intro a
    rfl
```

-- snippet 37
```lean
-- Mathlib.RingTheory.Derivation.Lie.instLieAlgebra (L57-L61)
instance instLieAlgebra : LieAlgebra R (Derivation R A A) :=
{ Derivation.instModule with
    lie_smul := fun r d e => by
      ext a; simp only [commutator_apply, map_smul, smul_sub, smul_apply] }
```

-- snippet 38
```lean
-- Mathlib.RingTheory.Derivation.Lie.couple (L82-L94)
def couple : LieSubalgebra R  (Derivation R A' A' × Derivation R A A) where
  carrier := { x | x.fst.compAlgebraMapL R A A' A' = (Algebra.ofId A A').toLinearMap.compDer x.snd }
add_mem' := by simp_all
  zero_mem' := by simp
  smul_mem' := by simp_all
  lie_mem' {x y} hx hy := by
    have hxx (a : A) := congrArg (fun f => f a) hx
    have hyy (a : A) := congrArg (fun f => f a) hy
    ext z
    simp at hxx hyy
    simp [Derivation.commutator_apply, hxx, hyy]

namespace Compatible
```

-- snippet 39
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.mapCoeffs (L38-L64)
def mapCoeffs : Derivation R A[X] (PolynomialModule A M) where
  __ := (PolynomialModule.map A d.toLinearMap).comp
PolynomialModule.equivPolynomial.symm.toLinearMap
  map_one_eq_zero' := show (Finsupp.single 0 1).mapRange (d : A → M) d.map_zero = 0 by simp
  leibniz' p q := by
    dsimp
    induction p using Polynomial.induction_on' with
    | add => simp only [add_mul, map_add, add_smul, smul_add, add_add_add_comm, *]
    | monomial n a =>
      induction q using Polynomial.induction_on' with
      | add => simp only [mul_add, map_add, add_smul, smul_add, add_add_add_comm, *]
      | monomial m b =>
        refine Finsupp.ext fun i ↦ ?_
        dsimp [PolynomialModule.equivPolynomial, PolynomialModule.map]
        simp only [toFinsupp_mul, toFinsupp_monomial, AddMonoidAlgebra.single_mul_single]
        change d _ = _ + _
        -- TODO: copy more `Finsupp` API to `PolynomialModule`.
        -- We have to do a bit of work to go through the identification
        -- `PolynomialModule A M = ℕ →₀ M`...
        dsimp only [PolynomialModule, Finsupp.mapRange.linearMap_apply, coeFn_coe]
        rw [Finsupp.mapRange_single, Finsupp.mapRange_single]
        -- ... and here we go back through the identification.
        change _ = (_ • PolynomialModule.single A _ _) _ + (_ • PolynomialModule.single A _ _) i
        simp only [PolynomialModule.monomial_smul_single, AddMonoidAlgebra.single_apply,
          apply_ite d, leibniz, map_zero, PolynomialModule.single_apply, ite_add_zero,
          add_comm m n]
```

-- snippet 40
```lean
-- Mathlib.RingTheory.Derivation.MapCoeffs.implicitDeriv (L155-L158)
def implicitDeriv (v : A[X]) :
    Derivation ℤ A[X] A[X] :=
mapCoeffs + v • derivative'.restrictScalars ℤ
```
[/INST]

mistral-common:Tekken v15 (Mistral chat template, [INST]/[SYSTEM_PROMPT])


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.MvPolynomial.CommRing).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
theorem totalDegree_neg (a : MvPolynomial σ R) : (-a).totalDegree = a.totalDegree
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.C_sub (L60-L62)
theorem C_sub : (C (a - a') : MvPolynomial σ R) = C a - C a' :=
map_sub _ _ _
```

-- snippet 2
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.C_neg (L64-L66)
theorem C_neg : (C (-a) : MvPolynomial σ R) = -C a :=
map_neg _ _
```

-- snippet 3
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.coeff_neg (L68-L70)
theorem coeff_neg (m : σ →₀ ℕ) (p : MvPolynomial σ R) : coeff m (-p) = -coeff m p :=
Finsupp.neg_apply _ _
```

-- snippet 4
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.coeff_sub (L72-L74)
theorem coeff_sub (m : σ →₀ ℕ) (p q : MvPolynomial σ R) : coeff m (p - q) = coeff m p - coeff m q :=
Finsupp.sub_apply _ _ _
```

-- snippet 5
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.support_neg (L76-L78)
theorem support_neg : (-p).support = p.support :=
Finsupp.support_neg p
```

-- snippet 6
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.support_sub (L79-L86)
theorem support_sub [DecidableEq σ] (p q : MvPolynomial σ R) :
    (p - q).support ⊆ p.support ∪ q.support :=
Finsupp.support_sub

variable {σ} (p)

section Degrees
```

-- snippet 7
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degrees_neg (L88-L90)
theorem degrees_neg (p : MvPolynomial σ R) : (-p).degrees = p.degrees := by
rw [degrees, support_neg]; rfl
```

-- snippet 8
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degrees_sub_le (L91-L98)
theorem degrees_sub_le [DecidableEq σ] {p q : MvPolynomial σ R} :
    (p - q).degrees ≤ p.degrees ∪ q.degrees := by
simpa [degrees_def] using AddMonoidAlgebra.supDegree_sub_le

end Degrees

section Degrees
```

-- snippet 9
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degreeOf_neg (L100-L102)
theorem degreeOf_neg (i : σ) (p : MvPolynomial σ R) : degreeOf i (-p) = degreeOf i p := by
rw [degreeOf, degreeOf, degrees_neg]
```

-- snippet 10
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degreeOf_sub_le (L103-L110)
theorem degreeOf_sub_le (i : σ) (p q : MvPolynomial σ R) :
    degreeOf i (p - q) ≤ max (degreeOf i p) (degreeOf i q) := by
simpa only [sub_eq_add_neg, degreeOf_neg] using degreeOf_add_le i p (-q)

end Degrees

section Vars
```

-- snippet 11
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.vars_neg (L112-L113)
theorem vars_neg : (-p).vars = p.vars := by simp [vars, degrees_neg]
```

-- snippet 12
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.vars_sub_subset (L114-L116)
theorem vars_sub_subset [DecidableEq σ] : (p - q).vars ⊆ p.vars ∪ q.vars := by
convert vars_add_subset p (-q) using 2 <;> simp [sub_eq_add_neg]
```

-- snippet 13
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.vars_sub_of_disjoint (L118-L129)
theorem vars_sub_of_disjoint [DecidableEq σ] (hpq : Disjoint p.vars q.vars) :
    (p - q).vars = p.vars ∪ q.vars := by
rw [← vars_neg q] at hpq
  convert vars_add_of_disjoint hpq using 2 <;> simp [sub_eq_add_neg]

end Vars

section Eval

variable [CommRing S]
variable (f : R →+* S) (g : σ → S)
```

-- snippet 14
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.eval₂_sub (L131-L133)
theorem eval₂_sub : (p - q).eval₂ f g = p.eval₂ f g - q.eval₂ f g :=
(eval₂Hom f g).map_sub _ _
```

-- snippet 15
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.eval_sub (L134-L136)
theorem eval_sub (f : σ → R) : eval f (p - q) = eval f p - eval f q :=
eval₂_sub _ _ _
```

-- snippet 16
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_inj (L172-L175)
theorem C_inj {σ : Type*} (R : Type*) [CommSemiring R] (r s : R) :
    (C r : MvPolynomial σ R) = C s ↔ r = s :=
(C_injective σ R).eq_iff
```

-- snippet 17
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_add (L149-L151)
theorem C_add : (C (a + a') : MvPolynomial σ R) = C a + C a' :=
Finsupp.single_add _ _ _
```

-- snippet 18
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.monomial_left_injective (L124-L127)
theorem monomial_left_injective {r : R} (hr : r ≠ 0) :
    Function.Injective fun s : σ →₀ ℕ => monomial s r :=
Finsupp.single_left_injective hr
```

-- snippet 19
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.one_def (L95-L96)
theorem one_def : (1 : MvPolynomial σ R) = monomial 0 1 := rfl
```

-- snippet 20
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.single_eq_monomial (L97-L99)
theorem single_eq_monomial (s : σ →₀ ℕ) (a : R) : Finsupp.single s a = monomial s a :=
rfl
```

-- snippet 21
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.X (L121-L123)
def X (n : σ) : MvPolynomial σ R :=
monomial (Finsupp.single n 1) 1
```

-- snippet 22
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.infinite_of_infinite (L185-L188)
instance infinite_of_infinite (σ : Type*) (R : Type*) [CommSemiring R] [Infinite R] :
    Infinite (MvPolynomial σ R) :=
Infinite.of_injective C (C_injective _ _)
```

-- snippet 23
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.monomial_left_inj (L129-L132)
theorem monomial_left_inj {s t : σ →₀ ℕ} {r : R} (hr : r ≠ 0) :
    monomial s r = monomial t r ↔ s = t :=
Finsupp.single_left_inj hr
```

-- snippet 24
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.MvPolynomial (L81-L91)
abbrev MvPolynomial (σ : Type*) (R : Type*) [CommSemiring R] :=
AddMonoidAlgebra R (σ →₀ ℕ)

namespace MvPolynomial

variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}

section CommSemiring
variable [CommSemiring R] [CommSemiring S₁] {p q : MvPolynomial σ R}

/-- `monomial s a` is the monomial with coefficient `a` and exponents given by `s` -/
```

-- snippet 25
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_apply (L133-L135)
theorem C_apply : (C a : MvPolynomial σ R) = monomial 0 a :=
rfl
```

-- snippet 26
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.algebraMap_apply (L116-L120)
theorem algebraMap_apply [Algebra R S₁] (r : R) :
    algebraMap R (MvPolynomial σ S₁) r = C (algebraMap R S₁ r) :=
rfl

/-- `X n` is the degree `1` monomial $X_n$. -/
```

-- snippet 27
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_1 (L140-L142)
theorem C_1 : C 1 = (1 : MvPolynomial σ R) :=
rfl
```

-- snippet 28
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_surjective (L164-L170)
theorem C_surjective {R : Type*} [CommSemiring R] (σ : Type*) [IsEmpty σ] :
    Function.Surjective (C : R → MvPolynomial σ R) := by
refine fun p => ⟨p.toFun 0, Finsupp.ext fun a => ?_⟩
  simp only [C_apply, ← single_eq_monomial, (Finsupp.ext isEmptyElim (α := σ) : a = 0),
    single_eq_same]
  rfl
```

-- snippet 29
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_pow (L157-L159)
theorem C_pow (a : R) (n : ℕ) : (C (a ^ n) : MvPolynomial σ R) = C a ^ n :=
map_pow _ _ _
```

-- snippet 30
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.mul_def (L100-L103)
theorem mul_def : p * q = p.sum fun m a => q.sum fun n b => monomial (m + n) (a * b) :=
AddMonoidAlgebra.mul_def ..

/-- `C a` is the constant polynomial with value `a` -/
```

-- snippet 31
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_ne_zero (L178-L180)
lemma C_ne_zero : (C a : MvPolynomial σ R) ≠ 0 ↔ a ≠ 0 :=
C_eq_zero.ne
```

-- snippet 32
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.nontrivial_of_nontrivial (L181-L184)
instance nontrivial_of_nontrivial (σ : Type*) (R : Type*) [CommSemiring R] [Nontrivial R] :
    Nontrivial (MvPolynomial σ R) :=
inferInstanceAs (Nontrivial <| AddMonoidAlgebra R (σ →₀ ℕ))
```

-- snippet 33
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C (L104-L108)
def C : R →+* MvPolynomial σ R :=
{ singleZeroRingHom with toFun := monomial 0 }

variable (R σ)
```

-- snippet 34
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_mul (L153-L155)
theorem C_mul : (C (a * a') : MvPolynomial σ R) = C a * C a' :=
C_mul_monomial.symm
```

-- snippet 35
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.algebraMap_eq (L110-L114)
theorem algebraMap_eq : algebraMap R (MvPolynomial σ R) = C :=
rfl

variable {R σ}
```

-- snippet 36
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_injective (L160-L163)
theorem C_injective (σ : Type*) (R : Type*) [CommSemiring R] :
    Function.Injective (C : R → MvPolynomial σ R) :=
Finsupp.single_injective _
```

-- snippet 37
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.monomial (L92-L94)
def monomial (s : σ →₀ ℕ) : R →ₗ[R] MvPolynomial σ R :=
AddMonoidAlgebra.lsingle s
```

-- snippet 38
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_mul_monomial (L143-L147)
theorem C_mul_monomial : C a * monomial s a' = monomial s (a * a') := by
have := single_mul_single 0 s a a'
  rw [zero_add] at this
  exact this
```

-- snippet 39
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_0 (L137-L138)
theorem C_0 : C 0 = (0 : MvPolynomial σ R) := map_zero _
```

-- snippet 40
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.infinite_of_nonempty (L189-L193)
instance infinite_of_nonempty (σ : Type*) (R : Type*) [Nonempty σ] [CommSemiring R]
    [Nontrivial R] : Infinite (MvPolynomial σ R) :=
Infinite.of_injective ((fun s : σ →₀ ℕ => monomial s 1) ∘ Finsupp.single (Classical.arbitrary σ))
    <| (monomial_left_injective one_ne_zero).comp (Finsupp.single_injective _)
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.MvPolynomial.CommRing).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem totalDegree_neg (a : MvPolynomial σ R) : (-a).totalDegree = a.totalDegree
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.C_sub (L60-L62)
theorem C_sub : (C (a - a') : MvPolynomial σ R) = C a - C a' :=
map_sub _ _ _
```

-- snippet 2
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.C_neg (L64-L66)
theorem C_neg : (C (-a) : MvPolynomial σ R) = -C a :=
map_neg _ _
```

-- snippet 3
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.coeff_neg (L68-L70)
theorem coeff_neg (m : σ →₀ ℕ) (p : MvPolynomial σ R) : coeff m (-p) = -coeff m p :=
Finsupp.neg_apply _ _
```

-- snippet 4
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.coeff_sub (L72-L74)
theorem coeff_sub (m : σ →₀ ℕ) (p q : MvPolynomial σ R) : coeff m (p - q) = coeff m p - coeff m q :=
Finsupp.sub_apply _ _ _
```

-- snippet 5
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.support_neg (L76-L78)
theorem support_neg : (-p).support = p.support :=
Finsupp.support_neg p
```

-- snippet 6
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.support_sub (L79-L86)
theorem support_sub [DecidableEq σ] (p q : MvPolynomial σ R) :
    (p - q).support ⊆ p.support ∪ q.support :=
Finsupp.support_sub

variable {σ} (p)

section Degrees
```

-- snippet 7
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degrees_neg (L88-L90)
theorem degrees_neg (p : MvPolynomial σ R) : (-p).degrees = p.degrees := by
rw [degrees, support_neg]; rfl
```

-- snippet 8
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degrees_sub_le (L91-L98)
theorem degrees_sub_le [DecidableEq σ] {p q : MvPolynomial σ R} :
    (p - q).degrees ≤ p.degrees ∪ q.degrees := by
simpa [degrees_def] using AddMonoidAlgebra.supDegree_sub_le

end Degrees

section Degrees
```

-- snippet 9
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degreeOf_neg (L100-L102)
theorem degreeOf_neg (i : σ) (p : MvPolynomial σ R) : degreeOf i (-p) = degreeOf i p := by
rw [degreeOf, degreeOf, degrees_neg]
```

-- snippet 10
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.degreeOf_sub_le (L103-L110)
theorem degreeOf_sub_le (i : σ) (p q : MvPolynomial σ R) :
    degreeOf i (p - q) ≤ max (degreeOf i p) (degreeOf i q) := by
simpa only [sub_eq_add_neg, degreeOf_neg] using degreeOf_add_le i p (-q)

end Degrees

section Vars
```

-- snippet 11
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.vars_neg (L112-L113)
theorem vars_neg : (-p).vars = p.vars := by simp [vars, degrees_neg]
```

-- snippet 12
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.vars_sub_subset (L114-L116)
theorem vars_sub_subset [DecidableEq σ] : (p - q).vars ⊆ p.vars ∪ q.vars := by
convert vars_add_subset p (-q) using 2 <;> simp [sub_eq_add_neg]
```

-- snippet 13
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.vars_sub_of_disjoint (L118-L129)
theorem vars_sub_of_disjoint [DecidableEq σ] (hpq : Disjoint p.vars q.vars) :
    (p - q).vars = p.vars ∪ q.vars := by
rw [← vars_neg q] at hpq
  convert vars_add_of_disjoint hpq using 2 <;> simp [sub_eq_add_neg]

end Vars

section Eval

variable [CommRing S]
variable (f : R →+* S) (g : σ → S)
```

-- snippet 14
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.eval₂_sub (L131-L133)
theorem eval₂_sub : (p - q).eval₂ f g = p.eval₂ f g - q.eval₂ f g :=
(eval₂Hom f g).map_sub _ _
```

-- snippet 15
```lean
-- Mathlib.Algebra.MvPolynomial.CommRing.eval_sub (L134-L136)
theorem eval_sub (f : σ → R) : eval f (p - q) = eval f p - eval f q :=
eval₂_sub _ _ _
```

-- snippet 16
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_inj (L172-L175)
theorem C_inj {σ : Type*} (R : Type*) [CommSemiring R] (r s : R) :
    (C r : MvPolynomial σ R) = C s ↔ r = s :=
(C_injective σ R).eq_iff
```

-- snippet 17
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_add (L149-L151)
theorem C_add : (C (a + a') : MvPolynomial σ R) = C a + C a' :=
Finsupp.single_add _ _ _
```

-- snippet 18
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.monomial_left_injective (L124-L127)
theorem monomial_left_injective {r : R} (hr : r ≠ 0) :
    Function.Injective fun s : σ →₀ ℕ => monomial s r :=
Finsupp.single_left_injective hr
```

-- snippet 19
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.one_def (L95-L96)
theorem one_def : (1 : MvPolynomial σ R) = monomial 0 1 := rfl
```

-- snippet 20
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.single_eq_monomial (L97-L99)
theorem single_eq_monomial (s : σ →₀ ℕ) (a : R) : Finsupp.single s a = monomial s a :=
rfl
```

-- snippet 21
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.X (L121-L123)
def X (n : σ) : MvPolynomial σ R :=
monomial (Finsupp.single n 1) 1
```

-- snippet 22
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.infinite_of_infinite (L185-L188)
instance infinite_of_infinite (σ : Type*) (R : Type*) [CommSemiring R] [Infinite R] :
    Infinite (MvPolynomial σ R) :=
Infinite.of_injective C (C_injective _ _)
```

-- snippet 23
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.monomial_left_inj (L129-L132)
theorem monomial_left_inj {s t : σ →₀ ℕ} {r : R} (hr : r ≠ 0) :
    monomial s r = monomial t r ↔ s = t :=
Finsupp.single_left_inj hr
```

-- snippet 24
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.MvPolynomial (L81-L91)
abbrev MvPolynomial (σ : Type*) (R : Type*) [CommSemiring R] :=
AddMonoidAlgebra R (σ →₀ ℕ)

namespace MvPolynomial

variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}

section CommSemiring
variable [CommSemiring R] [CommSemiring S₁] {p q : MvPolynomial σ R}

/-- `monomial s a` is the monomial with coefficient `a` and exponents given by `s` -/
```

-- snippet 25
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_apply (L133-L135)
theorem C_apply : (C a : MvPolynomial σ R) = monomial 0 a :=
rfl
```

-- snippet 26
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.algebraMap_apply (L116-L120)
theorem algebraMap_apply [Algebra R S₁] (r : R) :
    algebraMap R (MvPolynomial σ S₁) r = C (algebraMap R S₁ r) :=
rfl

/-- `X n` is the degree `1` monomial $X_n$. -/
```

-- snippet 27
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_1 (L140-L142)
theorem C_1 : C 1 = (1 : MvPolynomial σ R) :=
rfl
```

-- snippet 28
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_surjective (L164-L170)
theorem C_surjective {R : Type*} [CommSemiring R] (σ : Type*) [IsEmpty σ] :
    Function.Surjective (C : R → MvPolynomial σ R) := by
refine fun p => ⟨p.toFun 0, Finsupp.ext fun a => ?_⟩
  simp only [C_apply, ← single_eq_monomial, (Finsupp.ext isEmptyElim (α := σ) : a = 0),
    single_eq_same]
  rfl
```

-- snippet 29
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_pow (L157-L159)
theorem C_pow (a : R) (n : ℕ) : (C (a ^ n) : MvPolynomial σ R) = C a ^ n :=
map_pow _ _ _
```

-- snippet 30
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.mul_def (L100-L103)
theorem mul_def : p * q = p.sum fun m a => q.sum fun n b => monomial (m + n) (a * b) :=
AddMonoidAlgebra.mul_def ..

/-- `C a` is the constant polynomial with value `a` -/
```

-- snippet 31
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_ne_zero (L178-L180)
lemma C_ne_zero : (C a : MvPolynomial σ R) ≠ 0 ↔ a ≠ 0 :=
C_eq_zero.ne
```

-- snippet 32
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.nontrivial_of_nontrivial (L181-L184)
instance nontrivial_of_nontrivial (σ : Type*) (R : Type*) [CommSemiring R] [Nontrivial R] :
    Nontrivial (MvPolynomial σ R) :=
inferInstanceAs (Nontrivial <| AddMonoidAlgebra R (σ →₀ ℕ))
```

-- snippet 33
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C (L104-L108)
def C : R →+* MvPolynomial σ R :=
{ singleZeroRingHom with toFun := monomial 0 }

variable (R σ)
```

-- snippet 34
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_mul (L153-L155)
theorem C_mul : (C (a * a') : MvPolynomial σ R) = C a * C a' :=
C_mul_monomial.symm
```

-- snippet 35
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.algebraMap_eq (L110-L114)
theorem algebraMap_eq : algebraMap R (MvPolynomial σ R) = C :=
rfl

variable {R σ}
```

-- snippet 36
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_injective (L160-L163)
theorem C_injective (σ : Type*) (R : Type*) [CommSemiring R] :
    Function.Injective (C : R → MvPolynomial σ R) :=
Finsupp.single_injective _
```

-- snippet 37
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.monomial (L92-L94)
def monomial (s : σ →₀ ℕ) : R →ₗ[R] MvPolynomial σ R :=
AddMonoidAlgebra.lsingle s
```

-- snippet 38
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_mul_monomial (L143-L147)
theorem C_mul_monomial : C a * monomial s a' = monomial s (a * a') := by
have := single_mul_single 0 s a a'
  rw [zero_add] at this
  exact this
```

-- snippet 39
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.C_0 (L137-L138)
theorem C_0 : C 0 = (0 : MvPolynomial σ R) := map_zero _
```

-- snippet 40
```lean
-- Mathlib.Algebra.MvPolynomial.Basic.infinite_of_nonempty (L189-L193)
instance infinite_of_nonempty (σ : Type*) (R : Type*) [Nonempty σ] [CommSemiring R]
    [Nontrivial R] : Infinite (MvPolynomial σ R) :=
Infinite.of_injective ((fun s : σ →₀ ℕ => monomial s 1) ∘ Finsupp.single (Classical.arbitrary σ))
    <| (monomial_left_injective one_ne_zero).comp (Finsupp.single_injective _)
```
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.Normed.Group.Int).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
theorem norm_zpow_le_mul_norm (n : ℤ) (a : α) : ‖a ^ n‖ ≤ ‖n‖ * ‖a‖
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Analysis.Normed.Group.Int.instNormedAddCommGroup (L20-L25)
instance instNormedAddCommGroup : NormedAddCommGroup ℤ where
  norm n := ‖(n : ℝ)‖
dist_eq m n := by
    simp only [dist_eq, norm, cast_add, cast_neg]
    rw [abs_sub_comm, neg_add_eq_sub]
```

-- snippet 2
```lean
-- Mathlib.Analysis.Normed.Group.Int.norm_cast_real (L27-L29)
theorem norm_cast_real (m : ℤ) : ‖(m : ℝ)‖ = ‖m‖ :=
rfl
```

-- snippet 3
```lean
-- Mathlib.Analysis.Normed.Group.Int.norm_eq_abs (L30-L32)
theorem norm_eq_abs (n : ℤ) : ‖n‖ = |(n : ℝ)| :=
rfl
```

-- snippet 4
```lean
-- Mathlib.Analysis.Normed.Group.Int.norm_natCast (L33-L34)
theorem norm_natCast (n : ℕ) : ‖(n : ℤ)‖ = n := by simp [Int.norm_eq_abs]
```

-- snippet 5
```lean
-- Mathlib.Analysis.Normed.Group.Int.abs_le_floor_nnreal_iff (L42-L48)
theorem abs_le_floor_nnreal_iff (z : ℤ) (c : ℝ≥0) : |z| ≤ ⌊c⌋₊ ↔ ‖z‖₊ ≤ c := by
rw [Int.abs_eq_natAbs, Int.ofNat_le, Nat.le_floor_iff (zero_le c), NNReal.natCast_natAbs z]

end Int

-- Now that we've installed the norm on `ℤ`,
-- we can state some lemmas about `zsmul`.
```

-- snippet 6
```lean
-- Mathlib.Analysis.Normed.Group.Int.nnnorm_zpow_le_mul_norm (L58-L60)
theorem nnnorm_zpow_le_mul_norm (n : ℤ) (a : α) : ‖a ^ n‖₊ ≤ ‖n‖₊ * ‖a‖₊ := by
simpa only [← NNReal.coe_le_coe, NNReal.coe_mul] using norm_zpow_le_mul_norm n a
```

-- snippet 7
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_lineMap_lineMap (L67-L70)
theorem nndist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
    nndist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = nndist c₁ c₂ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_lineMap _ _ _ _
```

-- snippet 8
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_midpoint_right (L159-L162)
theorem nndist_midpoint_right (p₁ p₂ : P) :
    nndist (midpoint 𝕜 p₁ p₂) p₂ = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_midpoint_right _ _
```

-- snippet 9
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_right_lineMap (L104-L106)
theorem dist_right_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_right _ _ _)
```

-- snippet 10
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_center_homothety (L41-L44)
theorem dist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
    dist p₁ (homothety p₁ c p₂) = ‖c‖ * dist p₁ p₂ := by
simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm]
```

-- snippet 11
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_lineMap_lineMap (L60-L65)
theorem dist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
    dist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = dist c₁ c₂ * dist p₁ p₂ := by
rw [dist_comm p₁ p₂]
  simp only [lineMap_apply, dist_eq_norm_vsub, vadd_vsub_vadd_cancel_right,
    ← sub_smul, norm_smul, vsub_eq_sub]
```

-- snippet 12
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_lineMap_right (L99-L102)
theorem nndist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
    nndist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_right _ _ _
```

-- snippet 13
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_homothety_center (L55-L58)
theorem nndist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
    nndist (homothety p₁ c p₂) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_center _ _ _
```

-- snippet 14
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_homothety_self (L113-L116)
theorem dist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
    dist (homothety p₁ c p₂) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
rw [homothety_eq_lineMap, dist_lineMap_right]
```

-- snippet 15
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_lineMap_left (L80-L83)
theorem nndist_lineMap_left (p₁ p₂ : P) (c : 𝕜) :
    nndist (lineMap p₁ p₂ c) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_left _ _ _
```

-- snippet 16
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_self_homothety (L123-L125)
theorem dist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
    dist p₂ (homothety p₁ c p₂) = ‖1 - c‖ * dist p₁ p₂ := by rw [dist_comm, dist_homothety_self]
```

-- snippet 17
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_lineMap_left (L76-L78)
theorem dist_lineMap_left (p₁ p₂ : P) (c : 𝕜) : dist (lineMap p₁ p₂ c) p₁ = ‖c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_zero, dist_zero_right] using dist_lineMap_lineMap p₁ p₂ c 0
```

-- snippet 18
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_lineMap_right (L94-L97)
theorem dist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
    dist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_one, dist_eq_norm'] using dist_lineMap_lineMap p₁ p₂ c 1
```

-- snippet 19
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_midpoint_right (L154-L157)
theorem dist_midpoint_right (p₁ p₂ : P) :
    dist (midpoint 𝕜 p₁ p₂) p₂ = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [midpoint_comm, dist_midpoint_left, dist_comm]
```

-- snippet 20
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_left_lineMap (L89-L92)
theorem nndist_left_lineMap (p₁ p₂ : P) (c : 𝕜) :
    nndist p₁ (lineMap p₁ p₂ c) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_left_lineMap _ _ _
```

-- snippet 21
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_left_lineMap (L85-L87)
theorem dist_left_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₁ (lineMap p₁ p₂ c) = ‖c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_left _ _ _)
```

-- snippet 22
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_left_midpoint (L140-L143)
theorem nndist_left_midpoint (p₁ p₂ : P) :
    nndist p₁ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_left_midpoint _ _
```

-- snippet 23
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_center_homothety (L46-L49)
theorem nndist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
    nndist p₁ (homothety p₁ c p₂) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_center_homothety _ _ _
```

-- snippet 24
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_midpoint_left (L149-L152)
theorem nndist_midpoint_left (p₁ p₂ : P) :
    nndist (midpoint 𝕜 p₁ p₂) p₁ = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_midpoint_left _ _
```

-- snippet 25
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_self_homothety (L127-L134)
theorem nndist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
    nndist p₂ (homothety p₁ c p₂) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_self_homothety _ _ _

section invertibleTwo

variable [Invertible (2 : 𝕜)]
```

-- snippet 26
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_right_lineMap (L108-L111)
theorem nndist_right_lineMap (p₁ p₂ : P) (c : 𝕜) :
    nndist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_right_lineMap _ _ _
```

-- snippet 27
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.lipschitzWith_lineMap (L71-L74)
theorem lipschitzWith_lineMap (p₁ p₂ : P) : LipschitzWith (nndist p₁ p₂) (lineMap p₁ p₂ : 𝕜 → P) :=
LipschitzWith.of_dist_le_mul fun c₁ c₂ =>
    ((dist_lineMap_lineMap p₁ p₂ c₁ c₂).trans (mul_comm _ _)).le
```

-- snippet 28
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_homothety_center (L51-L53)
theorem dist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
    dist (homothety p₁ c p₂) p₁ = ‖c‖ * dist p₁ p₂ := by rw [dist_comm, dist_center_homothety]
```

-- snippet 29
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_midpoint_left (L145-L147)
theorem dist_midpoint_left (p₁ p₂ : P) : dist (midpoint 𝕜 p₁ p₂) p₁ = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [dist_comm, dist_left_midpoint]
```

-- snippet 30
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_left_midpoint (L136-L138)
theorem dist_left_midpoint (p₁ p₂ : P) : dist p₁ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [midpoint, dist_comm, dist_lineMap_left, invOf_eq_inv, ← norm_inv]
```

-- snippet 31
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_homothety_self (L118-L121)
theorem nndist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
    nndist (homothety p₁ c p₂) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_self _ _ _
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.Normed.Group.Int).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem norm_zpow_le_mul_norm (n : ℤ) (a : α) : ‖a ^ n‖ ≤ ‖n‖ * ‖a‖
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Analysis.Normed.Group.Int.instNormedAddCommGroup (L20-L25)
instance instNormedAddCommGroup : NormedAddCommGroup ℤ where
  norm n := ‖(n : ℝ)‖
dist_eq m n := by
    simp only [dist_eq, norm, cast_add, cast_neg]
    rw [abs_sub_comm, neg_add_eq_sub]
```

-- snippet 2
```lean
-- Mathlib.Analysis.Normed.Group.Int.norm_cast_real (L27-L29)
theorem norm_cast_real (m : ℤ) : ‖(m : ℝ)‖ = ‖m‖ :=
rfl
```

-- snippet 3
```lean
-- Mathlib.Analysis.Normed.Group.Int.norm_eq_abs (L30-L32)
theorem norm_eq_abs (n : ℤ) : ‖n‖ = |(n : ℝ)| :=
rfl
```

-- snippet 4
```lean
-- Mathlib.Analysis.Normed.Group.Int.norm_natCast (L33-L34)
theorem norm_natCast (n : ℕ) : ‖(n : ℤ)‖ = n := by simp [Int.norm_eq_abs]
```

-- snippet 5
```lean
-- Mathlib.Analysis.Normed.Group.Int.abs_le_floor_nnreal_iff (L42-L48)
theorem abs_le_floor_nnreal_iff (z : ℤ) (c : ℝ≥0) : |z| ≤ ⌊c⌋₊ ↔ ‖z‖₊ ≤ c := by
rw [Int.abs_eq_natAbs, Int.ofNat_le, Nat.le_floor_iff (zero_le c), NNReal.natCast_natAbs z]

end Int

-- Now that we've installed the norm on `ℤ`,
-- we can state some lemmas about `zsmul`.
```

-- snippet 6
```lean
-- Mathlib.Analysis.Normed.Group.Int.nnnorm_zpow_le_mul_norm (L58-L60)
theorem nnnorm_zpow_le_mul_norm (n : ℤ) (a : α) : ‖a ^ n‖₊ ≤ ‖n‖₊ * ‖a‖₊ := by
simpa only [← NNReal.coe_le_coe, NNReal.coe_mul] using norm_zpow_le_mul_norm n a
```

-- snippet 7
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_lineMap_lineMap (L67-L70)
theorem nndist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
    nndist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = nndist c₁ c₂ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_lineMap _ _ _ _
```

-- snippet 8
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_midpoint_right (L159-L162)
theorem nndist_midpoint_right (p₁ p₂ : P) :
    nndist (midpoint 𝕜 p₁ p₂) p₂ = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_midpoint_right _ _
```

-- snippet 9
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_right_lineMap (L104-L106)
theorem dist_right_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_right _ _ _)
```

-- snippet 10
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_center_homothety (L41-L44)
theorem dist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
    dist p₁ (homothety p₁ c p₂) = ‖c‖ * dist p₁ p₂ := by
simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm]
```

-- snippet 11
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_lineMap_lineMap (L60-L65)
theorem dist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
    dist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = dist c₁ c₂ * dist p₁ p₂ := by
rw [dist_comm p₁ p₂]
  simp only [lineMap_apply, dist_eq_norm_vsub, vadd_vsub_vadd_cancel_right,
    ← sub_smul, norm_smul, vsub_eq_sub]
```

-- snippet 12
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_lineMap_right (L99-L102)
theorem nndist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
    nndist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_right _ _ _
```

-- snippet 13
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_homothety_center (L55-L58)
theorem nndist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
    nndist (homothety p₁ c p₂) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_center _ _ _
```

-- snippet 14
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_homothety_self (L113-L116)
theorem dist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
    dist (homothety p₁ c p₂) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
rw [homothety_eq_lineMap, dist_lineMap_right]
```

-- snippet 15
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_lineMap_left (L80-L83)
theorem nndist_lineMap_left (p₁ p₂ : P) (c : 𝕜) :
    nndist (lineMap p₁ p₂ c) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_left _ _ _
```

-- snippet 16
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_self_homothety (L123-L125)
theorem dist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
    dist p₂ (homothety p₁ c p₂) = ‖1 - c‖ * dist p₁ p₂ := by rw [dist_comm, dist_homothety_self]
```

-- snippet 17
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_lineMap_left (L76-L78)
theorem dist_lineMap_left (p₁ p₂ : P) (c : 𝕜) : dist (lineMap p₁ p₂ c) p₁ = ‖c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_zero, dist_zero_right] using dist_lineMap_lineMap p₁ p₂ c 0
```

-- snippet 18
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_lineMap_right (L94-L97)
theorem dist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
    dist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_one, dist_eq_norm'] using dist_lineMap_lineMap p₁ p₂ c 1
```

-- snippet 19
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_midpoint_right (L154-L157)
theorem dist_midpoint_right (p₁ p₂ : P) :
    dist (midpoint 𝕜 p₁ p₂) p₂ = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [midpoint_comm, dist_midpoint_left, dist_comm]
```

-- snippet 20
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_left_lineMap (L89-L92)
theorem nndist_left_lineMap (p₁ p₂ : P) (c : 𝕜) :
    nndist p₁ (lineMap p₁ p₂ c) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_left_lineMap _ _ _
```

-- snippet 21
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_left_lineMap (L85-L87)
theorem dist_left_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₁ (lineMap p₁ p₂ c) = ‖c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_left _ _ _)
```

-- snippet 22
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_left_midpoint (L140-L143)
theorem nndist_left_midpoint (p₁ p₂ : P) :
    nndist p₁ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_left_midpoint _ _
```

-- snippet 23
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_center_homothety (L46-L49)
theorem nndist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
    nndist p₁ (homothety p₁ c p₂) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_center_homothety _ _ _
```

-- snippet 24
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_midpoint_left (L149-L152)
theorem nndist_midpoint_left (p₁ p₂ : P) :
    nndist (midpoint 𝕜 p₁ p₂) p₁ = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_midpoint_left _ _
```

-- snippet 25
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_self_homothety (L127-L134)
theorem nndist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
    nndist p₂ (homothety p₁ c p₂) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_self_homothety _ _ _

section invertibleTwo

variable [Invertible (2 : 𝕜)]
```

-- snippet 26
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_right_lineMap (L108-L111)
theorem nndist_right_lineMap (p₁ p₂ : P) (c : 𝕜) :
    nndist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_right_lineMap _ _ _
```

-- snippet 27
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.lipschitzWith_lineMap (L71-L74)
theorem lipschitzWith_lineMap (p₁ p₂ : P) : LipschitzWith (nndist p₁ p₂) (lineMap p₁ p₂ : 𝕜 → P) :=
LipschitzWith.of_dist_le_mul fun c₁ c₂ =>
    ((dist_lineMap_lineMap p₁ p₂ c₁ c₂).trans (mul_comm _ _)).le
```

-- snippet 28
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_homothety_center (L51-L53)
theorem dist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
    dist (homothety p₁ c p₂) p₁ = ‖c‖ * dist p₁ p₂ := by rw [dist_comm, dist_center_homothety]
```

-- snippet 29
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_midpoint_left (L145-L147)
theorem dist_midpoint_left (p₁ p₂ : P) : dist (midpoint 𝕜 p₁ p₂) p₁ = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [dist_comm, dist_left_midpoint]
```

-- snippet 30
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.dist_left_midpoint (L136-L138)
theorem dist_left_midpoint (p₁ p₂ : P) : dist p₁ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [midpoint, dist_comm, dist_lineMap_left, invOf_eq_inv, ← norm_inv]
```

-- snippet 31
```lean
-- Mathlib.Analysis.Normed.Affine.AddTorsor.nndist_homothety_self (L118-L121)
theorem nndist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
    nndist (homothety p₁ c p₂) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_self _ _ _
```
[/INST]