l3lab/ntp-mathlib huggingface dataset:
instance : Preadditive (PresheafOfModules R) where
  add_comp := by 

Proof state:
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P : PresheafOfModules R
Q : PresheafOfModules R
T : PresheafOfModules R
⊢ ∀ (P Q R_1 : PresheafOfModules R) (f f' : P ⟶ Q) (g : Q ⟶ R_1), (f + f') ≫ g = f ≫ g + f' ≫ g

Next tactic:
intros
instance : Preadditive (PresheafOfModules R) where
  add_comp := by intros; 

Proof state:
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P : PresheafOfModules R
Q : PresheafOfModules R
T : PresheafOfModules R
P✝ Q✝ R✝ : PresheafOfModules R
f✝ f'✝ : P✝ ⟶ Q✝
g✝ : Q✝ ⟶ R✝
⊢ (f✝ + f'✝) ≫ g✝ = f✝ ≫ g✝ + f'✝ ≫ g✝

Next tactic:
ext1
instance : Preadditive (PresheafOfModules R) where
  add_comp := by intros; ext1; 

Proof state:
case w
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P : PresheafOfModules R
Q : PresheafOfModules R
T : PresheafOfModules R
P✝ Q✝ R✝ : PresheafOfModules R
f✝ f'✝ : P✝ ⟶ Q✝
g✝ : Q✝ ⟶ R✝
X✝ : Cᵒᵖ
⊢ app ((f✝ + f'✝) ≫ g✝) X✝ = app (f✝ ≫ g✝ + f'✝ ≫ g✝) X✝

Next tactic:
simp only [comp_app, add_app, comp_add]
instance : Preadditive (PresheafOfModules R) where
  add_comp := by intros; ext1; simp only [comp_app, add_app, comp_add]
  comp_add := by 

Proof state:
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P : PresheafOfModules R
Q : PresheafOfModules R
T : PresheafOfModules R
⊢ ∀ (P Q R_1 : PresheafOfModules R) (f : P ⟶ Q) (g g' : Q ⟶ R_1), f ≫ (g + g') = f ≫ g + f ≫ g'

Next tactic:
intros
instance : Preadditive (PresheafOfModules R) where
  add_comp := by intros; ext1; simp only [comp_app, add_app, comp_add]
  comp_add := by intros; 

Proof state:
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P : PresheafOfModules R
Q : PresheafOfModules R
T : PresheafOfModules R
P✝ Q✝ R✝ : PresheafOfModules R
f✝ : P✝ ⟶ Q✝
g✝ g'✝ : Q✝ ⟶ R✝
⊢ f✝ ≫ (g✝ + g'✝) = f✝ ≫ g✝ + f✝ ≫ g'✝

Next tactic:
ext1
instance : Preadditive (PresheafOfModules R) where
  add_comp := by intros; ext1; simp only [comp_app, add_app, comp_add]
  comp_add := by intros; ext1; 

Proof state:
case w
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P : PresheafOfModules R
Q : PresheafOfModules R
T : PresheafOfModules R
P✝ Q✝ R✝ : PresheafOfModules R
f✝ : P✝ ⟶ Q✝
g✝ g'✝ : Q✝ ⟶ R✝
X✝ : Cᵒᵖ
⊢ app (f✝ ≫ (g✝ + g'✝)) X✝ = app (f✝ ≫ g✝ + f✝ ≫ g'✝) X✝

Next tactic:
simp only [comp_app, add_app, add_comp]
instance : Faithful (toPresheaf R) where
  map_injective {P Q} f g h := by
    

Proof state:
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P Q : PresheafOfModules R
f g : P ⟶ Q
h : (toPresheaf R).map f = (toPresheaf R).map g
⊢ f = g

Next tactic:
ext X x
instance : Faithful (toPresheaf R) where
  map_injective {P Q} f g h := by
    ext X x
    

Proof state:
case w.h
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P Q : PresheafOfModules R
f g : P ⟶ Q
h : (toPresheaf R).map f = (toPresheaf R).map g
X : Cᵒᵖ
x : ↑(obj P X)
⊢ (Hom.app f X) x = (Hom.app g X) x

Next tactic:
have eq := congr_app h X
instance : Faithful (toPresheaf R) where
  map_injective {P Q} f g h := by
    ext X x
    have eq := congr_app h X
    

Proof state:
case w.h
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P Q : PresheafOfModules R
f g : P ⟶ Q
h : (toPresheaf R).map f = (toPresheaf R).map g
X : Cᵒᵖ
x : ↑(obj P X)
eq : ((toPresheaf R).map f).app X = ((toPresheaf R).map g).app X
⊢ (Hom.app f X) x = (Hom.app g X) x

Next tactic:
simp only [toPresheaf_obj, toPresheaf_map_app] at eq
instance : Faithful (toPresheaf R) where
  map_injective {P Q} f g h := by
    ext X x
    have eq := congr_app h X
    simp only [toPresheaf_obj, toPresheaf_map_app] at eq
    

Proof state:
case w.h
C : Type u₁
inst✝ : Category.{v₁, u₁} C
R : Cᵒᵖ ⥤ RingCat
P Q : PresheafOfModules R
f g : P ⟶ Q
h : (toPresheaf R).map f = (toPresheaf R).map g
X : Cᵒᵖ
x : ↑(obj P X)
eq : toAddMonoidHom (Hom.app f X) = toAddMonoidHom (Hom.app g X)
⊢ (Hom.app f X) x = (Hom.app g X) x

Next tactic:
simp only [← toAddMonoidHom_coe, eq]
/-- An affine map is continuous iff its underlying linear map is continuous. See also
`AffineMap.continuous_linear_iff`. -/
theorem continuous_iff {f : E →ᵃ[R] F} : Continuous f ↔ Continuous f.linear := by
  

Proof state:
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Ring R
inst✝¹ : Module R E
inst✝ : Module R F
f : E →ᵃ[R] F
⊢ Continuous ⇑f ↔ Continuous ⇑f.linear

Next tactic:
constructor
/-- An affine map is continuous iff its underlying linear map is continuous. See also
`AffineMap.continuous_linear_iff`. -/
theorem continuous_iff {f : E →ᵃ[R] F} : Continuous f ↔ Continuous f.linear := by
  constructor
  · 

Proof state:
case mp
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Ring R
inst✝¹ : Module R E
inst✝ : Module R F
f : E →ᵃ[R] F
⊢ Continuous ⇑f → Continuous ⇑f.linear

Next tactic:
intro hc
/-- An affine map is continuous iff its underlying linear map is continuous. See also
`AffineMap.continuous_linear_iff`. -/
theorem continuous_iff {f : E →ᵃ[R] F} : Continuous f ↔ Continuous f.linear := by
  constructor
  · intro hc
    

Proof state:
case mp
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Ring R
inst✝¹ : Module R E
inst✝ : Module R F
f : E →ᵃ[R] F
hc : Continuous ⇑f
⊢ Continuous ⇑f.linear

Next tactic:
rw [decomp' f]
/-- An affine map is continuous iff its underlying linear map is continuous. See also
`AffineMap.continuous_linear_iff`. -/
theorem continuous_iff {f : E →ᵃ[R] F} : Continuous f ↔ Continuous f.linear := by
  constructor
  · intro hc
    rw [decomp' f]
    

Proof state:
case mp
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Ring R
inst✝¹ : Module R E
inst✝ : Module R F
f : E →ᵃ[R] F
hc : Continuous ⇑f
⊢ Continuous (⇑f - fun x => f 0)

Next tactic:
exact hc.sub continuous_const
/-- An affine map is continuous iff its underlying linear map is continuous. See also
`AffineMap.continuous_linear_iff`. -/
theorem continuous_iff {f : E →ᵃ[R] F} : Continuous f ↔ Continuous f.linear := by
  constructor
  · intro hc
    rw [decomp' f]
    exact hc.sub continuous_const
  · 

Proof state:
case mpr
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Ring R
inst✝¹ : Module R E
inst✝ : Module R F
f : E →ᵃ[R] F
⊢ Continuous ⇑f.linear → Continuous ⇑f

Next tactic:
intro hc
/-- An affine map is continuous iff its underlying linear map is continuous. See also
`AffineMap.continuous_linear_iff`. -/
theorem continuous_iff {f : E →ᵃ[R] F} : Continuous f ↔ Continuous f.linear := by
  constructor
  · intro hc
    rw [decomp' f]
    exact hc.sub continuous_const
  · intro hc
    

Proof state:
case mpr
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Ring R
inst✝¹ : Module R E
inst✝ : Module R F
f : E →ᵃ[R] F
hc : Continuous ⇑f.linear
⊢ Continuous ⇑f

Next tactic:
rw [decomp f]
/-- An affine map is continuous iff its underlying linear map is continuous. See also
`AffineMap.continuous_linear_iff`. -/
theorem continuous_iff {f : E →ᵃ[R] F} : Continuous f ↔ Continuous f.linear := by
  constructor
  · intro hc
    rw [decomp' f]
    exact hc.sub continuous_const
  · intro hc
    rw [decomp f]
    

Proof state:
case mpr
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Ring R
inst✝¹ : Module R E
inst✝ : Module R F
f : E →ᵃ[R] F
hc : Continuous ⇑f.linear
⊢ Continuous (⇑f.linear + fun x => f 0)

Next tactic:
exact hc.add continuous_const
@[continuity]
theorem homothety_continuous (x : F) (t : R) : Continuous <| homothety x t := by
  

Proof state:
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : CommRing R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
⊢ Continuous ⇑(homothety x t)

Next tactic:
suffices ⇑(homothety x t) = fun y => t • (y - x) + x by
    rw [this]
    exact ((continuous_id.sub continuous_const).const_smul _).add continuous_const
@[continuity]
theorem homothety_continuous (x : F) (t : R) : Continuous <| homothety x t := by
  suffices ⇑(homothety x t) = fun y => t • (y - x) + x by
    

Proof state:
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : CommRing R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
this : ⇑(homothety x t) = fun y => t • (y - x) + x
⊢ Continuous ⇑(homothety x t)

Next tactic:
rw [this]
@[continuity]
theorem homothety_continuous (x : F) (t : R) : Continuous <| homothety x t := by
  suffices ⇑(homothety x t) = fun y => t • (y - x) + x by
    rw [this]
    

Proof state:
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : CommRing R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
this : ⇑(homothety x t) = fun y => t • (y - x) + x
⊢ Continuous fun y => t • (y - x) + x

Next tactic:
exact ((continuous_id.sub continuous_const).const_smul _).add continuous_const
@[continuity]
theorem homothety_continuous (x : F) (t : R) : Continuous <| homothety x t := by
  suffices ⇑(homothety x t) = fun y => t • (y - x) + x by
    rw [this]
    exact ((continuous_id.sub continuous_const).const_smul _).add continuous_const
    -- Porting note: proof was `by continuity`
  

Proof state:
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : CommRing R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
⊢ ⇑(homothety x t) = fun y => t • (y - x) + x

Next tactic:
ext y
@[continuity]
theorem homothety_continuous (x : F) (t : R) : Continuous <| homothety x t := by
  suffices ⇑(homothety x t) = fun y => t • (y - x) + x by
    rw [this]
    exact ((continuous_id.sub continuous_const).const_smul _).add continuous_const
    -- Porting note: proof was `by continuity`
  ext y
  

Proof state:
case h
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : CommRing R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
y : F
⊢ (homothety x t) y = t • (y - x) + x

Next tactic:
simp [homothety_apply]
theorem homothety_isOpenMap (x : F) (t : R) (ht : t ≠ 0) : IsOpenMap <| homothety x t := by
  

Proof state:
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Field R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
ht : t ≠ 0
⊢ IsOpenMap ⇑(homothety x t)

Next tactic:
apply IsOpenMap.of_inverse (homothety_continuous x t⁻¹)
theorem homothety_isOpenMap (x : F) (t : R) (ht : t ≠ 0) : IsOpenMap <| homothety x t := by
  apply IsOpenMap.of_inverse (homothety_continuous x t⁻¹) <;> 

Proof state:
case l_inv
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Field R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
ht : t ≠ 0
⊢ Function.LeftInverse ⇑(homothety x t) ⇑(homothety x t⁻¹)

Next tactic:
intro e
theorem homothety_isOpenMap (x : F) (t : R) (ht : t ≠ 0) : IsOpenMap <| homothety x t := by
  apply IsOpenMap.of_inverse (homothety_continuous x t⁻¹) <;> 

Proof state:
case r_inv
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Field R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
ht : t ≠ 0
⊢ Function.RightInverse ⇑(homothety x t) ⇑(homothety x t⁻¹)

Next tactic:
intro e
theorem homothety_isOpenMap (x : F) (t : R) (ht : t ≠ 0) : IsOpenMap <| homothety x t := by
  apply IsOpenMap.of_inverse (homothety_continuous x t⁻¹) <;> intro e <;>
    

Proof state:
case l_inv
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Field R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
ht : t ≠ 0
e : F
⊢ (homothety x t) ((homothety x t⁻¹) e) = e

Next tactic:
simp [← AffineMap.comp_apply, ← homothety_mul, ht]
theorem homothety_isOpenMap (x : F) (t : R) (ht : t ≠ 0) : IsOpenMap <| homothety x t := by
  apply IsOpenMap.of_inverse (homothety_continuous x t⁻¹) <;> intro e <;>
    

Proof state:
case r_inv
R : Type u_1
E : Type u_2
F : Type u_3
inst✝⁷ : AddCommGroup E
inst✝⁶ : TopologicalSpace E
inst✝⁵ : AddCommGroup F
inst✝⁴ : TopologicalSpace F
inst✝³ : TopologicalAddGroup F
inst✝² : Field R
inst✝¹ : Module R F
inst✝ : ContinuousConstSMul R F
x : F
t : R
ht : t ≠ 0
e : F
⊢ (homothety x t⁻¹) ((homothety x t) e) = e

Next tactic:
simp [← AffineMap.comp_apply, ← homothety_mul, ht]
@[simp]
lemma harmonic_succ (n : ℕ) : harmonic (n + 1) = harmonic n + (↑(n + 1))⁻¹ := by
  

Proof state:
n : ℕ
⊢ harmonic (n + 1) = harmonic n + (↑(n + 1))⁻¹

Next tactic:
apply Finset.sum_range_succ
lemma harmonic_pos {n : ℕ} (Hn : n ≠ 0) : 0 < harmonic n :=
  Finset.sum_pos (fun _ _ => inv_pos.mpr (by 

Proof state:
n : ℕ
Hn : n ≠ 0
x✝¹ : ℕ
x✝ : x✝¹ ∈ Finset.range n
⊢ 0 < ↑(x✝¹ + 1)

Next tactic:
norm_cast
lemma harmonic_pos {n : ℕ} (Hn : n ≠ 0) : 0 < harmonic n :=
  Finset.sum_pos (fun _ _ => inv_pos.mpr (by norm_cast; 

Proof state:
n : ℕ
Hn : n ≠ 0
x✝¹ : ℕ
x✝ : x✝¹ ∈ Finset.range n
⊢ 0 < x✝¹ + 1

Next tactic:
linarith
lemma harmonic_pos {n : ℕ} (Hn : n ≠ 0) : 0 < harmonic n :=
  Finset.sum_pos (fun _ _ => inv_pos.mpr (by norm_cast; linarith))
  (by 

Proof state:
n : ℕ
Hn : n ≠ 0
⊢ Finset.Nonempty (Finset.range n)

Next tactic:
rwa [Finset.nonempty_range_iff]
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  

Proof state:
n : ℕ
⊢ padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)

Next tactic:
induction' n with n ih
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · 

Proof state:
case zero
⊢ padicValRat 2 (harmonic Nat.zero) = -↑(Nat.log 2 Nat.zero)

Next tactic:
simp
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · 

Proof state:
case succ
n : ℕ
ih : padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)
⊢ padicValRat 2 (harmonic (Nat.succ n)) = -↑(Nat.log 2 (Nat.succ n))

Next tactic:
rcases eq_or_ne n 0 with rfl | hn
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · rcases eq_or_ne n 0 with rfl | hn
    · 

Proof state:
case succ.inl
ih : padicValRat 2 (harmonic 0) = -↑(Nat.log 2 0)
⊢ padicValRat 2 (harmonic (Nat.succ 0)) = -↑(Nat.log 2 (Nat.succ 0))

Next tactic:
simp
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · rcases eq_or_ne n 0 with rfl | hn
    · simp
    

Proof state:
case succ.inr
n : ℕ
ih : padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)
hn : n ≠ 0
⊢ padicValRat 2 (harmonic (Nat.succ n)) = -↑(Nat.log 2 (Nat.succ n))

Next tactic:
rw [harmonic_succ]
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · rcases eq_or_ne n 0 with rfl | hn
    · simp
    rw [harmonic_succ]
    

Proof state:
case succ.inr
n : ℕ
ih : padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)
hn : n ≠ 0
⊢ padicValRat 2 (harmonic n + (↑(n + 1))⁻¹) = -↑(Nat.log 2 (Nat.succ n))

Next tactic:
have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · rcases eq_or_ne n 0 with rfl | hn
    · simp
    rw [harmonic_succ]
    have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹
    · 

Proof state:
case key
n : ℕ
ih : padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)
hn : n ≠ 0
⊢ padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹

Next tactic:
rw [ih, padicValRat.inv, padicValRat.of_nat, Ne, neg_inj, Nat.cast_inj]
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · rcases eq_or_ne n 0 with rfl | hn
    · simp
    rw [harmonic_succ]
    have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹
    · rw [ih, padicValRat.inv, padicValRat.of_nat, Ne, neg_inj, Nat.cast_inj]
      

Proof state:
case key
n : ℕ
ih : padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)
hn : n ≠ 0
⊢ ¬Nat.log 2 n = padicValNat 2 (n + 1)

Next tactic:
exact Nat.log_ne_padicValNat_succ hn
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · rcases eq_or_ne n 0 with rfl | hn
    · simp
    rw [harmonic_succ]
    have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹
    · rw [ih, padicValRat.inv, padicValRat.of_nat, Ne, neg_inj, Nat.cast_inj]
      exact Nat.log_ne_padicValNat_succ hn
    

Proof state:
case succ.inr
n : ℕ
ih : padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)
hn : n ≠ 0
key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹
⊢ padicValRat 2 (harmonic n + (↑(n + 1))⁻¹) = -↑(Nat.log 2 (Nat.succ n))

Next tactic:
rw [padicValRat.add_eq_min (harmonic_succ n ▸ (harmonic_pos n.succ_ne_zero).ne')
        (harmonic_pos hn).ne' (inv_ne_zero (Nat.cast_ne_zero.mpr n.succ_ne_zero)) key, ih,
        padicValRat.inv, padicValRat.of_nat, min_neg_neg, neg_inj, ← Nat.cast_max, Nat.cast_inj]
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
    of n. -/
theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by
  induction' n with n ih
  · simp
  · rcases eq_or_ne n 0 with rfl | hn
    · simp
    rw [harmonic_succ]
    have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹
    · rw [ih, padicValRat.inv, padicValRat.of_nat, Ne, neg_inj, Nat.cast_inj]
      exact Nat.log_ne_padicValNat_succ hn
    rw [padicValRat.add_eq_min (harmonic_succ n ▸ (harmonic_pos n.succ_ne_zero).ne')
        (harmonic_pos hn).ne' (inv_ne_zero (Nat.cast_ne_zero.mpr n.succ_ne_zero)) key, ih,
        padicValRat.inv, padicValRat.of_nat, min_neg_neg, neg_inj, ← Nat.cast_max, Nat.cast_inj]
    

Proof state:
case succ.inr
n : ℕ
ih : padicValRat 2 (harmonic n) = -↑(Nat.log 2 n)
hn : n ≠ 0
key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹
⊢ max (Nat.log 2 n) (padicValNat 2 (Nat.succ n)) = Nat.log 2 (Nat.succ n)

Next tactic:
exact Nat.max_log_padicValNat_succ_eq_log_succ n
/-- The 2-adic norm of the n-th harmonic number is 2 raised to the logarithm of n in base 2. -/
lemma padicNorm_two_harmonic {n : ℕ} (hn : n ≠ 0) :
    ‖(harmonic n : ℚ_[2])‖ = 2 ^ (Nat.log 2 n) := by
  

Proof state:
n : ℕ
hn : n ≠ 0
⊢ ‖↑(harmonic n)‖ = 2 ^ Nat.log 2 n

Next tactic:
rw [padicNormE.eq_padicNorm, padicNorm.eq_zpow_of_nonzero (harmonic_pos hn).ne',
    padicValRat_two_harmonic, neg_neg, zpow_coe_nat, Rat.cast_pow, Rat.cast_coe_nat, Nat.cast_ofNat]
/-- The n-th harmonic number is not an integer for n ≥ 2. -/
theorem harmonic_not_int {n : ℕ} (h : 2 ≤ n) : ¬ (harmonic n).isInt := by
  

Proof state:
n : ℕ
h : 2 ≤ n
⊢ ¬Rat.isInt (harmonic n) = true

Next tactic:
apply padicNorm.not_int_of_not_padic_int 2
/-- The n-th harmonic number is not an integer for n ≥ 2. -/
theorem harmonic_not_int {n : ℕ} (h : 2 ≤ n) : ¬ (harmonic n).isInt := by
  apply padicNorm.not_int_of_not_padic_int 2
  

Proof state:
n : ℕ
h : 2 ≤ n
⊢ 1 < padicNorm 2 (harmonic n)

Next tactic:
rw [padicNorm.eq_zpow_of_nonzero (harmonic_pos (ne_zero_of_lt h)).ne',
      padicValRat_two_harmonic, neg_neg, zpow_coe_nat]
/-- The n-th harmonic number is not an integer for n ≥ 2. -/
theorem harmonic_not_int {n : ℕ} (h : 2 ≤ n) : ¬ (harmonic n).isInt := by
  apply padicNorm.not_int_of_not_padic_int 2
  rw [padicNorm.eq_zpow_of_nonzero (harmonic_pos (ne_zero_of_lt h)).ne',
      padicValRat_two_harmonic, neg_neg, zpow_coe_nat]
  

Proof state:
n : ℕ
h : 2 ≤ n
⊢ 1 < ↑2 ^ Nat.log 2 n

Next tactic:
exact one_lt_pow one_lt_two (Nat.log_pos one_lt_two h).ne'
instance : OrderRingHomClass (α →+*o β) α β
    where
  coe f := f.toFun
  coe_injective' f g h := by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁷ : NonAssocSemiring α
inst✝⁶ : Preorder α
inst✝⁵ : NonAssocSemiring β
inst✝⁴ : Preorder β
inst✝³ : NonAssocSemiring γ
inst✝² : Preorder γ
inst✝¹ : NonAssocSemiring δ
inst✝ : Preorder δ
f g : α →+*o β
h : (fun f => f.toFun) f = (fun f => f.toFun) g
⊢ f = g

Next tactic:
obtain ⟨⟨_, _⟩, _⟩ := f
instance : OrderRingHomClass (α →+*o β) α β
    where
  coe f := f.toFun
  coe_injective' f g h := by
    obtain ⟨⟨_, _⟩, _⟩ := f; 

Proof state:
case mk.mk
F : Type u_1
α : Type u_2
β : Type u_3
γ : Type u_4
δ : Type u_5
inst✝⁷ : NonAssocSemiring α
inst✝⁶ : Preorder α
inst✝⁵ : NonAssocSemiring β
inst✝⁴ : Preorder β
inst✝³ : NonAssocSemiring γ
inst✝² : Preorder γ
inst✝¹ : NonAssocSemiring δ
inst✝ : Preorder δ
g : α →+*o β
toMonoidHom✝ : α →* β
map_zero'✝ : OneHom.toFun (↑toMonoidHom✝) 0 = 0
map_add'✝ :
  ∀ (x y : α), OneHom.toFun (↑toMonoidHom✝) (x + y) = OneHom.toFun (↑toMonoidHom✝) x + OneHom.toFun (↑toMonoidHom✝) y
monotone'✝ : Monotone (↑↑{ toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ }).toFun
h :
  (fun f => f.toFun)
      { toRingHom := { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ },
        monotone' := monotone'✝ } =
    (fun f => f.toFun) g
⊢ { toRingHom := { toMonoidHom := toMonoidHom✝, map_zero' := map_zero'✝, map_add' := map_add'✝ },
      monotone' := monotone'✝ } =
    g

Next tactic:
obtain ⟨⟨_, _⟩, _⟩ := g