l3lab/ntp-mathlib huggingface dataset:
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  

Proof state:
n m : ℕ
p : Fin (n + 1)
i : Fin n
⊢ p < succAbove p i ↔ p ≤ castSucc i

Next tactic:
refine' Iff.intro _ _
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · 

Proof state:
case refine'_1
n m : ℕ
p : Fin (n + 1)
i : Fin n
⊢ p < succAbove p i → p ≤ castSucc i

Next tactic:
intro h
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · intro h
    

Proof state:
case refine'_1
n m : ℕ
p : Fin (n + 1)
i : Fin n
h : p < succAbove p i
⊢ p ≤ castSucc i

Next tactic:
cases' succAbove_lt_ge p i with H H
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · intro h
    cases' succAbove_lt_ge p i with H H
    · 

Proof state:
case refine'_1.inl
n m : ℕ
p : Fin (n + 1)
i : Fin n
h : p < succAbove p i
H : castSucc i < p
⊢ p ≤ castSucc i

Next tactic:
rw [succAbove_below _ _ H] at h
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · intro h
    cases' succAbove_lt_ge p i with H H
    · rw [succAbove_below _ _ H] at h
      

Proof state:
case refine'_1.inl
n m : ℕ
p : Fin (n + 1)
i : Fin n
h : p < castSucc i
H : castSucc i < p
⊢ p ≤ castSucc i

Next tactic:
exact le_of_lt h
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · intro h
    cases' succAbove_lt_ge p i with H H
    · rw [succAbove_below _ _ H] at h
      exact le_of_lt h
    · 

Proof state:
case refine'_1.inr
n m : ℕ
p : Fin (n + 1)
i : Fin n
h : p < succAbove p i
H : p ≤ castSucc i
⊢ p ≤ castSucc i

Next tactic:
exact H
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · intro h
    cases' succAbove_lt_ge p i with H H
    · rw [succAbove_below _ _ H] at h
      exact le_of_lt h
    · exact H
  · 

Proof state:
case refine'_2
n m : ℕ
p : Fin (n + 1)
i : Fin n
⊢ p ≤ castSucc i → p < succAbove p i

Next tactic:
intro h
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · intro h
    cases' succAbove_lt_ge p i with H H
    · rw [succAbove_below _ _ H] at h
      exact le_of_lt h
    · exact H
  · intro h
    

Proof state:
case refine'_2
n m : ℕ
p : Fin (n + 1)
i : Fin n
h : p ≤ castSucc i
⊢ p < succAbove p i

Next tactic:
rw [succAbove_above _ _ h]
/-- Embedding `i : Fin n` into `Fin (n + 1)` using a pivot `p` that is lesser
results in a value that is greater than `p`. -/
theorem lt_succAbove_iff (p : Fin (n + 1)) (i : Fin n) : p < p.succAbove i ↔ p ≤ castSucc i := by
  refine' Iff.intro _ _
  · intro h
    cases' succAbove_lt_ge p i with H H
    · rw [succAbove_below _ _ H] at h
      exact le_of_lt h
    · exact H
  · intro h
    rw [succAbove_above _ _ h]
    

Proof state:
case refine'_2
n m : ℕ
p : Fin (n + 1)
i : Fin n
h : p ≤ castSucc i
⊢ p < succ i

Next tactic:
exact lt_of_le_of_lt h (castSucc_lt_succ i)
/-- Embedding `i : Fin n` into `Fin (n + 1)` with a hole around `p : Fin (n + 1)`
never results in `p` itself -/
theorem succAbove_ne (p : Fin (n + 1)) (i : Fin n) : p.succAbove i ≠ p := by
  

Proof state:
n m : ℕ
p : Fin (n + 1)
i : Fin n
⊢ succAbove p i ≠ p

Next tactic:
intro eq
/-- Embedding `i : Fin n` into `Fin (n + 1)` with a hole around `p : Fin (n + 1)`
never results in `p` itself -/
theorem succAbove_ne (p : Fin (n + 1)) (i : Fin n) : p.succAbove i ≠ p := by
  intro eq
  

Proof state:
n m : ℕ
p : Fin (n + 1)
i : Fin n
eq : succAbove p i = p
⊢ False

Next tactic:
by_cases H : castSucc i < p
/-- Embedding `i : Fin n` into `Fin (n + 1)` with a hole around `p : Fin (n + 1)`
never results in `p` itself -/
theorem succAbove_ne (p : Fin (n + 1)) (i : Fin n) : p.succAbove i ≠ p := by
  intro eq
  by_cases H : castSucc i < p
  · 

Proof state:
case pos
n m : ℕ
p : Fin (n + 1)
i : Fin n
eq : succAbove p i = p
H : castSucc i < p
⊢ False

Next tactic:
simp [lt_irrefl, ← succAbove_below _ _ H, eq] at H
/-- Embedding `i : Fin n` into `Fin (n + 1)` with a hole around `p : Fin (n + 1)`
never results in `p` itself -/
theorem succAbove_ne (p : Fin (n + 1)) (i : Fin n) : p.succAbove i ≠ p := by
  intro eq
  by_cases H : castSucc i < p
  · simp [lt_irrefl, ← succAbove_below _ _ H, eq] at H
  · 

Proof state:
case neg
n m : ℕ
p : Fin (n + 1)
i : Fin n
eq : succAbove p i = p
H : ¬castSucc i < p
⊢ False

Next tactic:
simpa [← succAbove_above _ _ (le_of_not_lt H), eq, H] using castSucc_lt_succ i
/-- Embedding a positive `Fin n` results in a positive `Fin (n + 1)` -/
theorem succAbove_pos [NeZero n] (p : Fin (n + 1)) (i : Fin n) (h : 0 < i) : 0 < p.succAbove i := by
  

Proof state:
n m : ℕ
inst✝ : NeZero n
p : Fin (n + 1)
i : Fin n
h : 0 < i
⊢ 0 < succAbove p i

Next tactic:
by_cases H : castSucc i < p
/-- Embedding a positive `Fin n` results in a positive `Fin (n + 1)` -/
theorem succAbove_pos [NeZero n] (p : Fin (n + 1)) (i : Fin n) (h : 0 < i) : 0 < p.succAbove i := by
  by_cases H : castSucc i < p
  · 

Proof state:
case pos
n m : ℕ
inst✝ : NeZero n
p : Fin (n + 1)
i : Fin n
h : 0 < i
H : castSucc i < p
⊢ 0 < succAbove p i

Next tactic:
simpa [succAbove_below _ _ H] using castSucc_pos' h
/-- Embedding a positive `Fin n` results in a positive `Fin (n + 1)` -/
theorem succAbove_pos [NeZero n] (p : Fin (n + 1)) (i : Fin n) (h : 0 < i) : 0 < p.succAbove i := by
  by_cases H : castSucc i < p
  · simpa [succAbove_below _ _ H] using castSucc_pos' h
  · 

Proof state:
case neg
n m : ℕ
inst✝ : NeZero n
p : Fin (n + 1)
i : Fin n
h : 0 < i
H : ¬castSucc i < p
⊢ 0 < succAbove p i

Next tactic:
simp [succAbove_above _ _ (le_of_not_lt H)]
@[simp]
theorem succAbove_castLT {x y : Fin (n + 1)} (h : x < y)
    (hx : x.1 < n := lt_of_lt_of_le h y.le_last) : y.succAbove (x.castLT hx) = x := by
  

Proof state:
n m : ℕ
x y : Fin (n + 1)
h : x < y
hx : optParam (↑x < n) (_ : ↑x < n)
⊢ succAbove y (castLT x hx) = x

Next tactic:
rw [succAbove_below, castSucc_castLT]
@[simp]
theorem succAbove_castLT {x y : Fin (n + 1)} (h : x < y)
    (hx : x.1 < n := lt_of_lt_of_le h y.le_last) : y.succAbove (x.castLT hx) = x := by
  rw [succAbove_below, castSucc_castLT]
  

Proof state:
case h
n m : ℕ
x y : Fin (n + 1)
h : x < y
hx : optParam (↑x < n) (_ : ↑x < n)
⊢ castSucc (castLT x hx) < y

Next tactic:
exact h
@[simp]
theorem succAbove_pred {x y : Fin (n + 1)} (h : x < y)
    (hy : y ≠ 0 := (x.zero_le.trans_lt h).ne') : x.succAbove (y.pred hy) = y := by
  

Proof state:
n m : ℕ
x y : Fin (n + 1)
h : x < y
hy : optParam (y ≠ 0) (_ : y ≠ 0)
⊢ succAbove x (pred y hy) = y

Next tactic:
rw [succAbove_above, succ_pred]
@[simp]
theorem succAbove_pred {x y : Fin (n + 1)} (h : x < y)
    (hy : y ≠ 0 := (x.zero_le.trans_lt h).ne') : x.succAbove (y.pred hy) = y := by
  rw [succAbove_above, succ_pred]
  

Proof state:
case h
n m : ℕ
x y : Fin (n + 1)
h : x < y
hy : optParam (y ≠ 0) (_ : y ≠ 0)
⊢ x ≤ castSucc (pred y hy)

Next tactic:
simpa [le_iff_val_le_val] using Nat.le_sub_one_of_lt h
theorem castLT_succAbove {x : Fin n} {y : Fin (n + 1)} (h : castSucc x < y)
    (h' : (y.succAbove x).1 < n := lt_of_lt_of_le ((succAbove_lt_iff _ _).2 h) (le_last y)) :
    (y.succAbove x).castLT h' = x := by 

Proof state:
n m : ℕ
x : Fin n
y : Fin (n + 1)
h : castSucc x < y
h' : optParam (↑(succAbove y x) < n) (_ : ↑(succAbove y x) < n)
⊢ castLT (succAbove y x) h' = x

Next tactic:
simp only [succAbove_below _ _ h, castLT_castSucc]
theorem pred_succAbove {x : Fin n} {y : Fin (n + 1)} (h : y ≤ castSucc x)
    (h' : (y.succAbove x) ≠ 0 := (y.zero_le.trans_lt <| (lt_succAbove_iff _ _).2 h).ne') :
    (y.succAbove x).pred h' = x := by 

Proof state:
n m : ℕ
x : Fin n
y : Fin (n + 1)
h : y ≤ castSucc x
h' : optParam (succAbove y x ≠ 0) (_ : succAbove y x ≠ 0)
⊢ pred (succAbove y x) h' = x

Next tactic:
simp only [succAbove_above _ _ h, pred_succ]
theorem exists_succAbove_eq {x y : Fin (n + 1)} (h : x ≠ y) : ∃ z, y.succAbove z = x := by
  

Proof state:
n m : ℕ
x y : Fin (n + 1)
h : x ≠ y
⊢ ∃ z, succAbove y z = x

Next tactic:
cases' h.lt_or_lt with hlt hlt
theorem exists_succAbove_eq {x y : Fin (n + 1)} (h : x ≠ y) : ∃ z, y.succAbove z = x := by
  cases' h.lt_or_lt with hlt hlt
  

Proof state:
case inl
n m : ℕ
x y : Fin (n + 1)
h : x ≠ y
hlt : x < y
⊢ ∃ z, succAbove y z = x
case inr n m : ℕ x y : Fin (n + 1) h : x ≠ y hlt : y < x ⊢ ∃ z, succAbove y z = x

Next tactic:
exacts [⟨_, succAbove_castLT hlt⟩, ⟨_, succAbove_pred hlt⟩]
@[simp]
theorem exists_succAbove_eq_iff {x y : Fin (n + 1)} : (∃ z, x.succAbove z = y) ↔ y ≠ x := by
  

Proof state:
n m : ℕ
x y : Fin (n + 1)
⊢ (∃ z, succAbove x z = y) ↔ y ≠ x

Next tactic:
refine' ⟨_, exists_succAbove_eq⟩
@[simp]
theorem exists_succAbove_eq_iff {x y : Fin (n + 1)} : (∃ z, x.succAbove z = y) ↔ y ≠ x := by
  refine' ⟨_, exists_succAbove_eq⟩
  

Proof state:
n m : ℕ
x y : Fin (n + 1)
⊢ (∃ z, succAbove x z = y) → y ≠ x

Next tactic:
rintro ⟨y, rfl⟩
@[simp]
theorem exists_succAbove_eq_iff {x y : Fin (n + 1)} : (∃ z, x.succAbove z = y) ↔ y ≠ x := by
  refine' ⟨_, exists_succAbove_eq⟩
  rintro ⟨y, rfl⟩
  

Proof state:
case intro
n m : ℕ
x : Fin (n + 1)
y : Fin n
⊢ succAbove x y ≠ x

Next tactic:
exact succAbove_ne _ _
@[simp]
theorem range_succ (n : ℕ) : Set.range (Fin.succ : Fin n → Fin (n + 1)) = {0}ᶜ := by
  

Proof state:
n✝ m n : ℕ
⊢ Set.range succ = {0}ᶜ

Next tactic:
rw [← succAbove_zero]
@[simp]
theorem range_succ (n : ℕ) : Set.range (Fin.succ : Fin n → Fin (n + 1)) = {0}ᶜ := by
  rw [← succAbove_zero]
  

Proof state:
n✝ m n : ℕ
⊢ Set.range (succAbove 0) = {0}ᶜ

Next tactic:
exact range_succAbove (0 : Fin (n + 1))
@[simp]
theorem exists_succ_eq_iff {x : Fin (n + 1)} : (∃ y, Fin.succ y = x) ↔ x ≠ 0 := by
  

Proof state:
n m : ℕ
x : Fin (n + 1)
⊢ (∃ y, succ y = x) ↔ x ≠ 0

Next tactic:
convert @exists_succAbove_eq_iff n 0 x
/-- `succAbove` is injective at the pivot -/
theorem succAbove_left_injective : Injective (@succAbove n) := fun _ _ h => by
  

Proof state:
n m : ℕ
x✝¹ x✝ : Fin (n + 1)
h : succAbove x✝¹ = succAbove x✝
⊢ x✝¹ = x✝

Next tactic:
simpa [range_succAbove] using congr_arg (fun f : Fin n → Fin (n + 1) => (Set.range f)ᶜ) h
@[simp]
theorem zero_succAbove {n : ℕ} (i : Fin n) : (0 : Fin (n + 1)).succAbove i = i.succ := by
  

Proof state:
n✝ m n : ℕ
i : Fin n
⊢ succAbove 0 i = succ i

Next tactic:
rfl
@[simp]
theorem succ_succAbove_zero {n : ℕ} [NeZero n] (i : Fin n) : succAbove i.succ 0 = 0 :=
  succAbove_below i.succ 0 (by 

Proof state:
n✝ m n : ℕ
inst✝ : NeZero n
i : Fin n
⊢ castSucc 0 < succ i

Next tactic:
simp only [castSucc_zero', succ_pos]
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      

Proof state:
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j < i
⊢ succAbove (succ i) (succ j) = succ (succAbove i j)

Next tactic:
have h' : castSucc j.succ < i.succ := by simpa [lt_iff_val_lt_val] using h
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      have h' : castSucc j.succ < i.succ := by 

Proof state:
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j < i
⊢ castSucc (succ j) < succ i

Next tactic:
simpa [lt_iff_val_lt_val] using h
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      have h' : castSucc j.succ < i.succ := by simpa [lt_iff_val_lt_val] using h
      

Proof state:
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j < i
h' : castSucc (succ j) < succ i
⊢ succAbove (succ i) (succ j) = succ (succAbove i j)

Next tactic:
ext
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      have h' : castSucc j.succ < i.succ := by simpa [lt_iff_val_lt_val] using h
      ext
      

Proof state:
case h
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j < i
h' : castSucc (succ j) < succ i
⊢ ↑(succAbove (succ i) (succ j)) = ↑(succ (succAbove i j))

Next tactic:
simp [succAbove_below _ _ h, succAbove_below _ _ h']
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      have h' : castSucc j.succ < i.succ := by simpa [lt_iff_val_lt_val] using h
      ext
      simp [succAbove_below _ _ h, succAbove_below _ _ h'])
    fun h => by
    

Proof state:
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j ≥ i
⊢ succAbove (succ i) (succ j) = succ (succAbove i j)

Next tactic:
have h' : i.succ ≤ castSucc j.succ := by simpa [le_iff_val_le_val] using h
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      have h' : castSucc j.succ < i.succ := by simpa [lt_iff_val_lt_val] using h
      ext
      simp [succAbove_below _ _ h, succAbove_below _ _ h'])
    fun h => by
    have h' : i.succ ≤ castSucc j.succ := by 

Proof state:
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j ≥ i
⊢ succ i ≤ castSucc (succ j)

Next tactic:
simpa [le_iff_val_le_val] using h
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      have h' : castSucc j.succ < i.succ := by simpa [lt_iff_val_lt_val] using h
      ext
      simp [succAbove_below _ _ h, succAbove_below _ _ h'])
    fun h => by
    have h' : i.succ ≤ castSucc j.succ := by simpa [le_iff_val_le_val] using h
    

Proof state:
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j ≥ i
h' : succ i ≤ castSucc (succ j)
⊢ succAbove (succ i) (succ j) = succ (succAbove i j)

Next tactic:
ext
@[simp]
theorem succ_succAbove_succ {n : ℕ} (i : Fin (n + 1)) (j : Fin n) :
    i.succ.succAbove j.succ = (i.succAbove j).succ :=
  (lt_or_ge (castSucc j) i).elim
    (fun h => by
      have h' : castSucc j.succ < i.succ := by simpa [lt_iff_val_lt_val] using h
      ext
      simp [succAbove_below _ _ h, succAbove_below _ _ h'])
    fun h => by
    have h' : i.succ ≤ castSucc j.succ := by simpa [le_iff_val_le_val] using h
    ext
    

Proof state:
case h
n✝ m n : ℕ
i : Fin (n + 1)
j : Fin n
h : castSucc j ≥ i
h' : succ i ≤ castSucc (succ j)
⊢ ↑(succAbove (succ i) (succ j)) = ↑(succ (succAbove i j))

Next tactic:
simp [succAbove_above _ _ h, succAbove_above _ _ h']
theorem one_succAbove_zero {n : ℕ} : (1 : Fin (n + 2)).succAbove 0 = 0 := by
  

Proof state:
n✝ m n : ℕ
⊢ succAbove 1 0 = 0

Next tactic:
rfl
/-- By moving `succ` to the outside of this expression, we create opportunities for further
simplification using `succAbove_zero` or `succ_succAbove_zero`. -/
@[simp]
theorem succ_succAbove_one {n : ℕ} [NeZero n] (i : Fin (n + 1)) :
    i.succ.succAbove 1 = (i.succAbove 0).succ := by
  

Proof state:
n✝ m n : ℕ
inst✝ : NeZero n
i : Fin (n + 1)
⊢ succAbove (succ i) 1 = succ (succAbove i 0)

Next tactic:
rw [← succ_zero_eq_one']
/-- By moving `succ` to the outside of this expression, we create opportunities for further
simplification using `succAbove_zero` or `succ_succAbove_zero`. -/
@[simp]
theorem succ_succAbove_one {n : ℕ} [NeZero n] (i : Fin (n + 1)) :
    i.succ.succAbove 1 = (i.succAbove 0).succ := by
  rw [← succ_zero_eq_one']
  

Proof state:
n✝ m n : ℕ
inst✝ : NeZero n
i : Fin (n + 1)
⊢ succAbove (succ i) (succ 0) = succ (succAbove i 0)

Next tactic:
convert succ_succAbove_succ i 0
@[simp]
theorem one_succAbove_succ {n : ℕ} (j : Fin n) :
    (1 : Fin (n + 2)).succAbove j.succ = j.succ.succ := by
  

Proof state:
n✝ m n : ℕ
j : Fin n
⊢ succAbove 1 (succ j) = succ (succ j)

Next tactic:
have := succ_succAbove_succ 0 j
@[simp]
theorem one_succAbove_succ {n : ℕ} (j : Fin n) :
    (1 : Fin (n + 2)).succAbove j.succ = j.succ.succ := by
  have := succ_succAbove_succ 0 j
  

Proof state:
n✝ m n : ℕ
j : Fin n
this : succAbove (succ 0) (succ j) = succ (succAbove 0 j)
⊢ succAbove 1 (succ j) = succ (succ j)

Next tactic:
rwa [succ_zero_eq_one, zero_succAbove] at this
@[simp]
theorem one_succAbove_one {n : ℕ} : (1 : Fin (n + 3)).succAbove 1 = 2 := by
  

Proof state:
n✝ m n : ℕ
⊢ succAbove 1 1 = 2

Next tactic:
have := succ_succAbove_succ (0 : Fin (n + 2)) (0 : Fin (n + 2))
@[simp]
theorem one_succAbove_one {n : ℕ} : (1 : Fin (n + 3)).succAbove 1 = 2 := by
  have := succ_succAbove_succ (0 : Fin (n + 2)) (0 : Fin (n + 2))
  

Proof state:
n✝ m n : ℕ
this : succAbove (succ 0) (succ ↑↑0) = succ (succAbove 0 ↑↑0)
⊢ succAbove 1 1 = 2

Next tactic:
simp only [succ_zero_eq_one, val_zero, Nat.cast_zero, zero_succAbove, succ_one_eq_two] at this
@[simp]
theorem one_succAbove_one {n : ℕ} : (1 : Fin (n + 3)).succAbove 1 = 2 := by
  have := succ_succAbove_succ (0 : Fin (n + 2)) (0 : Fin (n + 2))
  simp only [succ_zero_eq_one, val_zero, Nat.cast_zero, zero_succAbove, succ_one_eq_two] at this
  

Proof state:
n✝ m n : ℕ
this : succAbove 1 1 = 2
⊢ succAbove 1 1 = 2

Next tactic:
exact this
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  

Proof state:
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
⊢ predAbove p a ≤ predAbove p b

Next tactic:
dsimp [predAbove]
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  

Proof state:
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
⊢ (if h : castSucc p < a then pred a (_ : a ≠ 0) else castLT a (_ : ↑a < n)) ≤
    if h : castSucc p < b then pred b (_ : b ≠ 0) else castLT b (_ : ↑b < n)

Next tactic:
split_ifs with ha hb hb
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  

Proof state:
case pos
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : castSucc p < a
hb : castSucc p < b
⊢ pred a (_ : a ≠ 0) ≤ pred b (_ : b ≠ 0)
case neg
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : castSucc p < a
hb : ¬castSucc p < b
⊢ pred a (_ : a ≠ 0) ≤ castLT b (_ : ↑b < n)
case pos
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : ¬castSucc p < a
hb : castSucc p < b
⊢ castLT a (_ : ↑a < n) ≤ pred b (_ : b ≠ 0)
case neg
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : ¬castSucc p < a
hb : ¬castSucc p < b
⊢ castLT a (_ : ↑a < n) ≤ castLT b (_ : ↑b < n)

Next tactic:
all_goals simp only [le_iff_val_le_val, coe_pred]
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals 

Proof state:
case pos
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : castSucc p < a
hb : castSucc p < b
⊢ pred a (_ : a ≠ 0) ≤ pred b (_ : b ≠ 0)

Next tactic:
simp only [le_iff_val_le_val, coe_pred]
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals 

Proof state:
case neg
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : castSucc p < a
hb : ¬castSucc p < b
⊢ pred a (_ : a ≠ 0) ≤ castLT b (_ : ↑b < n)

Next tactic:
simp only [le_iff_val_le_val, coe_pred]
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals 

Proof state:
case pos
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : ¬castSucc p < a
hb : castSucc p < b
⊢ castLT a (_ : ↑a < n) ≤ pred b (_ : b ≠ 0)

Next tactic:
simp only [le_iff_val_le_val, coe_pred]
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals 

Proof state:
case neg
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : ¬castSucc p < a
hb : ¬castSucc p < b
⊢ castLT a (_ : ↑a < n) ≤ castLT b (_ : ↑b < n)

Next tactic:
simp only [le_iff_val_le_val, coe_pred]
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals simp only [le_iff_val_le_val, coe_pred]
  · 

Proof state:
case pos
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : castSucc p < a
hb : castSucc p < b
⊢ ↑a - 1 ≤ ↑b - 1

Next tactic:
exact pred_le_pred H
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals simp only [le_iff_val_le_val, coe_pred]
  · exact pred_le_pred H
  · 

Proof state:
case neg
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : castSucc p < a
hb : ¬castSucc p < b
⊢ ↑a - 1 ≤ ↑(castLT b (_ : ↑b < n))

Next tactic:
calc
      _ ≤ _ := Nat.pred_le _
      _ ≤ _ := H
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals simp only [le_iff_val_le_val, coe_pred]
  · exact pred_le_pred H
  · calc
      _ ≤ _ := Nat.pred_le _
      _ ≤ _ := H
  · 

Proof state:
case pos
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : ¬castSucc p < a
hb : castSucc p < b
⊢ ↑(castLT a (_ : ↑a < n)) ≤ ↑b - 1

Next tactic:
simp at ha
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals simp only [le_iff_val_le_val, coe_pred]
  · exact pred_le_pred H
  · calc
      _ ≤ _ := Nat.pred_le _
      _ ≤ _ := H
  · simp at ha
    

Proof state:
case pos
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha✝ : ¬castSucc p < a
hb : castSucc p < b
ha : a ≤ castSucc p
⊢ ↑(castLT a (_ : ↑a < n)) ≤ ↑b - 1

Next tactic:
exact le_pred_of_lt (lt_of_le_of_lt ha hb)
theorem predAbove_right_monotone (p : Fin n) : Monotone p.predAbove := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  all_goals simp only [le_iff_val_le_val, coe_pred]
  · exact pred_le_pred H
  · calc
      _ ≤ _ := Nat.pred_le _
      _ ≤ _ := H
  · simp at ha
    exact le_pred_of_lt (lt_of_le_of_lt ha hb)
  · 

Proof state:
case neg
n m : ℕ
p : Fin n
a b : Fin (n + 1)
H : a ≤ b
ha : ¬castSucc p < a
hb : ¬castSucc p < b
⊢ ↑(castLT a (_ : ↑a < n)) ≤ ↑(castLT b (_ : ↑b < n))

Next tactic:
exact H
theorem predAbove_left_monotone (i : Fin (n + 1)) :
    Monotone fun p => predAbove p i := fun a b H => by
  

Proof state:
n m : ℕ
i : Fin (n + 1)
a b : Fin n
H : a ≤ b
⊢ (fun p => predAbove p i) a ≤ (fun p => predAbove p i) b

Next tactic:
dsimp [predAbove]
theorem predAbove_left_monotone (i : Fin (n + 1)) :
    Monotone fun p => predAbove p i := fun a b H => by
  dsimp [predAbove]
  

Proof state:
n m : ℕ
i : Fin (n + 1)
a b : Fin n
H : a ≤ b
⊢ (if h : castSucc a < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n)) ≤
    if h : castSucc b < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n)

Next tactic:
split_ifs with ha hb hb
theorem predAbove_left_monotone (i : Fin (n + 1)) :
    Monotone fun p => predAbove p i := fun a b H => by
  dsimp [predAbove]
  split_ifs with ha hb hb
  · 

Proof state:
case pos
n m : ℕ
i : Fin (n + 1)
a b : Fin n
H : a ≤ b
ha : castSucc a < i
hb : castSucc b < i
⊢ pred i (_ : i ≠ 0) ≤ pred i (_ : i ≠ 0)

Next tactic:
rfl