Skip to content

Commit 6d22793

Browse files
authored
refactor: Array.feraseIdx: avoid have in definition (#4074)
otherwise it remains in the equational theorem and may cause the “unused have linter” to trigger. By moving the proof into `decreasing_by`, the equational theorems are unencumbered by termination arguments. see also leanprover-community/batteries#690 (comment)
1 parent e0c1afd commit 6d22793

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Init/Data/Array/Basic.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,17 +733,15 @@ def feraseIdx (a : Array α) (i : Fin a.size) : Array α :=
733733
if h : i.val + 1 < a.size then
734734
let a' := a.swap ⟨i.val + 1, h⟩ i
735735
let i' : Fin a'.size := ⟨i.val + 1, by simp [a', h]⟩
736-
have : a'.size - i' < a.size - i := by
737-
simp [a', Nat.sub_succ_lt_self _ _ i.isLt]
738736
a'.feraseIdx i'
739737
else
740738
a.pop
741739
termination_by a.size - i.val
742-
decreasing_by simp_wf; decreasing_trivial_pre_omega
740+
decreasing_by simp_wf; exact Nat.sub_succ_lt_self _ _ i.isLt
743741

744742
theorem size_feraseIdx (a : Array α) (i : Fin a.size) : (a.feraseIdx i).size = a.size - 1 := by
745743
induction a, i using Array.feraseIdx.induct with
746-
| @case1 a i h a' _ _ ih =>
744+
| @case1 a i h a' _ ih =>
747745
unfold feraseIdx
748746
simp [h, a', ih]
749747
| case2 a i h =>

0 commit comments

Comments
 (0)