Skip to content

Commit f5eaaa9

Browse files
committed
Merge remote-tracking branch 'origin/simp_nf_2025-05' into getElem_simps
2 parents fe52717 + d7d370e commit f5eaaa9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+328
-301
lines changed

src/Init/Data/Array/Attach.lean

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ well-founded recursion mechanism to prove that the function terminates.
6969
simp [pmap]
7070

7171
@[simp] theorem toList_attachWith {xs : Array α} {P : α → Prop} {H : ∀ x ∈ xs, P x} :
72-
(xs.attachWith P H).toList = xs.toList.attachWith P (by simpa [mem_toList] using H) := by
72+
(xs.attachWith P H).toList = xs.toList.attachWith P (by simpa [mem_toList_iff] using H) := by
7373
simp [attachWith]
7474

7575
@[simp] theorem toList_attach {xs : Array α} :
76-
xs.attach.toList = xs.toList.attachWith (· ∈ xs) (by simp [mem_toList]) := by
76+
xs.attach.toList = xs.toList.attachWith (· ∈ xs) (by simp [mem_toList_iff]) := by
7777
simp [attach]
7878

7979
@[simp] theorem toList_pmap {xs : Array α} {P : α → Prop} {f : ∀ a, P a → β} {H : ∀ a ∈ xs, P a} :
@@ -574,9 +574,12 @@ state, the right approach is usually the tactic `simp [Array.unattach, -Array.ma
574574
-/
575575
def unattach {α : Type _} {p : α → Prop} (xs : Array { x // p x }) : Array α := xs.map (·.val)
576576

577-
@[simp] theorem unattach_nil {p : α → Prop} : (#[] : Array { x // p x }).unattach = #[] := by
577+
@[simp] theorem unattach_empty {p : α → Prop} : (#[] : Array { x // p x }).unattach = #[] := by
578578
simp [unattach]
579579

580+
@[deprecated unattach_empty (since := "2025-05-26")]
581+
abbrev unattach_nil := @unattach_empty
582+
580583
@[simp] theorem unattach_push {p : α → Prop} {a : { x // p x }} {xs : Array { x // p x }} :
581584
(xs.push a).unattach = xs.unattach.push a.1 := by
582585
simp only [unattach, Array.map_push]

src/Init/Data/Array/Bootstrap.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,13 @@ theorem foldrM_eq_reverse_foldlM_toList [Monad m] {f : α → β → m β} {init
8989
xs.toList.foldr f init = xs.foldr f init :=
9090
List.foldr_eq_foldrM .. ▸ foldrM_toList ..
9191

92-
@[simp, grind =] theorem push_toList {xs : Array α} {a : α} : (xs.push a).toList = xs.toList ++ [a] := by
92+
@[simp, grind =] theorem toList_push {xs : Array α} {x : α} : (xs.push x).toList = xs.toList ++ [x] := by
93+
rcases xs with ⟨xs⟩
9394
simp [push, List.concat_eq_append]
9495

96+
@[deprecated toList_push (since := "2025-05-26")]
97+
abbrev push_toList := @toList_push
98+
9599
@[simp, grind =] theorem toListAppend_eq {xs : Array α} {l : List α} : xs.toListAppend l = xs.toList ++ l := by
96100
simp [toListAppend, ← foldr_toList]
97101

src/Init/Data/Array/Count.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ theorem countP_push {a : α} {xs : Array α} : countP p (xs.push a) = countP p x
5252
rcases xs with ⟨xs⟩
5353
simp_all
5454

55-
@[simp] theorem countP_singleton {a : α} : countP p #[a] = if p a then 1 else 0 := by
56-
simp [countP_push]
55+
theorem countP_singleton {a : α} : countP p #[a] = if p a then 1 else 0 := by
56+
simp
5757

5858
theorem size_eq_countP_add_countP {xs : Array α} : xs.size = countP p xs + countP (fun a => ¬p a) xs := by
5959
rcases xs with ⟨xs⟩

src/Init/Data/Array/Erase.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ open Nat
2424

2525
/-! ### eraseP -/
2626

27-
@[simp] theorem eraseP_empty : #[].eraseP p = #[] := by simp
27+
theorem eraseP_empty : #[].eraseP p = #[] := by simp
2828

2929
theorem eraseP_of_forall_mem_not {xs : Array α} (h : ∀ a, a ∈ xs → ¬p a) : xs.eraseP p = xs := by
3030
rcases xs with ⟨xs⟩

src/Init/Data/Array/Extract.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,9 @@ theorem extract_append_left {as bs : Array α} :
238238
(as ++ bs).extract 0 as.size = as.extract 0 as.size := by
239239
simp
240240

241-
@[simp] theorem extract_append_right {as bs : Array α} :
241+
theorem extract_append_right {as bs : Array α} :
242242
(as ++ bs).extract as.size (as.size + i) = bs.extract 0 i := by
243-
simp only [extract_append, extract_size_left, Nat.sub_self, empty_append]
244-
congr 1
245-
omega
243+
simp
246244

247245
@[simp] theorem map_extract {as : Array α} {i j : Nat} :
248246
(as.extract i j).map f = (as.map f).extract i j := by

src/Init/Data/Array/Find.lean

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ abbrev findSome?_mkArray_of_isNone := @findSome?_replicate_of_isNone
142142

143143
@[simp] theorem find?_empty : find? p #[] = none := rfl
144144

145-
@[simp] theorem find?_singleton {a : α} {p : α → Bool} :
145+
theorem find?_singleton {a : α} {p : α → Bool} :
146146
#[a].find? p = if p a then some a else none := by
147-
simp [singleton_eq_toArray_singleton]
147+
simp
148148

149149
@[simp] theorem findRev?_push_of_pos {xs : Array α} (h : p a) :
150150
findRev? p (xs.push a) = some a := by
@@ -347,7 +347,8 @@ theorem find?_eq_some_iff_getElem {xs : Array α} {p : α → Bool} {b : α} :
347347

348348
/-! ### findIdx -/
349349

350-
@[simp] theorem findIdx_empty : findIdx p #[] = 0 := rfl
350+
theorem findIdx_empty : findIdx p #[] = 0 := rfl
351+
351352
theorem findIdx_singleton {a : α} {p : α → Bool} :
352353
#[a].findIdx p = if p a then 0 else 1 := by
353354
simp
@@ -600,7 +601,8 @@ theorem findIdx?_eq_some_le_of_findIdx?_eq_some {xs : Array α} {p q : α → Bo
600601

601602
/-! ### findFinIdx? -/
602603

603-
@[simp] theorem findFinIdx?_empty {p : α → Bool} : findFinIdx? p #[] = none := by simp
604+
theorem findFinIdx?_empty {p : α → Bool} : findFinIdx? p #[] = none := by simp
605+
604606
theorem findFinIdx?_singleton {a : α} {p : α → Bool} :
605607
#[a].findFinIdx? p = if p a then some ⟨0, by simp⟩ else none := by
606608
simp
@@ -699,7 +701,7 @@ The verification API for `idxOf?` is still incomplete.
699701
The lemmas below should be made consistent with those for `findIdx?` (and proved using them).
700702
-/
701703

702-
@[simp] theorem idxOf?_empty [BEq α] : (#[] : Array α).idxOf? a = none := by simp
704+
theorem idxOf?_empty [BEq α] : (#[] : Array α).idxOf? a = none := by simp
703705

704706
@[simp] theorem idxOf?_eq_none_iff [BEq α] [LawfulBEq α] {xs : Array α} {a : α} :
705707
xs.idxOf? a = none ↔ a ∉ xs := by
@@ -712,14 +714,10 @@ theorem isSome_idxOf? [BEq α] [LawfulBEq α] {xs : Array α} {a : α} :
712714
rcases xs with ⟨xs⟩
713715
simp
714716

715-
@[simp]
716717
theorem isNone_idxOf? [BEq α] [LawfulBEq α] {xs : Array α} {a : α} :
717718
(xs.idxOf? a).isNone = ¬ a ∈ xs := by
718-
rcases xs with ⟨xs⟩
719719
simp
720720

721-
722-
723721
/-! ### finIdxOf?
724722
725723
The verification API for `finIdxOf?` is still incomplete.
@@ -730,7 +728,7 @@ theorem idxOf?_eq_map_finIdxOf?_val [BEq α] {xs : Array α} {a : α} :
730728
xs.idxOf? a = (xs.finIdxOf? a).map (·.val) := by
731729
simp [idxOf?, finIdxOf?, findIdx?_eq_map_findFinIdx?_val]
732730

733-
@[simp] theorem finIdxOf?_empty [BEq α] : (#[] : Array α).finIdxOf? a = none := by simp
731+
theorem finIdxOf?_empty [BEq α] : (#[] : Array α).finIdxOf? a = none := by simp
734732

735733
@[simp] theorem finIdxOf?_eq_none_iff [BEq α] [LawfulBEq α] {xs : Array α} {a : α} :
736734
xs.finIdxOf? a = none ↔ a ∉ xs := by
@@ -748,10 +746,8 @@ theorem isSome_finIdxOf? [BEq α] [LawfulBEq α] {xs : Array α} {a : α} :
748746
rcases xs with ⟨xs⟩
749747
simp
750748

751-
@[simp]
752749
theorem isNone_finIdxOf? [BEq α] [LawfulBEq α] {xs : Array α} {a : α} :
753750
(xs.finIdxOf? a).isNone = ¬ a ∈ xs := by
754-
rcases xs with ⟨xs⟩
755751
simp
756752

757753
end Array

0 commit comments

Comments
 (0)