l3lab/ntp-mathlib huggingface dataset:
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  

Proof state:
case succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
⊢ appr x (succ n) < p ^ succ n

Next tactic:
simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  

Proof state:
case succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
⊢ (if h : x - ↑(appr x n) = 0 then appr x n
    else
      appr x n +
        p ^ n *
          ZMod.val
            (toZMod ↑(unitCoeff (_ : ¬x - ↑(appr x n) = 0)) *
              0 ^
                match valuation (x - ↑(appr x n)) - ↑n with
                | Int.ofNat m => m
                | Int.negSucc m => succ m)) <
    p ^ succ n

Next tactic:
have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by 

Proof state:
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
⊢ p ^ n < p ^ (n + 1)

Next tactic:
apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  

Proof state:
case succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
⊢ (if h : x - ↑(appr x n) = 0 then appr x n
    else
      appr x n +
        p ^ n *
          ZMod.val
            (toZMod ↑(unitCoeff (_ : ¬x - ↑(appr x n) = 0)) *
              0 ^
                match valuation (x - ↑(appr x n)) - ↑n with
                | Int.ofNat m => m
                | Int.negSucc m => succ m)) <
    p ^ succ n

Next tactic:
split_ifs with h
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · 

Proof state:
case pos
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : x - ↑(appr x n) = 0
⊢ appr x n < p ^ succ n

Next tactic:
apply lt_trans (ih _) hp
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · apply lt_trans (ih _) hp
  · 

Proof state:
case neg
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : ¬x - ↑(appr x n) = 0
⊢ appr x n +
      p ^ n *
        ZMod.val
          (toZMod ↑(unitCoeff (_ : ¬x - ↑(appr x n) = 0)) *
            0 ^
              match valuation (x - ↑(appr x n)) - ↑n with
              | Int.ofNat m => m
              | Int.negSucc m => succ m) <
    p ^ succ n

Next tactic:
calc
      _ < p ^ n + p ^ n * (p - 1) := ?_
      _ = p ^ (n + 1) := ?_
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · apply lt_trans (ih _) hp
  · calc
      _ < p ^ n + p ^ n * (p - 1) := ?_
      _ = p ^ (n + 1) := ?_

    · 

Proof state:
case neg.calc_1
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : ¬x - ↑(appr x n) = 0
⊢ appr x n +
      p ^ n *
        ZMod.val
          (toZMod ↑(unitCoeff (_ : ¬x - ↑(appr x n) = 0)) *
            0 ^
              match valuation (x - ↑(appr x n)) - ↑n with
              | Int.ofNat m => m
              | Int.negSucc m => succ m) <
    p ^ n + p ^ n * (p - 1)

Next tactic:
apply add_lt_add_of_lt_of_le (ih _)
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · apply lt_trans (ih _) hp
  · calc
      _ < p ^ n + p ^ n * (p - 1) := ?_
      _ = p ^ (n + 1) := ?_

    · apply add_lt_add_of_lt_of_le (ih _)
      

Proof state:
case neg.calc_1
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : ¬x - ↑(appr x n) = 0
⊢ p ^ n *
      ZMod.val
        (toZMod ↑(unitCoeff (_ : ¬x - ↑(appr x n) = 0)) *
          0 ^
            match valuation (x - ↑(appr x n)) - ↑n with
            | Int.ofNat m => m
            | Int.negSucc m => succ m) ≤
    p ^ n * (p - 1)

Next tactic:
apply Nat.mul_le_mul_left
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · apply lt_trans (ih _) hp
  · calc
      _ < p ^ n + p ^ n * (p - 1) := ?_
      _ = p ^ (n + 1) := ?_

    · apply add_lt_add_of_lt_of_le (ih _)
      apply Nat.mul_le_mul_left
      

Proof state:
case neg.calc_1.h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : ¬x - ↑(appr x n) = 0
⊢ ZMod.val
      (toZMod ↑(unitCoeff (_ : ¬x - ↑(appr x n) = 0)) *
        0 ^
          match valuation (x - ↑(appr x n)) - ↑n with
          | Int.ofNat m => m
          | Int.negSucc m => succ m) ≤
    p - 1

Next tactic:
apply le_pred_of_lt
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · apply lt_trans (ih _) hp
  · calc
      _ < p ^ n + p ^ n * (p - 1) := ?_
      _ = p ^ (n + 1) := ?_

    · apply add_lt_add_of_lt_of_le (ih _)
      apply Nat.mul_le_mul_left
      apply le_pred_of_lt
      

Proof state:
case neg.calc_1.h.h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : ¬x - ↑(appr x n) = 0
⊢ ZMod.val
      (toZMod ↑(unitCoeff (_ : ¬x - ↑(appr x n) = 0)) *
        0 ^
          match valuation (x - ↑(appr x n)) - ↑n with
          | Int.ofNat m => m
          | Int.negSucc m => succ m) <
    Nat.sub p 0

Next tactic:
apply ZMod.val_lt
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · apply lt_trans (ih _) hp
  · calc
      _ < p ^ n + p ^ n * (p - 1) := ?_
      _ = p ^ (n + 1) := ?_

    · apply add_lt_add_of_lt_of_le (ih _)
      apply Nat.mul_le_mul_left
      apply le_pred_of_lt
      apply ZMod.val_lt
    · 

Proof state:
case neg.calc_2
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : ¬x - ↑(appr x n) = 0
⊢ p ^ n + p ^ n * (p - 1) = p ^ (n + 1)

Next tactic:
rw [mul_tsub, mul_one, ← _root_.pow_succ']
theorem appr_lt (x : ℤ_[p]) (n : ℕ) : x.appr n < p ^ n := by
  induction' n with n ih generalizing x
  · simp only [appr, zero_eq, _root_.pow_zero, zero_lt_one]
  simp only [appr, map_natCast, ZMod.nat_cast_self, RingHom.map_pow, Int.natAbs, RingHom.map_mul]
  have hp : p ^ n < p ^ (n + 1) := by apply pow_lt_pow_right hp_prime.1.one_lt (lt_add_one n)
  split_ifs with h
  · apply lt_trans (ih _) hp
  · calc
      _ < p ^ n + p ^ n * (p - 1) := ?_
      _ = p ^ (n + 1) := ?_

    · apply add_lt_add_of_lt_of_le (ih _)
      apply Nat.mul_le_mul_left
      apply le_pred_of_lt
      apply ZMod.val_lt
    · rw [mul_tsub, mul_one, ← _root_.pow_succ']
      

Proof state:
case neg.calc_2
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), appr x n < p ^ n
x : ℤ_[p]
hp : p ^ n < p ^ (n + 1)
h : ¬x - ↑(appr x n) = 0
⊢ p ^ n + (p ^ (n + 1) - p ^ n) = p ^ (n + 1)

Next tactic:
apply add_tsub_cancel_of_le (le_of_lt hp)
theorem appr_mono (x : ℤ_[p]) : Monotone x.appr := by
  

Proof state:
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
⊢ Monotone (appr x)

Next tactic:
apply monotone_nat_of_le_succ
theorem appr_mono (x : ℤ_[p]) : Monotone x.appr := by
  apply monotone_nat_of_le_succ
  

Proof state:
case hf
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
⊢ ∀ (n : ℕ), appr x n ≤ appr x (n + 1)

Next tactic:
intro n
theorem appr_mono (x : ℤ_[p]) : Monotone x.appr := by
  apply monotone_nat_of_le_succ
  intro n
  

Proof state:
case hf
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
n : ℕ
⊢ appr x n ≤ appr x (n + 1)

Next tactic:
dsimp [appr]
theorem appr_mono (x : ℤ_[p]) : Monotone x.appr := by
  apply monotone_nat_of_le_succ
  intro n
  dsimp [appr]
  

Proof state:
case hf
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
n : ℕ
⊢ appr x n ≤
    if hy : x - ↑(appr x n) = 0 then appr x n
    else appr x n + p ^ n * ZMod.val (toZMod (↑(unitCoeff hy) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x n)) - ↑n)))

Next tactic:
split_ifs
theorem appr_mono (x : ℤ_[p]) : Monotone x.appr := by
  apply monotone_nat_of_le_succ
  intro n
  dsimp [appr]
  split_ifs; · 

Proof state:
case pos
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
n : ℕ
h✝ : x - ↑(appr x n) = 0
⊢ appr x n ≤ appr x n

Next tactic:
rfl
theorem appr_mono (x : ℤ_[p]) : Monotone x.appr := by
  apply monotone_nat_of_le_succ
  intro n
  dsimp [appr]
  split_ifs; · rfl
  

Proof state:
case neg
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
n : ℕ
h✝ : ¬x - ↑(appr x n) = 0
⊢ appr x n ≤ appr x n + p ^ n * ZMod.val (toZMod (↑(unitCoeff h✝) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x n)) - ↑n)))

Next tactic:
apply Nat.le_add_right
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  

Proof state:
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m n : ℕ
h : m ≤ n
⊢ p ^ m ∣ appr x n - appr x m

Next tactic:
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; 

Proof state:
case intro
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
h : m ≤ m + k
⊢ p ^ m ∣ appr x (m + k) - appr x m

Next tactic:
clear h
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  

Proof state:
case intro
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
⊢ p ^ m ∣ appr x (m + k) - appr x m

Next tactic:
induction' k with k ih
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · 

Proof state:
case intro.zero
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m : ℕ
⊢ p ^ m ∣ appr x (m + zero) - appr x m

Next tactic:
simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  

Proof state:
case intro.succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
⊢ p ^ m ∣ appr x (m + succ k) - appr x m

Next tactic:
rw [Nat.succ_eq_add_one, ← add_assoc]
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  rw [Nat.succ_eq_add_one, ← add_assoc]
  

Proof state:
case intro.succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
⊢ p ^ m ∣ appr x (m + k + 1) - appr x m

Next tactic:
dsimp [appr]
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  rw [Nat.succ_eq_add_one, ← add_assoc]
  dsimp [appr]
  

Proof state:
case intro.succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
⊢ p ^ m ∣
    (if hy : x - ↑(appr x (m + k)) = 0 then appr x (m + k)
      else
        appr x (m + k) +
          p ^ (m + k) *
            ZMod.val (toZMod (↑(unitCoeff hy) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x (m + k))) - ↑(m + k))))) -
      appr x m

Next tactic:
split_ifs with h
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  rw [Nat.succ_eq_add_one, ← add_assoc]
  dsimp [appr]
  split_ifs with h
  · 

Proof state:
case pos
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
h : x - ↑(appr x (m + k)) = 0
⊢ p ^ m ∣ appr x (m + k) - appr x m

Next tactic:
exact ih
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  rw [Nat.succ_eq_add_one, ← add_assoc]
  dsimp [appr]
  split_ifs with h
  · exact ih
  

Proof state:
case neg
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
h : ¬x - ↑(appr x (m + k)) = 0
⊢ p ^ m ∣
    appr x (m + k) +
        p ^ (m + k) *
          ZMod.val (toZMod (↑(unitCoeff h) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x (m + k))) - ↑(m + k)))) -
      appr x m

Next tactic:
rw [add_comm, add_tsub_assoc_of_le (appr_mono _ (Nat.le_add_right m k))]
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  rw [Nat.succ_eq_add_one, ← add_assoc]
  dsimp [appr]
  split_ifs with h
  · exact ih
  rw [add_comm, add_tsub_assoc_of_le (appr_mono _ (Nat.le_add_right m k))]
  

Proof state:
case neg
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
h : ¬x - ↑(appr x (m + k)) = 0
⊢ p ^ m ∣
    p ^ (m + k) * ZMod.val (toZMod (↑(unitCoeff h) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x (m + k))) - ↑(m + k)))) +
      (appr x (m + k) - appr x m)

Next tactic:
apply dvd_add _ ih
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  rw [Nat.succ_eq_add_one, ← add_assoc]
  dsimp [appr]
  split_ifs with h
  · exact ih
  rw [add_comm, add_tsub_assoc_of_le (appr_mono _ (Nat.le_add_right m k))]
  apply dvd_add _ ih
  

Proof state:
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
h : ¬x - ↑(appr x (m + k)) = 0
⊢ p ^ m ∣
    p ^ (m + k) * ZMod.val (toZMod (↑(unitCoeff h) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x (m + k))) - ↑(m + k))))

Next tactic:
apply dvd_mul_of_dvd_left
theorem dvd_appr_sub_appr (x : ℤ_[p]) (m n : ℕ) (h : m ≤ n) : p ^ m ∣ x.appr n - x.appr m := by
  obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le h; clear h
  induction' k with k ih
  · simp only [zero_eq, add_zero, le_refl, tsub_eq_zero_of_le, ne_eq, Nat.isUnit_iff, dvd_zero]
  rw [Nat.succ_eq_add_one, ← add_assoc]
  dsimp [appr]
  split_ifs with h
  · exact ih
  rw [add_comm, add_tsub_assoc_of_le (appr_mono _ (Nat.le_add_right m k))]
  apply dvd_add _ ih
  apply dvd_mul_of_dvd_left
  

Proof state:
case h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ x : ℤ_[p]
m k : ℕ
ih : p ^ m ∣ appr x (m + k) - appr x m
h : ¬x - ↑(appr x (m + k)) = 0
⊢ p ^ m ∣ p ^ (m + k)

Next tactic:
apply pow_dvd_pow _ (Nat.le_add_right m k)
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  

Proof state:
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x : ℤ_[p]
n : ℕ
⊢ ∀ (x : ℤ_[p]), x - ↑(appr x n) ∈ Ideal.span {↑p ^ n}

Next tactic:
simp only [Ideal.mem_span_singleton]
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  

Proof state:
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x : ℤ_[p]
n : ℕ
⊢ ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)

Next tactic:
induction' n with n ih
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · 

Proof state:
case zero
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x : ℤ_[p]
⊢ ∀ (x : ℤ_[p]), ↑p ^ zero ∣ x - ↑(appr x zero)

Next tactic:
simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  

Proof state:
case succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
⊢ ∀ (x : ℤ_[p]), ↑p ^ succ n ∣ x - ↑(appr x (succ n))

Next tactic:
intro x
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  intro x
  

Proof state:
case succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
x : ℤ_[p]
⊢ ↑p ^ succ n ∣ x - ↑(appr x (succ n))

Next tactic:
dsimp only [appr]
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  intro x
  dsimp only [appr]
  

Proof state:
case succ
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
x : ℤ_[p]
⊢ ↑p ^ succ n ∣
    x -
      ↑(if hy : x - ↑(appr x n) = 0 then appr x n
        else
          appr x n + p ^ n * ZMod.val (toZMod (↑(unitCoeff hy) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x n)) - ↑n))))

Next tactic:
split_ifs with h
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  intro x
  dsimp only [appr]
  split_ifs with h
  · 

Proof state:
case pos
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
x : ℤ_[p]
h : x - ↑(appr x n) = 0
⊢ ↑p ^ succ n ∣ x - ↑(appr x n)

Next tactic:
rw [h]
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  intro x
  dsimp only [appr]
  split_ifs with h
  · rw [h]
    

Proof state:
case pos
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
x : ℤ_[p]
h : x - ↑(appr x n) = 0
⊢ ↑p ^ succ n ∣ 0

Next tactic:
apply dvd_zero
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  intro x
  dsimp only [appr]
  split_ifs with h
  · rw [h]
    apply dvd_zero
  

Proof state:
case neg
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
x : ℤ_[p]
h : ¬x - ↑(appr x n) = 0
⊢ ↑p ^ succ n ∣
    x - ↑(appr x n + p ^ n * ZMod.val (toZMod (↑(unitCoeff h) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x n)) - ↑n))))

Next tactic:
push_cast
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  intro x
  dsimp only [appr]
  split_ifs with h
  · rw [h]
    apply dvd_zero
  push_cast
  

Proof state:
case neg
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
x : ℤ_[p]
h : ¬x - ↑(appr x n) = 0
⊢ ↑p ^ succ n ∣
    x -
      (↑(appr x n) +
        ↑p ^ n * ↑(ZMod.val (toZMod (↑(unitCoeff h) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x n)) - ↑n)))))

Next tactic:
rw [sub_add_eq_sub_sub]
theorem appr_spec (n : ℕ) : ∀ x : ℤ_[p], x - appr x n ∈ Ideal.span {(p : ℤ_[p]) ^ n} := by
  simp only [Ideal.mem_span_singleton]
  induction' n with n ih
  · simp only [zero_eq, _root_.pow_zero, isUnit_one, IsUnit.dvd, forall_const]
  intro x
  dsimp only [appr]
  split_ifs with h
  · rw [h]
    apply dvd_zero
  push_cast
  rw [sub_add_eq_sub_sub]
  

Proof state:
case neg
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
n : ℕ
ih : ∀ (x : ℤ_[p]), ↑p ^ n ∣ x - ↑(appr x n)
x : ℤ_[p]
h : ¬x - ↑(appr x n) = 0
⊢ ↑p ^ succ n ∣
    x - ↑(appr x n) -
      ↑p ^ n * ↑(ZMod.val (toZMod (↑(unitCoeff h) * ↑p ^ Int.natAbs (valuation (x - ↑(appr x n)) - ↑n))))

Next tactic:
obtain ⟨c, hc⟩ := ih x