Skip to content

Commit 82171a6

Browse files
committed
cleanups
1 parent b799307 commit 82171a6

File tree

7 files changed

+24
-6
lines changed

7 files changed

+24
-6
lines changed

src/Std/Data/DTreeMap/Internal/Lemmas.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10339,14 +10339,14 @@ theorem keys_filter [TransOrd α] [LawfulEqOrd α] {f : (a : α) → β a → Bo
1033910339
rw [List.keys_filter h.ordered.distinctKeys]
1034010340
simp only [List.filter_map, Function.comp_def, List.unattach, List.map_map]
1034110341

10342-
private theorem _root_.List.unattach_filter_eq_if {p : α → Prop} {l : List { x // p x }}
10342+
private theorem List.unattach_filter_eq_if {p : α → Prop} {l : List { x // p x }}
1034310343
{f : { x // p x } → Bool} :
1034410344
open scoped Classical in
1034510345
(l.filter f).unattach = l.unattach.filter (fun x => if h : p x then f ⟨x, h⟩ else false) := by
1034610346
apply List.unattach_filter
1034710347
simp +contextual
1034810348

10349-
private theorem _root_.Array.unattach_filter_eq_if {p : α → Prop} {xs : Array { x // p x }}
10349+
private theorem Array.unattach_filter_eq_if {p : α → Prop} {xs : Array { x // p x }}
1035010350
{f : { x // p x } → Bool} :
1035110351
open scoped Classical in
1035210352
(xs.filter f).unattach = xs.unattach.filter (fun x => if h : p x then f ⟨x, h⟩ else false) := by

src/Std/Data/DTreeMap/Lemmas.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ theorem mem_keys [LawfulEqCmp cmp] [TransCmp cmp] {k : α} :
11371137
k ∈ t.keys ↔ k ∈ t :=
11381138
Impl.mem_keys t.wf
11391139

1140+
@[simp, grind =]
11401141
theorem mem_keysArray [LawfulEqCmp cmp] [TransCmp cmp] {k : α} :
11411142
k ∈ t.keysArray ↔ k ∈ t :=
11421143
Impl.mem_keysArray t.wf

src/Std/Data/DTreeMap/Raw/Lemmas.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ theorem mem_keys [LawfulEqCmp cmp] [TransCmp cmp] (h : t.WF) {k : α} :
11671167
k ∈ t.keys ↔ k ∈ t :=
11681168
Impl.mem_keys h
11691169

1170+
@[simp, grind =]
11701171
theorem mem_keysArray [LawfulEqCmp cmp] [TransCmp cmp] (h : t.WF) {k : α} :
11711172
k ∈ t.keysArray ↔ k ∈ t :=
11721173
Impl.mem_keysArray h

src/Std/Data/TreeMap/Lemmas.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ theorem getElem?_congr [TransCmp cmp] {a b : α} (hab : cmp a b = .eq) :
298298
theorem toList_insert_perm [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] {k : α} {v : β} :
299299
(t.insert k v).toList.Perm (⟨k, v⟩ :: t.toList.filter (¬k == ·.1)) := DTreeMap.Const.toList_insert_perm
300300

301+
theorem toArray_insert_perm [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] {k : α} {v : β} :
302+
(t.insert k v).toArray.Perm ((t.toArray.filter (¬k == ·.1)).push ⟨k, v⟩) := DTreeMap.Const.toArray_insert_perm
303+
301304
theorem keys_insertIfNew_perm {t : TreeMap α Unit cmp} [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] {k : α} :
302305
(t.insertIfNew k ()).keys.Perm (if k ∈ t then t.keys else k :: t.keys) :=
303306
DTreeMap.keys_insertIfNew_perm
@@ -839,6 +842,7 @@ theorem mem_keys [LawfulEqCmp cmp] [TransCmp cmp] {k : α} :
839842
k ∈ t.keys ↔ k ∈ t :=
840843
DTreeMap.mem_keys
841844

845+
@[simp, grind =]
842846
theorem mem_keysArray [LawfulEqCmp cmp] [TransCmp cmp] {k : α} :
843847
k ∈ t.keysArray ↔ k ∈ t :=
844848
DTreeMap.mem_keysArray
@@ -4569,6 +4573,7 @@ theorem toList_filterMap {f : (a : α) → β → Option γ} :
45694573
t.toList.filterMap (fun p => (f p.1 p.2).map (fun x => (p.1, x))) :=
45704574
DTreeMap.Const.toList_filterMap
45714575

4576+
@[simp, grind =]
45724577
theorem toArray_filterMap {f : α → β → Option γ} :
45734578
(t.filterMap f).toArray =
45744579
t.toArray.filterMap (fun p => (f p.1 p.2).map (fun x => (p.1, x))) :=
@@ -4741,6 +4746,7 @@ theorem toList_filter {f : α → β → Bool} :
47414746
(t.filter f).toList = t.toList.filter (fun p => f p.1 p.2) :=
47424747
DTreeMap.Const.toList_filter
47434748

4749+
@[simp, grind =]
47444750
theorem toArray_filter {f : α → β → Bool} :
47454751
(t.filter f).toArray = t.toArray.filter (fun p => f p.1 p.2) :=
47464752
DTreeMap.Const.toArray_filter
@@ -4936,6 +4942,7 @@ theorem toList_map {f : α → β → γ} :
49364942
(t.map f).toList = t.toList.map (fun p => (p.1, f p.1 p.2)) :=
49374943
DTreeMap.Const.toList_map
49384944

4945+
@[simp, grind =]
49394946
theorem toArray_map {f : α → β → γ} :
49404947
(t.map f).toArray = t.toArray.map (fun p => (p.1, f p.1 p.2)) :=
49414948
DTreeMap.Const.toArray_map

src/Std/Data/TreeMap/Raw/Lemmas.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ theorem toList_insert_perm [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] (h : t.WF)
294294
(t.insert k v).toList.Perm (⟨k, v⟩ :: t.toList.filter (¬k == ·.1)) :=
295295
DTreeMap.Raw.Const.toList_insert_perm h
296296

297+
theorem toArray_insert_perm [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] (h : t.WF) {k : α} {v : β} :
298+
(t.insert k v).toArray.Perm ((t.toArray.filter (¬k == ·.1)).push ⟨k, v⟩) :=
299+
DTreeMap.Raw.Const.toArray_insert_perm h
300+
297301
theorem keys_insertIfNew_perm {t : Raw α Unit cmp} [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] (h : t.WF) {k : α} :
298302
(t.insertIfNew k ()).keys.Perm (if k ∈ t then t.keys else k :: t.keys) :=
299303
DTreeMap.Raw.keys_insertIfNew_perm h
@@ -841,6 +845,7 @@ theorem mem_keys [LawfulEqCmp cmp] [TransCmp cmp] (h : t.WF) {k : α} :
841845
k ∈ t.keys ↔ k ∈ t :=
842846
DTreeMap.Raw.mem_keys h
843847

848+
@[simp, grind =]
844849
theorem mem_keysArray [LawfulEqCmp cmp] [TransCmp cmp] (h : t.WF) {k : α} :
845850
k ∈ t.keysArray ↔ k ∈ t :=
846851
DTreeMap.Raw.mem_keysArray h

src/Std/Data/TreeSet/Lemmas.lean

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ theorem toList_insert_perm [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] {k : α} :
293293
(t.insert k).toList.Perm (if k ∈ t then t.toList else k :: t.toList) :=
294294
DTreeMap.keys_insertIfNew_perm
295295

296+
theorem toArray_insert_perm [BEq α] [TransCmp cmp] [LawfulBEqCmp cmp] {k : α} :
297+
(t.insert k).toArray.Perm (if k ∈ t then t.toArray else t.toArray.push k) :=
298+
DTreeMap.keysArray_insertIfNew_perm
299+
296300
@[simp, grind =] theorem get_erase [TransCmp cmp] {k a : α} {h'} :
297301
(t.erase k).get a h' = t.get a (mem_of_mem_erase h') :=
298302
TreeMap.getKey_erase
@@ -485,12 +489,12 @@ theorem contains_toArray [BEq α] [LawfulBEqCmp cmp] [TransCmp cmp] {k : α} :
485489
t.toArray.contains k = t.contains k := by
486490
simp [← toArray_toList, contains_toList]
487491

488-
@[simp]
492+
@[simp, grind =]
489493
theorem mem_toList [LawfulEqCmp cmp] [TransCmp cmp] {k : α} :
490494
k ∈ t.toList ↔ k ∈ t :=
491495
TreeMap.mem_keys
492496

493-
@[simp]
497+
@[simp, grind =]
494498
theorem mem_toArray [LawfulEqCmp cmp] [TransCmp cmp] {k : α} :
495499
k ∈ t.toArray ↔ k ∈ t :=
496500
TreeMap.mem_keysArray
@@ -1610,7 +1614,7 @@ theorem min!_eq_head!_toList [TransCmp cmp] [Inhabited α] :
16101614
t.min! = t.toList.head! :=
16111615
TreeMap.minKey!_eq_head!_keys
16121616

1613-
theorem min!_eq_get!_toArray [TransCmp cmp] [Inhabited α] :
1617+
theorem min!_eq_getElem!_toArray [TransCmp cmp] [Inhabited α] :
16141618
t.min! = t.toArray[0]! :=
16151619
TreeMap.minKey!_eq_getElem!_keysArray
16161620

src/Std/Data/TreeSet/Raw/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ theorem min!_eq_head!_toList [TransCmp cmp] [Inhabited α] (h : t.WF) :
15601560
TreeMap.Raw.minKey!_eq_head!_keys h
15611561

15621562
@[grind =_]
1563-
theorem min!_eq_getElem!_toArray_zero [TransCmp cmp] [Inhabited α] (h : t.WF) :
1563+
theorem min!_eq_getElem!_toArray [TransCmp cmp] [Inhabited α] (h : t.WF) :
15641564
t.min! = t.toArray[0]! :=
15651565
TreeMap.Raw.minKey!_eq_getElem!_keysArray h
15661566

0 commit comments

Comments
 (0)