l3lab/ntp-mathlib huggingface dataset:
/-- If `E` is a strictly convex normed space and `f : α → E` is a function such that `‖f x‖ ≤ C`
a.e., then either this function is a.e. equal to its average value, or the norm of its integral is
strictly less than `(μ univ).toReal * C`. -/
theorem ae_eq_const_or_norm_integral_lt_of_norm_le_const [StrictConvexSpace ℝ E] [IsFiniteMeasure μ]
    (h_le : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) :
    f =ᵐ[μ] const α (⨍ x, f x ∂μ) ∨ ‖∫ x, f x ∂μ‖ < (μ univ).toReal * C := by
  rcases eq_or_ne μ 0 with h₀ | h₀; · left; simp [h₀, EventuallyEq]
  have hμ : 0 < (μ univ).toReal := by
    

Proof state:
α : Type u_1
E : Type u_2
F : Type u_3
m0 : MeasurableSpace α
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℝ E
inst✝⁵ : CompleteSpace E
inst✝⁴ : NormedAddCommGroup F
inst✝³ : NormedSpace ℝ F
inst✝² : CompleteSpace F
μ : Measure α
s : Set E
t : Set α
f : α → E
g : E → ℝ
C : ℝ
inst✝¹ : StrictConvexSpace ℝ E
inst✝ : IsFiniteMeasure μ
h_le : ∀ᵐ (x : α) ∂μ, ‖f x‖ ≤ C
h₀ : μ ≠ 0
⊢ 0 < ENNReal.toReal (↑↑μ univ)

Next tactic:
simp [ENNReal.toReal_pos_iff, pos_iff_ne_zero, h₀, measure_lt_top]
/-- If `E` is a strictly convex normed space and `f : α → E` is a function such that `‖f x‖ ≤ C`
a.e., then either this function is a.e. equal to its average value, or the norm of its integral is
strictly less than `(μ univ).toReal * C`. -/
theorem ae_eq_const_or_norm_integral_lt_of_norm_le_const [StrictConvexSpace ℝ E] [IsFiniteMeasure μ]
    (h_le : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) :
    f =ᵐ[μ] const α (⨍ x, f x ∂μ) ∨ ‖∫ x, f x ∂μ‖ < (μ univ).toReal * C := by
  rcases eq_or_ne μ 0 with h₀ | h₀; · left; simp [h₀, EventuallyEq]
  have hμ : 0 < (μ univ).toReal := by
    simp [ENNReal.toReal_pos_iff, pos_iff_ne_zero, h₀, measure_lt_top]
  

Proof state:
case inr
α : Type u_1
E : Type u_2
F : Type u_3
m0 : MeasurableSpace α
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℝ E
inst✝⁵ : CompleteSpace E
inst✝⁴ : NormedAddCommGroup F
inst✝³ : NormedSpace ℝ F
inst✝² : CompleteSpace F
μ : Measure α
s : Set E
t : Set α
f : α → E
g : E → ℝ
C : ℝ
inst✝¹ : StrictConvexSpace ℝ E
inst✝ : IsFiniteMeasure μ
h_le : ∀ᵐ (x : α) ∂μ, ‖f x‖ ≤ C
h₀ : μ ≠ 0
hμ : 0 < ENNReal.toReal (↑↑μ univ)
⊢ f =ᶠ[ae μ] const α (⨍ (x : α), f x ∂μ) ∨ ‖∫ (x : α), f x ∂μ‖ < ENNReal.toReal (↑↑μ univ) * C

Next tactic:
refine' (ae_eq_const_or_norm_average_lt_of_norm_le_const h_le).imp_right fun H => _
/-- If `E` is a strictly convex normed space and `f : α → E` is a function such that `‖f x‖ ≤ C`
a.e., then either this function is a.e. equal to its average value, or the norm of its integral is
strictly less than `(μ univ).toReal * C`. -/
theorem ae_eq_const_or_norm_integral_lt_of_norm_le_const [StrictConvexSpace ℝ E] [IsFiniteMeasure μ]
    (h_le : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) :
    f =ᵐ[μ] const α (⨍ x, f x ∂μ) ∨ ‖∫ x, f x ∂μ‖ < (μ univ).toReal * C := by
  rcases eq_or_ne μ 0 with h₀ | h₀; · left; simp [h₀, EventuallyEq]
  have hμ : 0 < (μ univ).toReal := by
    simp [ENNReal.toReal_pos_iff, pos_iff_ne_zero, h₀, measure_lt_top]
  refine' (ae_eq_const_or_norm_average_lt_of_norm_le_const h_le).imp_right fun H => _
  

Proof state:
case inr
α : Type u_1
E : Type u_2
F : Type u_3
m0 : MeasurableSpace α
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℝ E
inst✝⁵ : CompleteSpace E
inst✝⁴ : NormedAddCommGroup F
inst✝³ : NormedSpace ℝ F
inst✝² : CompleteSpace F
μ : Measure α
s : Set E
t : Set α
f : α → E
g : E → ℝ
C : ℝ
inst✝¹ : StrictConvexSpace ℝ E
inst✝ : IsFiniteMeasure μ
h_le : ∀ᵐ (x : α) ∂μ, ‖f x‖ ≤ C
h₀ : μ ≠ 0
hμ : 0 < ENNReal.toReal (↑↑μ univ)
H : ‖⨍ (x : α), f x ∂μ‖ < C
⊢ ‖∫ (x : α), f x ∂μ‖ < ENNReal.toReal (↑↑μ univ) * C

Next tactic:
rwa [average_eq, norm_smul, norm_inv, Real.norm_eq_abs, abs_of_pos hμ, ← div_eq_inv_mul,
    div_lt_iff' hμ] at H
/-- If `E` is a strictly convex normed space and `f : α → E` is a function such that `‖f x‖ ≤ C`
a.e. on a set `t` of finite measure, then either this function is a.e. equal to its average value on
`t`, or the norm of its integral over `t` is strictly less than `(μ t).toReal * C`. -/
theorem ae_eq_const_or_norm_set_integral_lt_of_norm_le_const [StrictConvexSpace ℝ E] (ht : μ t ≠ ∞)
    (h_le : ∀ᵐ x ∂μ.restrict t, ‖f x‖ ≤ C) :
    f =ᵐ[μ.restrict t] const α (⨍ x in t, f x ∂μ) ∨ ‖∫ x in t, f x ∂μ‖ < (μ t).toReal * C := by
  

Proof state:
α : Type u_1
E : Type u_2
F : Type u_3
m0 : MeasurableSpace α
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℝ E
inst✝⁴ : CompleteSpace E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace ℝ F
inst✝¹ : CompleteSpace F
μ : Measure α
s : Set E
t : Set α
f : α → E
g : E → ℝ
C : ℝ
inst✝ : StrictConvexSpace ℝ E
ht : ↑↑μ t ≠ ⊤
h_le : ∀ᵐ (x : α) ∂Measure.restrict μ t, ‖f x‖ ≤ C
⊢ f =ᶠ[ae (Measure.restrict μ t)] const α (⨍ (x : α) in t, f x ∂μ) ∨
    ‖∫ (x : α) in t, f x ∂μ‖ < ENNReal.toReal (↑↑μ t) * C

Next tactic:
haveI := Fact.mk ht.lt_top
/-- If `E` is a strictly convex normed space and `f : α → E` is a function such that `‖f x‖ ≤ C`
a.e. on a set `t` of finite measure, then either this function is a.e. equal to its average value on
`t`, or the norm of its integral over `t` is strictly less than `(μ t).toReal * C`. -/
theorem ae_eq_const_or_norm_set_integral_lt_of_norm_le_const [StrictConvexSpace ℝ E] (ht : μ t ≠ ∞)
    (h_le : ∀ᵐ x ∂μ.restrict t, ‖f x‖ ≤ C) :
    f =ᵐ[μ.restrict t] const α (⨍ x in t, f x ∂μ) ∨ ‖∫ x in t, f x ∂μ‖ < (μ t).toReal * C := by
  haveI := Fact.mk ht.lt_top
  

Proof state:
α : Type u_1
E : Type u_2
F : Type u_3
m0 : MeasurableSpace α
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℝ E
inst✝⁴ : CompleteSpace E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace ℝ F
inst✝¹ : CompleteSpace F
μ : Measure α
s : Set E
t : Set α
f : α → E
g : E → ℝ
C : ℝ
inst✝ : StrictConvexSpace ℝ E
ht : ↑↑μ t ≠ ⊤
h_le : ∀ᵐ (x : α) ∂Measure.restrict μ t, ‖f x‖ ≤ C
this : Fact (↑↑μ t < ⊤)
⊢ f =ᶠ[ae (Measure.restrict μ t)] const α (⨍ (x : α) in t, f x ∂μ) ∨
    ‖∫ (x : α) in t, f x ∂μ‖ < ENNReal.toReal (↑↑μ t) * C

Next tactic:
rw [← restrict_apply_univ]
/-- If `E` is a strictly convex normed space and `f : α → E` is a function such that `‖f x‖ ≤ C`
a.e. on a set `t` of finite measure, then either this function is a.e. equal to its average value on
`t`, or the norm of its integral over `t` is strictly less than `(μ t).toReal * C`. -/
theorem ae_eq_const_or_norm_set_integral_lt_of_norm_le_const [StrictConvexSpace ℝ E] (ht : μ t ≠ ∞)
    (h_le : ∀ᵐ x ∂μ.restrict t, ‖f x‖ ≤ C) :
    f =ᵐ[μ.restrict t] const α (⨍ x in t, f x ∂μ) ∨ ‖∫ x in t, f x ∂μ‖ < (μ t).toReal * C := by
  haveI := Fact.mk ht.lt_top
  rw [← restrict_apply_univ]
  

Proof state:
α : Type u_1
E : Type u_2
F : Type u_3
m0 : MeasurableSpace α
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℝ E
inst✝⁴ : CompleteSpace E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace ℝ F
inst✝¹ : CompleteSpace F
μ : Measure α
s : Set E
t : Set α
f : α → E
g : E → ℝ
C : ℝ
inst✝ : StrictConvexSpace ℝ E
ht : ↑↑μ t ≠ ⊤
h_le : ∀ᵐ (x : α) ∂Measure.restrict μ t, ‖f x‖ ≤ C
this : Fact (↑↑μ t < ⊤)
⊢ f =ᶠ[ae (Measure.restrict μ t)] const α (⨍ (x : α) in t, f x ∂μ) ∨
    ‖∫ (x : α) in t, f x ∂μ‖ < ENNReal.toReal (↑↑(Measure.restrict μ t) univ) * C

Next tactic:
exact ae_eq_const_or_norm_integral_lt_of_norm_le_const h_le
theorem Finite.of_equiv (α : Sort*) [h : Finite α] (f : α ≃ β) : Finite β := by
  

Proof state:
α✝ : Sort u_1
β : Sort u_2
α : Sort u_3
h : Finite α
f : α ≃ β
⊢ Finite β

Next tactic:
cases' h with n e
theorem Finite.of_equiv (α : Sort*) [h : Finite α] (f : α ≃ β) : Finite β := by
  cases' h with n e
  

Proof state:
case intro
α✝ : Sort u_1
β : Sort u_2
α : Sort u_3
f : α ≃ β
n : ℕ
e : α ≃ Fin n
⊢ Finite β

Next tactic:
exact Finite.intro (f.symm.trans e)
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  

Proof state:
n : ℕ
⊢ pair (unpair n).1 (unpair n).2 = n

Next tactic:
dsimp only [unpair]
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; 

Proof state:
n : ℕ
⊢ pair
      (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n) else (sqrt n, n - sqrt n * sqrt n - sqrt n)).1
      (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n)
        else (sqrt n, n - sqrt n * sqrt n - sqrt n)).2 =
    n

Next tactic:
let s := sqrt n
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; let s := sqrt n
  

Proof state:
n : ℕ
s : ℕ := sqrt n
⊢ pair
      (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n) else (sqrt n, n - sqrt n * sqrt n - sqrt n)).1
      (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n)
        else (sqrt n, n - sqrt n * sqrt n - sqrt n)).2 =
    n

Next tactic:
have sm : s * s + (n - s * s) = n := add_tsub_cancel_of_le (sqrt_le _)
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; let s := sqrt n
  have sm : s * s + (n - s * s) = n := add_tsub_cancel_of_le (sqrt_le _)
  

Proof state:
n : ℕ
s : ℕ := sqrt n
sm : s * s + (n - s * s) = n
⊢ pair
      (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n) else (sqrt n, n - sqrt n * sqrt n - sqrt n)).1
      (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n)
        else (sqrt n, n - sqrt n * sqrt n - sqrt n)).2 =
    n

Next tactic:
split_ifs with h
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; let s := sqrt n
  have sm : s * s + (n - s * s) = n := add_tsub_cancel_of_le (sqrt_le _)
  split_ifs with h
  · 

Proof state:
case pos
n : ℕ
s : ℕ := sqrt n
sm : s * s + (n - s * s) = n
h : n - sqrt n * sqrt n < sqrt n
⊢ pair (n - sqrt n * sqrt n, sqrt n).1 (n - sqrt n * sqrt n, sqrt n).2 = n

Next tactic:
simp [pair, h, sm]
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; let s := sqrt n
  have sm : s * s + (n - s * s) = n := add_tsub_cancel_of_le (sqrt_le _)
  split_ifs with h
  · simp [pair, h, sm]
  · 

Proof state:
case neg
n : ℕ
s : ℕ := sqrt n
sm : s * s + (n - s * s) = n
h : ¬n - sqrt n * sqrt n < sqrt n
⊢ pair (sqrt n, n - sqrt n * sqrt n - sqrt n).1 (sqrt n, n - sqrt n * sqrt n - sqrt n).2 = n

Next tactic:
have hl : n - s * s - s ≤ s :=
      tsub_le_iff_left.mpr (tsub_le_iff_left.mpr <| by rw [← add_assoc]; apply sqrt_le_add)
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; let s := sqrt n
  have sm : s * s + (n - s * s) = n := add_tsub_cancel_of_le (sqrt_le _)
  split_ifs with h
  · simp [pair, h, sm]
  · have hl : n - s * s - s ≤ s :=
      tsub_le_iff_left.mpr (tsub_le_iff_left.mpr <| by 

Proof state:
n : ℕ
s : ℕ := sqrt n
sm : s * s + (n - s * s) = n
h : ¬n - sqrt n * sqrt n < sqrt n
⊢ n ≤ s * s + (s + s)

Next tactic:
rw [← add_assoc]
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; let s := sqrt n
  have sm : s * s + (n - s * s) = n := add_tsub_cancel_of_le (sqrt_le _)
  split_ifs with h
  · simp [pair, h, sm]
  · have hl : n - s * s - s ≤ s :=
      tsub_le_iff_left.mpr (tsub_le_iff_left.mpr <| by rw [← add_assoc]; 

Proof state:
n : ℕ
s : ℕ := sqrt n
sm : s * s + (n - s * s) = n
h : ¬n - sqrt n * sqrt n < sqrt n
⊢ n ≤ s * s + s + s

Next tactic:
apply sqrt_le_add
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
  dsimp only [unpair]; let s := sqrt n
  have sm : s * s + (n - s * s) = n := add_tsub_cancel_of_le (sqrt_le _)
  split_ifs with h
  · simp [pair, h, sm]
  · have hl : n - s * s - s ≤ s :=
      tsub_le_iff_left.mpr (tsub_le_iff_left.mpr <| by rw [← add_assoc]; apply sqrt_le_add)
    

Proof state:
case neg
n : ℕ
s : ℕ := sqrt n
sm : s * s + (n - s * s) = n
h : ¬n - sqrt n * sqrt n < sqrt n
hl : n - s * s - s ≤ s
⊢ pair (sqrt n, n - sqrt n * sqrt n - sqrt n).1 (sqrt n, n - sqrt n * sqrt n - sqrt n).2 = n

Next tactic:
simp [pair, hl.not_lt, add_assoc, add_tsub_cancel_of_le (le_of_not_gt h), sm]
theorem pair_unpair' {n a b} (H : unpair n = (a, b)) : pair a b = n := by
  

Proof state:
n a b : ℕ
H : unpair n = (a, b)
⊢ pair a b = n

Next tactic:
simpa [H] using pair_unpair n
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  

Proof state:
a b : ℕ
⊢ unpair (pair a b) = (a, b)

Next tactic:
dsimp only [pair]
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; 

Proof state:
a b : ℕ
⊢ unpair (if a < b then b * b + a else a * a + a + b) = (a, b)

Next tactic:
split_ifs with h
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · 

Proof state:
case pos
a b : ℕ
h : a < b
⊢ unpair (b * b + a) = (a, b)

Next tactic:
show unpair (b * b + a) = (a, b)
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · show unpair (b * b + a) = (a, b)
    

Proof state:
case pos
a b : ℕ
h : a < b
⊢ unpair (b * b + a) = (a, b)

Next tactic:
have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · show unpair (b * b + a) = (a, b)
    have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
    

Proof state:
case pos
a b : ℕ
h : a < b
be : sqrt (b * b + a) = b
⊢ unpair (b * b + a) = (a, b)

Next tactic:
simp [unpair, be, add_tsub_cancel_right, h]
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · show unpair (b * b + a) = (a, b)
    have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
    simp [unpair, be, add_tsub_cancel_right, h]
  · 

Proof state:
case neg
a b : ℕ
h : ¬a < b
⊢ unpair (a * a + a + b) = (a, b)

Next tactic:
show unpair (a * a + a + b) = (a, b)
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · show unpair (b * b + a) = (a, b)
    have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
    simp [unpair, be, add_tsub_cancel_right, h]
  · show unpair (a * a + a + b) = (a, b)
    

Proof state:
case neg
a b : ℕ
h : ¬a < b
⊢ unpair (a * a + a + b) = (a, b)

Next tactic:
have ae : sqrt (a * a + (a + b)) = a := by
      rw [sqrt_add_eq]
      exact add_le_add_left (le_of_not_gt h) _
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · show unpair (b * b + a) = (a, b)
    have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
    simp [unpair, be, add_tsub_cancel_right, h]
  · show unpair (a * a + a + b) = (a, b)
    have ae : sqrt (a * a + (a + b)) = a := by
      

Proof state:
a b : ℕ
h : ¬a < b
⊢ sqrt (a * a + (a + b)) = a

Next tactic:
rw [sqrt_add_eq]
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · show unpair (b * b + a) = (a, b)
    have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
    simp [unpair, be, add_tsub_cancel_right, h]
  · show unpair (a * a + a + b) = (a, b)
    have ae : sqrt (a * a + (a + b)) = a := by
      rw [sqrt_add_eq]
      

Proof state:
case h
a b : ℕ
h : ¬a < b
⊢ a + b ≤ a + a

Next tactic:
exact add_le_add_left (le_of_not_gt h) _
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
  dsimp only [pair]; split_ifs with h
  · show unpair (b * b + a) = (a, b)
    have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
    simp [unpair, be, add_tsub_cancel_right, h]
  · show unpair (a * a + a + b) = (a, b)
    have ae : sqrt (a * a + (a + b)) = a := by
      rw [sqrt_add_eq]
      exact add_le_add_left (le_of_not_gt h) _
    

Proof state:
case neg
a b : ℕ
h : ¬a < b
ae : sqrt (a * a + (a + b)) = a
⊢ unpair (a * a + a + b) = (a, b)

Next tactic:
simp [unpair, ae, Nat.not_lt_zero, add_assoc]
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  

Proof state:
n : ℕ
n1 : 1 ≤ n
⊢ (unpair n).1 < n

Next tactic:
let s := sqrt n
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  

Proof state:
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
⊢ (unpair n).1 < n

Next tactic:
simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
  

Proof state:
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
⊢ (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n) else (sqrt n, n - sqrt n * sqrt n - sqrt n)).1 < n

Next tactic:
by_cases h : n - s * s < s
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
  by_cases h : n - s * s < s <;> 

Proof state:
case pos
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
h : n - s * s < s
⊢ (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n) else (sqrt n, n - sqrt n * sqrt n - sqrt n)).1 < n

Next tactic:
simp [h]
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
  by_cases h : n - s * s < s <;> 

Proof state:
case neg
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
h : ¬n - s * s < s
⊢ (if n - sqrt n * sqrt n < sqrt n then (n - sqrt n * sqrt n, sqrt n) else (sqrt n, n - sqrt n * sqrt n - sqrt n)).1 < n

Next tactic:
simp [h]
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
  by_cases h : n - s * s < s <;> simp [h]
  · 

Proof state:
case pos
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
h : n - s * s < s
⊢ n - sqrt n * sqrt n < n

Next tactic:
exact lt_of_lt_of_le h (sqrt_le_self _)
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
  by_cases h : n - s * s < s <;> simp [h]
  · exact lt_of_lt_of_le h (sqrt_le_self _)
  · 

Proof state:
case neg
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
h : ¬n - s * s < s
⊢ sqrt n < n

Next tactic:
simp at h
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
  by_cases h : n - s * s < s <;> simp [h]
  · exact lt_of_lt_of_le h (sqrt_le_self _)
  · simp at h
    

Proof state:
case neg
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
h : sqrt n ≤ n - sqrt n * sqrt n
⊢ sqrt n < n

Next tactic:
have s0 : 0 < s := sqrt_pos.2 n1
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
  let s := sqrt n
  simp only [unpair, ge_iff_le, tsub_le_iff_right, gt_iff_lt]
  by_cases h : n - s * s < s <;> simp [h]
  · exact lt_of_lt_of_le h (sqrt_le_self _)
  · simp at h
    have s0 : 0 < s := sqrt_pos.2 n1
    

Proof state:
case neg
n : ℕ
n1 : 1 ≤ n
s : ℕ := sqrt n
h : sqrt n ≤ n - sqrt n * sqrt n
s0 : 0 < s
⊢ sqrt n < n

Next tactic:
exact lt_of_le_of_lt h (tsub_lt_self n1 (mul_pos s0 s0))
@[simp]
theorem unpair_zero : unpair 0 = 0 := by
  

Proof state:
⊢ unpair 0 = 0

Next tactic:
rw [unpair]
@[simp]
theorem unpair_zero : unpair 0 = 0 := by
  rw [unpair]
  

Proof state:
⊢ (let s := sqrt 0;
    if 0 - s * s < s then (0 - s * s, s) else (s, 0 - s * s - s)) =
    0

Next tactic:
simp
theorem unpair_left_le : ∀ n : ℕ, (unpair n).1 ≤ n
  | 0 => by 

Proof state:
⊢ (unpair 0).1 ≤ 0

Next tactic:
simp
theorem left_le_pair (a b : ℕ) : a ≤ pair a b := by 

Proof state:
a b : ℕ
⊢ a ≤ pair a b

Next tactic:
simpa using unpair_left_le (pair a b)
theorem right_le_pair (a b : ℕ) : b ≤ pair a b := by
  

Proof state:
a b : ℕ
⊢ b ≤ pair a b

Next tactic:
by_cases h : a < b
theorem right_le_pair (a b : ℕ) : b ≤ pair a b := by
  by_cases h : a < b <;> 

Proof state:
case pos
a b : ℕ
h : a < b
⊢ b ≤ pair a b

Next tactic:
simp [pair, h]
theorem right_le_pair (a b : ℕ) : b ≤ pair a b := by
  by_cases h : a < b <;> 

Proof state:
case neg
a b : ℕ
h : ¬a < b
⊢ b ≤ pair a b

Next tactic:
simp [pair, h]
theorem right_le_pair (a b : ℕ) : b ≤ pair a b := by
  by_cases h : a < b <;> simp [pair, h]
  

Proof state:
case pos
a b : ℕ
h : a < b
⊢ b ≤ b * b + a

Next tactic:
exact le_trans (le_mul_self _) (Nat.le_add_right _ _)
theorem unpair_right_le (n : ℕ) : (unpair n).2 ≤ n := by
  

Proof state:
n : ℕ
⊢ (unpair n).2 ≤ n

Next tactic:
simpa using right_le_pair n.unpair.1 n.unpair.2
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  

Proof state:
a₁ a₂ b : ℕ
h : a₁ < a₂
⊢ pair a₁ b < pair a₂ b

Next tactic:
by_cases h₁ : a₁ < b
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> 

Proof state:
case pos
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
⊢ pair a₁ b < pair a₂ b

Next tactic:
simp [pair, h₁, add_assoc]
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> 

Proof state:
case neg
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : ¬a₁ < b
⊢ pair a₁ b < pair a₂ b

Next tactic:
simp [pair, h₁, add_assoc]
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · 

Proof state:
case pos
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
⊢ b * b + a₁ < if a₂ < b then b * b + a₂ else a₂ * a₂ + (a₂ + b)

Next tactic:
by_cases h₂ : a₂ < b
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · by_cases h₂ : a₂ < b <;> 

Proof state:
case pos
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
h₂ : a₂ < b
⊢ b * b + a₁ < if a₂ < b then b * b + a₂ else a₂ * a₂ + (a₂ + b)

Next tactic:
simp [pair, h₂, h]
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · by_cases h₂ : a₂ < b <;> 

Proof state:
case neg
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
h₂ : ¬a₂ < b
⊢ b * b + a₁ < if a₂ < b then b * b + a₂ else a₂ * a₂ + (a₂ + b)

Next tactic:
simp [pair, h₂, h]
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · by_cases h₂ : a₂ < b <;> simp [pair, h₂, h]
    

Proof state:
case neg
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
h₂ : ¬a₂ < b
⊢ b * b + a₁ < a₂ * a₂ + (a₂ + b)

Next tactic:
simp? at h₂ says simp only [not_lt] at h₂
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · by_cases h₂ : a₂ < b <;> simp [pair, h₂, h]
    simp? at h₂ says 

Proof state:
case neg
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
h₂ : ¬a₂ < b
⊢ b * b + a₁ < a₂ * a₂ + (a₂ + b)

Next tactic:
simp only [not_lt] at h₂
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · by_cases h₂ : a₂ < b <;> simp [pair, h₂, h]
    simp? at h₂ says simp only [not_lt] at h₂
    

Proof state:
case neg
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
h₂ : b ≤ a₂
⊢ b * b + a₁ < a₂ * a₂ + (a₂ + b)

Next tactic:
apply add_lt_add_of_le_of_lt
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · by_cases h₂ : a₂ < b <;> simp [pair, h₂, h]
    simp? at h₂ says simp only [not_lt] at h₂
    apply add_lt_add_of_le_of_lt
    

Proof state:
case neg.h₁
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
h₂ : b ≤ a₂
⊢ b * b ≤ a₂ * a₂
case neg.h₂ a₁ a₂ b : ℕ h : a₁ < a₂ h₁ : a₁ < b h₂ : b ≤ a₂ ⊢ a₁ < a₂ + b

Next tactic:
exact mul_self_le_mul_self h₂
theorem pair_lt_pair_left {a₁ a₂} (b) (h : a₁ < a₂) : pair a₁ b < pair a₂ b := by
  by_cases h₁ : a₁ < b <;> simp [pair, h₁, add_assoc]
  · by_cases h₂ : a₂ < b <;> simp [pair, h₂, h]
    simp? at h₂ says simp only [not_lt] at h₂
    apply add_lt_add_of_le_of_lt
    exact mul_self_le_mul_self h₂
    

Proof state:
case neg.h₂
a₁ a₂ b : ℕ
h : a₁ < a₂
h₁ : a₁ < b
h₂ : b ≤ a₂
⊢ a₁ < a₂ + b

Next tactic:
exact Nat.lt_add_right _ h