zzhisthebest/LeanBenchmark huggingface dataset:
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_5 {n m : ℕ+} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ} (hA : ¬A = 0)
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) :
  let normA := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖;
  (∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖) →
    0 < normA →
      ∀ (y : EuclideanSpace ℝ (Fin ↑n)),
        ‖x - y‖ ≤ ε / normA ^ 2 →
          ((fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) ⬝ᵥ fun x_1 => y x_1 - x x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x) →
            |A *ᵥ y ⬝ᵥ A *ᵥ y - A *ᵥ x ⬝ᵥ A *ᵥ x - 2 * (fun x_1 => y x_1 - x x_1) ⬝ᵥ (Aᵀ * A) *ᵥ x| ≤ ε * ‖x - y‖ →
              |A *ᵥ y ⬝ᵥ A *ᵥ y + (A *ᵥ x ⬝ᵥ A *ᵥ x - A *ᵥ x ⬝ᵥ A *ᵥ y * 2)| ≤ ε * ‖x - y‖ := sorry

Tactic state before:
case h.right
n m : ℕ+
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
hA : ¬A = 0
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
normApos : 0 < normA
y : EuclideanSpace ℝ (Fin ↑n)
ydist : ‖x - y‖ ≤ ε / normA ^ 2
aux1 : ((fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) ⬝ᵥ fun x_1 => y x_1 - x x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
⊢ |A *ᵥ y ⬝ᵥ A *ᵥ y - A *ᵥ x ⬝ᵥ A *ᵥ x - 2 * (fun x_1 => y x_1 - x x_1) ⬝ᵥ (Aᵀ * A) *ᵥ x| ≤ ε * ‖x - y‖

Tactic:
rw [dotProduct_comm] at aux1
    rw [aux1, ← mulVec_mulVec, ← dot_mul_eq_transpose_mul_dot _ (y - x), Matrix.mulVec_sub, dotProduct_sub]
    ring_nf

Tactic state after:
[case h.right
 n m : ℕ+
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 hA : ¬A = 0
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
 norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
 normApos : 0 < normA
 y : EuclideanSpace ℝ (Fin ↑n)
 ydist : ‖x - y‖ ≤ ε / normA ^ 2
 aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
 ⊢ |A *ᵥ y ⬝ᵥ A *ᵥ y + (A *ᵥ x ⬝ᵥ A *ᵥ x - A *ᵥ x ⬝ᵥ A *ᵥ y * 2)| ≤ ε * ‖x - y‖]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_6 {n m : ℕ+} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ} (hA : ¬A = 0)
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) :
  let normA := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖;
  (∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖) →
    0 < normA →
      ∀ (y : EuclideanSpace ℝ (Fin ↑n)),
        ‖x - y‖ ≤ ε / normA ^ 2 →
          ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x) →
            (∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)) →
              |A *ᵥ y ⬝ᵥ A *ᵥ y + (A *ᵥ x ⬝ᵥ A *ᵥ x - A *ᵥ x ⬝ᵥ A *ᵥ y * 2)| ≤ ε * ‖x - y‖ →
                ‖A *ᵥ (y - x)‖ ^ 2 ≤ ε * ‖x - y‖ := sorry

Tactic state before:
case h.right
n m : ℕ+
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
hA : ¬A = 0
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
normApos : 0 < normA
y : EuclideanSpace ℝ (Fin ↑n)
ydist : ‖x - y‖ ≤ ε / normA ^ 2
aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
⊢ |A *ᵥ y ⬝ᵥ A *ᵥ y + (A *ᵥ x ⬝ᵥ A *ᵥ x - A *ᵥ x ⬝ᵥ A *ᵥ y * 2)| ≤ ε * ‖x - y‖

Tactic:
rw [aux2, ← norm2eq_dot]
    simp
    rw [← Matrix.mulVec_sub]

Tactic state after:
[case h.right
 n m : ℕ+
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 hA : ¬A = 0
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
 norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
 normApos : 0 < normA
 y : EuclideanSpace ℝ (Fin ↑n)
 ydist : ‖x - y‖ ≤ ε / normA ^ 2
 aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
 aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
 ⊢ ‖A *ᵥ (y - x)‖ ^ 2 ≤ ε * ‖x - y‖]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_7 {n m : ℕ+} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ} (hA : ¬A = 0)
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) :
  let normA := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖;
  (∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖) →
    0 < normA →
      ∀ (y : EuclideanSpace ℝ (Fin ↑n)),
        ‖x - y‖ ≤ ε / normA ^ 2 →
          ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x) →
            (∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)) →
              ‖A *ᵥ (y - x)‖ ^ 2 ≤ (normA * ‖x - y‖) ^ 2 := sorry

Tactic state before:
n m : ℕ+
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
hA : ¬A = 0
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
normApos : 0 < normA
y : EuclideanSpace ℝ (Fin ↑n)
ydist : ‖x - y‖ ≤ ε / normA ^ 2
aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
⊢ ‖A *ᵥ (y - x)‖ ^ 2 ≤ (normA * ‖x - y‖) ^ 2

Tactic:
rw [norm_sub_rev]
    apply sq_le_sq' _ (norm_mul (y - x))
    calc
  -(normA * ‖y - x‖) ≤ 0 := by to_theorem simp;apply mul_nonneg;linarith [normApos]; apply norm_nonneg
  _ ≤ ‖A *ᵥ (y - x)‖₂ := by apply norm_nonneg

Tactic state after:
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_8 {n m : ℕ+} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ} (hA : ¬A = 0)
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) :
  let normA := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖;
  (∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖) →
    0 < normA →
      ∀ (y : EuclideanSpace ℝ (Fin ↑n)),
        ‖x - y‖ ≤ ε / normA ^ 2 →
          ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x) →
            (∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)) →
              -(normA * ‖y - x‖) ≤ 0 → 0 ≤ ‖y - x‖ := sorry

Tactic state before:
n m : ℕ+
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
hA : ¬A = 0
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
normApos : 0 < normA
y : EuclideanSpace ℝ (Fin ↑n)
ydist : ‖x - y‖ ≤ ε / normA ^ 2
aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
⊢ -(normA * ‖y - x‖) ≤ 0

Tactic:
simp
    apply mul_nonneg
    linarith [normApos]

Tactic state after:
[case hb
 n m : ℕ+
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 hA : ¬A = 0
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
 norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
 normApos : 0 < normA
 y : EuclideanSpace ℝ (Fin ↑n)
 ydist : ‖x - y‖ ≤ ε / normA ^ 2
 aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
 aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
 ⊢ 0 ≤ ‖y - x‖]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_9 {n m : ℕ+} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ} (hA : ¬A = 0)
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) :
  let normA := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖;
  (∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖) →
    0 < normA →
      ∀ (y : EuclideanSpace ℝ (Fin ↑n)),
        ‖x - y‖ ≤ ε / normA ^ 2 →
          ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x) →
            (∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)) →
              (normA * ‖x - y‖) ^ 2 ≤ ε * ‖x - y‖ → ‖x - y‖ * normA ^ 2 ≤ ε := sorry

Tactic state before:
n m : ℕ+
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
hA : ¬A = 0
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
normApos : 0 < normA
y : EuclideanSpace ℝ (Fin ↑n)
ydist : ‖x - y‖ ≤ ε / normA ^ 2
aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
⊢ (normA * ‖x - y‖) ^ 2 ≤ ε * ‖x - y‖

Tactic:
rw [pow_two, ← mul_assoc]
    apply mul_le_mul_of_nonneg_right
    rw [mul_rotate, mul_assoc, ← pow_two]

Tactic state after:
[case h
 n m : ℕ+
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 hA : ¬A = 0
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
 norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
 normApos : 0 < normA
 y : EuclideanSpace ℝ (Fin ↑n)
 ydist : ‖x - y‖ ≤ ε / normA ^ 2
 aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
 aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
 ⊢ ‖x - y‖ * normA ^ 2 ≤ ε,
 case a0
 n m : ℕ+
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 hA : ¬A = 0
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
 norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
 normApos : 0 < normA
 y : EuclideanSpace ℝ (Fin ↑n)
 ydist : ‖x - y‖ ≤ ε / normA ^ 2
 aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
 aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
 ⊢ 0 ≤ ‖x - y‖]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_10 {n m : ℕ+} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ} (hA : ¬A = 0)
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) :
  let normA := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖;
  (∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖) →
    0 < normA →
      ∀ (y : EuclideanSpace ℝ (Fin ↑n)),
        ‖x - y‖ ≤ ε / normA ^ 2 →
          ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x) →
            (∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)) →
              (normA * ‖x - y‖) ^ 2 ≤ ε * ‖x - y‖ → 0 ≤ ‖x - y‖ := sorry

Tactic state before:
n m : ℕ+
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
hA : ¬A = 0
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
normApos : 0 < normA
y : EuclideanSpace ℝ (Fin ↑n)
ydist : ‖x - y‖ ≤ ε / normA ^ 2
aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
⊢ (normA * ‖x - y‖) ^ 2 ≤ ε * ‖x - y‖

Tactic:
rw [pow_two, ← mul_assoc]
    apply mul_le_mul_of_nonneg_right
    rw [mul_rotate, mul_assoc, ← pow_two]

Tactic state after:
[case h
 n m : ℕ+
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 hA : ¬A = 0
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
 norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
 normApos : 0 < normA
 y : EuclideanSpace ℝ (Fin ↑n)
 ydist : ‖x - y‖ ≤ ε / normA ^ 2
 aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
 aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
 ⊢ ‖x - y‖ * normA ^ 2 ≤ ε,
 case a0
 n m : ℕ+
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 hA : ¬A = 0
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 normA : ℝ := ‖(toEuclideanLin ≪≫ₗ LinearMap.toContinuousLinearMap) A‖
 norm_mul : ∀ (x : EuclideanSpace ℝ (Fin ↑n)), ‖A *ᵥ x‖ ≤ normA * ‖x‖
 normApos : 0 < normA
 y : EuclideanSpace ℝ (Fin ↑n)
 ydist : ‖x - y‖ ≤ ε / normA ^ 2
 aux1 : ((fun x_1 => y x_1 - x x_1) ⬝ᵥ fun x_1 => ((Aᵀ * A) *ᵥ x) x_1) = (Aᵀ * A) *ᵥ x ⬝ᵥ (y - x)
 aux2 : ∀ (u v : Fin ↑m → ℝ), u ⬝ᵥ u + (v ⬝ᵥ v - v ⬝ᵥ u * 2) = (u - v) ⬝ᵥ (u - v)
 ⊢ 0 ≤ ‖x - y‖]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_11 {n m : ℕ+} {b : Fin ↑m → ℝ} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ}
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) (y : EuclideanSpace ℝ (Fin ↑n)) (a : ‖x - y‖ ≤ ε)
  (h_original_goal : ‖b ⬝ᵥ A *ᵥ y - b ⬝ᵥ A *ᵥ x - inner (Aᵀ *ᵥ b) (y - x)‖ ≤ ε * ‖x - y‖) :
  |Aᵀ *ᵥ b ⬝ᵥ y - Aᵀ *ᵥ b ⬝ᵥ x -
        ((WithLp.equiv 2 (Fin ↑n → ℝ)) y ⬝ᵥ (WithLp.equiv 2 (Fin ↑n → ℝ)) (Aᵀ *ᵥ b) -
          (WithLp.equiv 2 (Fin ↑n → ℝ)) x ⬝ᵥ (WithLp.equiv 2 (Fin ↑n → ℝ)) (Aᵀ *ᵥ b))| ≤
    ε * ‖x - y‖ := sorry

Tactic state before:
case right
n m : ℕ+
b : Fin ↑m → ℝ
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
y : EuclideanSpace ℝ (Fin ↑n)
a✝ : ‖x - y‖ ≤ ε
⊢ ‖b ⬝ᵥ A *ᵥ y - b ⬝ᵥ A *ᵥ x - inner (Aᵀ *ᵥ b) (y - x)‖ ≤ ε * ‖x - y‖

Tactic:
rw [dot_mul_eq_transpose_mul_dot, dot_mul_eq_transpose_mul_dot, ← dotProduct_sub]
    rw [EuclideanSpace.inner_eq_star_dotProduct]
    simp

Tactic state after:
[case right
 n m : ℕ+
 b : Fin ↑m → ℝ
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 x : EuclideanSpace ℝ (Fin ↑n)
 ε : ℝ
 εpos : ε > 0
 y : EuclideanSpace ℝ (Fin ↑n)
 a✝ : ‖x - y‖ ≤ ε
 ⊢ |Aᵀ *ᵥ b ⬝ᵥ y - Aᵀ *ᵥ b ⬝ᵥ x -
         ((WithLp.equiv 2 (Fin ↑n → ℝ)) y ⬝ᵥ (WithLp.equiv 2 (Fin ↑n → ℝ)) (Aᵀ *ᵥ b) -
           (WithLp.equiv 2 (Fin ↑n → ℝ)) x ⬝ᵥ (WithLp.equiv 2 (Fin ↑n → ℝ)) (Aᵀ *ᵥ b))| ≤
     ε * ‖x - y‖]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_12 {n m : ℕ+} {b : Fin ↑m → ℝ} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ}
  (x : EuclideanSpace ℝ (Fin ↑n)) (ε : ℝ) (εpos : ε > 0) (y : EuclideanSpace ℝ (Fin ↑n)) (a : ‖x - y‖ ≤ ε) :
  0 ≤ ε * ‖x - y‖ := sorry

Tactic state before:
case right
n m : ℕ+
b : Fin ↑m → ℝ
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
x : EuclideanSpace ℝ (Fin ↑n)
ε : ℝ
εpos : ε > 0
y : EuclideanSpace ℝ (Fin ↑n)
a✝ : ‖x - y‖ ≤ ε
⊢ 0 ≤ ε * ‖x - y‖

Tactic:
apply mul_nonneg
    linarith [εpos]
    apply norm_nonneg

Tactic state after:
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_13 {n m : ℕ+} {b : Fin ↑m → ℝ} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ}
  (x : EuclideanSpace ℝ (Fin ↑n)) :
  let f := fun x => 1 / 2 * A *ᵥ x ⬝ᵥ A *ᵥ x;
  let f' := fun x => Aᵀ *ᵥ A *ᵥ x;
  HasGradientAt f (f' x) x →
    let h := fun x => b ⬝ᵥ A *ᵥ x;
    let h' := fun x => Aᵀ *ᵥ b;
    HasGradientAt h (h' x) x →
      ∀ (z : EuclideanSpace ℝ (Fin ↑n)),
        2⁻¹ * (A *ᵥ z ⬝ᵥ A *ᵥ z - b ⬝ᵥ A *ᵥ z - (A *ᵥ z ⬝ᵥ b - b ⬝ᵥ b)) =
          2⁻¹ * A *ᵥ z ⬝ᵥ A *ᵥ z - b ⬝ᵥ A *ᵥ z + 2⁻¹ * b ⬝ᵥ b := sorry

Tactic state before:
case h
n m : ℕ+
b : Fin ↑m → ℝ
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
x : EuclideanSpace ℝ (Fin ↑n)
f : EuclideanSpace ℝ (Fin ↑n) → ℝ := fun x => 1 / 2 * A *ᵥ x ⬝ᵥ A *ᵥ x
f' : EuclideanSpace ℝ (Fin ↑n) → Fin ↑n → ℝ := fun x => Aᵀ *ᵥ A *ᵥ x
fgradient : HasGradientAt f (f' x) x
h : EuclideanSpace ℝ (Fin ↑n) → ℝ := fun x => b ⬝ᵥ A *ᵥ x
h' : EuclideanSpace ℝ (Fin ↑n) → Fin ↑n → ℝ := fun x => Aᵀ *ᵥ b
hgradient : HasGradientAt h (h' x) x
φ : EuclideanSpace ℝ (Fin ↑n) → ℝ := fun x => 1 / 2 * ‖A *ᵥ x - b‖ ^ 2
φ' : EuclideanSpace ℝ (Fin ↑n) → Fin ↑n → ℝ := fun x => Aᵀ *ᵥ (A *ᵥ x - b)
z : EuclideanSpace ℝ (Fin ↑n)
⊢ 2⁻¹ * (A *ᵥ z ⬝ᵥ A *ᵥ z - b ⬝ᵥ A *ᵥ z - (A *ᵥ z ⬝ᵥ b - b ⬝ᵥ b)) = 2⁻¹ * A *ᵥ z ⬝ᵥ A *ᵥ z - b ⬝ᵥ A *ᵥ z + 2⁻¹ * b ⬝ᵥ b

Tactic:
rw [← sub_add, dotProduct_comm _ b, sub_sub, ← two_mul, mul_add, mul_sub, ← mul_assoc]
    rw [inv_mul_cancel₀, one_mul]
    simp

Tactic state after:
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_14 {n m : ℕ+} {b : Fin ↑m → ℝ} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ}
  (x : EuclideanSpace ℝ (Fin ↑n)) :
  let f := fun x => 1 / 2 * A *ᵥ x ⬝ᵥ A *ᵥ x;
  let f' := fun x => Aᵀ *ᵥ A *ᵥ x;
  HasGradientAt f (f' x) x →
    let h := fun x => b ⬝ᵥ A *ᵥ x;
    let h' := fun x => Aᵀ *ᵥ b;
    HasGradientAt h (h' x) x →
      let φ := fun x => 1 / 2 * ‖A *ᵥ x - b‖ ^ 2;
      let φ' := fun x => Aᵀ *ᵥ (A *ᵥ x - b);
      (φ = fun x => f x - h x + 1 / 2 * b ⬝ᵥ b) → (φ' = fun x => f' x - h' x) → HasGradientAt φ (φ' x) x := sorry

Tactic state before:
n m : ℕ+
b : Fin ↑m → ℝ
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
x : EuclideanSpace ℝ (Fin ↑n)
f : EuclideanSpace ℝ (Fin ↑n) → ℝ := fun x => 1 / 2 * A *ᵥ x ⬝ᵥ A *ᵥ x
f' : EuclideanSpace ℝ (Fin ↑n) → Fin ↑n → ℝ := fun x => Aᵀ *ᵥ A *ᵥ x
fgradient : HasGradientAt f (f' x) x
h : EuclideanSpace ℝ (Fin ↑n) → ℝ := fun x => b ⬝ᵥ A *ᵥ x
h' : EuclideanSpace ℝ (Fin ↑n) → Fin ↑n → ℝ := fun x => Aᵀ *ᵥ b
hgradient : HasGradientAt h (h' x) x
φ : EuclideanSpace ℝ (Fin ↑n) → ℝ := fun x => 1 / 2 * ‖A *ᵥ x - b‖ ^ 2
φ' : EuclideanSpace ℝ (Fin ↑n) → Fin ↑n → ℝ := fun x => Aᵀ *ᵥ (A *ᵥ x - b)
φeq : φ = fun x => f x - h x + 1 / 2 * b ⬝ᵥ b
φ'eq : φ' = fun x => f' x - h' x
⊢ HasGradientAt φ (φ' x) x

Tactic:
rw [φeq, φ'eq]
    apply HasGradientAt.add_const
    apply HasGradientAt.sub fgradient hgradient

Tactic state after:
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_15 {n m : ℕ+} {b : Fin ↑m → ℝ} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ}
  (h_original_goal : ConvexOn ℝ Set.univ fun x => 1 / 2 * ‖A *ᵥ x - b‖ ^ 2) (x : EuclideanSpace ℝ (Fin ↑n)) :
  x ∈ Set.univ → ∀ y ∈ Set.univ, inner (Aᵀ *ᵥ (A *ᵥ x - b) - Aᵀ *ᵥ (A *ᵥ y - b)) (x - y) ≥ 0 := sorry

Tactic state before:
n m : ℕ+
b : Fin ↑m → ℝ
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
⊢ ConvexOn ℝ Set.univ fun x => 1 / 2 * ‖A *ᵥ x - b‖ ^ 2

Tactic:
apply monotone_gradient_convex'
    apply convex_univ
    exact (fun x _ => affine_sq_gradient x)

Tactic state after:
[case mono
 n m : ℕ+
 b : Fin ↑m → ℝ
 A : Matrix (Fin ↑m) (Fin ↑n) ℝ
 ⊢ ∀ x ∈ Set.univ, ∀ y ∈ Set.univ, inner (Aᵀ *ᵥ (A *ᵥ x - b) - Aᵀ *ᵥ (A *ᵥ y - b)) (x - y) ≥ 0]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_16 {n m : ℕ+} {b : Fin ↑m → ℝ} {A : Matrix (Fin ↑m) (Fin ↑n) ℝ}
  (x : EuclideanSpace ℝ (Fin ↑n)) (a : x ∈ Set.univ) (y : EuclideanSpace ℝ (Fin ↑n)) (a_1 : y ∈ Set.univ) :
  inner (Aᵀ *ᵥ (A *ᵥ x - b) - Aᵀ *ᵥ (A *ᵥ y - b)) (x - y) ≥ 0 := sorry

Tactic state before:
case mono
n m : ℕ+
b : Fin ↑m → ℝ
A : Matrix (Fin ↑m) (Fin ↑n) ℝ
x : EuclideanSpace ℝ (Fin ↑n)
a✝¹ : x ∈ Set.univ
y : EuclideanSpace ℝ (Fin ↑n)
a✝ : y ∈ Set.univ
⊢ inner (Aᵀ *ᵥ (A *ᵥ x - b) - Aᵀ *ᵥ (A *ᵥ y - b)) (x - y) ≥ 0

Tactic:
rw [Matrix.mulVec_sub, Matrix.mulVec_sub, ← sub_add, sub_add_eq_add_sub, sub_add_cancel, ←
  Matrix.mulVec_sub, real_inner_eq_dot]
    rw [← dot_mul_eq_transpose_mul_dot, ← Matrix.mulVec_sub, ← norm2eq_dot]
    apply sq_nonneg

Tactic state after:
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_17 {n : ℕ+} (h_original_goal : ConvexOn ℝ Set.univ fun x => ∑ i, ‖x i‖)
  ⦃x : EuclideanSpace ℝ (Fin ↑n)⦄ :
  x ∈ Set.univ →
    ∀ ⦃y : EuclideanSpace ℝ (Fin ↑n)⦄,
      y ∈ Set.univ →
        ∀ ⦃a b : ℝ⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → ∑ i, ‖(a • x + b • y) i‖ ≤ a • ∑ i, ‖x i‖ + b • ∑ i, ‖y i‖ := sorry

Tactic state before:
n : ℕ+
⊢ ConvexOn ℝ Set.univ fun x => ∑ i, ‖x i‖

Tactic:
rw [ConvexOn]
    constructor
    use convex_univ

Tactic state after:
[case right
 n : ℕ+
 ⊢ ∀ ⦃x : EuclideanSpace ℝ (Fin ↑n)⦄,
     x ∈ Set.univ →
       ∀ ⦃y : EuclideanSpace ℝ (Fin ↑n)⦄,
         y ∈ Set.univ →
           ∀ ⦃a b : ℝ⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → ∑ i, ‖(a • x + b • y) i‖ ≤ a • ∑ i, ‖x i‖ + b • ∑ i, ‖y i‖]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_18 (x : ℝ) (xpos : x ≤ 0) (xzero : x ≠ 0) (xneg : x < 0)
  (h_original_goal : x.sign * |x| = x) : x ≤ 0 := sorry

Tactic state before:
case neg
x : ℝ
xpos : x ≤ 0
xzero : x ≠ 0
xneg : x < 0
⊢ x.sign * |x| = x

Tactic:
rw [Real.sign_of_neg xneg]
    simp
    rw [neg_eq_iff_eq_neg, abs_eq_neg_self]

Tactic state after:
[case neg
 x : ℝ
 xpos : x ≤ 0
 xzero : x ≠ 0
 xneg : x < 0
 ⊢ x ≤ 0]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_19 {n : ℕ+} {t μ : ℝ} {h : EuclideanSpace ℝ (Fin ↑n) → ℝ}
  (lasso : h = fun y => μ • ∑ i, ‖y i‖) (x xm : EuclideanSpace ℝ (Fin ↑n)) (tpos : 0 < t) (μpos : 0 < μ)
  (minpoint : ∀ (i : Fin ↑n), xm i = sign (x i) * ((|x i| - t * μ) ⊔ 0)) :
  let g := (t * μ) • fun x => ∑ i, ‖x i‖;
  g = t • h → prox_prop (t • h) x xm → prox_prop ((t * μ) • fun x => ∑ i, ‖x i‖) x xm := sorry

Tactic state before:
n : ℕ+
t μ : ℝ
h : EuclideanSpace ℝ (Fin ↑n) → ℝ
lasso : h = fun y => μ • ∑ i, ‖y i‖
x xm : EuclideanSpace ℝ (Fin ↑n)
tpos : 0 < t
μpos : 0 < μ
minpoint : ∀ (i : Fin ↑n), xm i = sign (x i) * ((|x i| - t * μ) ⊔ 0)
g : EuclideanSpace ℝ (Fin ↑n) → ℝ := (t * μ) • fun x => ∑ i, ‖x i‖
geqth : g = t • h
⊢ prox_prop (t • h) x xm

Tactic:
rw [← geqth]
    show prox_prop ((t * μ) • (fun (x : EuclideanSpace ℝ (Fin n)) => ‖x‖₁)) x xm
    have tμpos : 0 < t * μ := by to_theorem apply mul_pos;linarith [tpos];linarith [μpos]

Tactic state after:
[n : ℕ+
 t μ : ℝ
 h : EuclideanSpace ℝ (Fin ↑n) → ℝ
 lasso : h = fun y => μ • ∑ i, ‖y i‖
 x xm : EuclideanSpace ℝ (Fin ↑n)
 tpos : 0 < t
 μpos : 0 < μ
 minpoint : ∀ (i : Fin ↑n), xm i = sign (x i) * ((|x i| - t * μ) ⊔ 0)
 g : EuclideanSpace ℝ (Fin ↑n) → ℝ := (t * μ) • fun x => ∑ i, ‖x i‖
 geqth : g = t • h
 tμpos : 0 < t * μ
 ⊢ prox_prop ((t * μ) • fun x => ∑ i, ‖x i‖) x xm]
import Mathlib
import Optlib


open Set Real Matrix Finset

open Set Real Matrix Finset NNReal

theorem extracted_formal_statement_20 {n : ℕ+} {t μ : ℝ} {h : EuclideanSpace ℝ (Fin ↑n) → ℝ}
  (lasso : h = fun y => μ • ∑ i, ‖y i‖) (x xm : EuclideanSpace ℝ (Fin ↑n)) (tpos : 0 < t) (μpos : 0 < μ)
  (minpoint : ∀ (i : Fin ↑n), xm i = sign (x i) * ((|x i| - t * μ) ⊔ 0)) :
  let g := (t * μ) • fun x => ∑ i, ‖x i‖;
  g = t • h → 0 < t * μ := sorry

Tactic state before:
n : ℕ+
t μ : ℝ
h : EuclideanSpace ℝ (Fin ↑n) → ℝ
lasso : h = fun y => μ • ∑ i, ‖y i‖
x xm : EuclideanSpace ℝ (Fin ↑n)
tpos : 0 < t
μpos : 0 < μ
minpoint : ∀ (i : Fin ↑n), xm i = sign (x i) * ((|x i| - t * μ) ⊔ 0)
g : EuclideanSpace ℝ (Fin ↑n) → ℝ := (t * μ) • fun x => ∑ i, ‖x i‖
geqth : g = t • h
⊢ 0 < t * μ

Tactic:
apply mul_pos
    linarith [tpos]
    linarith [μpos]

Tactic state after: