Skip to content

Commit d3854d8

Browse files
committed
toArray/keysArray lemmas
1 parent 3ea59e1 commit d3854d8

File tree

11 files changed

+1608
-2
lines changed

11 files changed

+1608
-2
lines changed

src/Init/Data/Array/Basic.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ end List
148148

149149
namespace Array
150150

151+
@[simp, grind =] theorem getElem!_toList [Inhabited α] {xs : Array α} {i : Nat} : xs.toList[i]! = xs[i]! := by
152+
rw [List.getElem!_toArray]
153+
151154
theorem size_eq_length_toList {xs : Array α} : xs.size = xs.toList.length := rfl
152155

153156
/-! ### Externs -/

src/Init/Data/List/Lemmas.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,12 @@ theorem getElem_zero_eq_head {l : List α} (h : 0 < l.length) :
937937
| nil => simp at h
938938
| cons _ _ => simp
939939

940+
theorem head!_eq_getElem! [Inhabited α] {l : List α} : head! l = l[0]! := by
941+
cases l <;> rfl
942+
943+
theorem headD_eq_getD {l : List α} {fallback} : headD l fallback = l.getD 0 fallback := by
944+
cases l <;> rfl
945+
940946
theorem head_eq_iff_head?_eq_some {xs : List α} (h) : xs.head h = a ↔ xs.head? = some a := by
941947
cases xs with
942948
| nil => simp at h

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

Lines changed: 402 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ theorem minKey?_eq_minEntry?_map_fst {l : Impl α β} : l.minKey? = l.minEntry?.
661661
theorem minKey_eq_minEntry_fst {l : Impl α β} {he} : l.minKey he = (l.minEntry he).fst := by
662662
induction l, he using minKey.induct_unfolding <;> simp only [minEntry] <;> trivial
663663

664-
theorem minKey!_eq_get!_minKey? [Inhabited α] {l : Impl α β} :
664+
theorem minKey!_eq_getElem!_minKey? [Inhabited α] {l : Impl α β} :
665665
l.minKey! = l.minKey?.get! := by
666666
induction l using minKey!.induct_unfolding <;> simp only [minKey?] <;> trivial
667667

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ theorem minKey_eq_minKey [Ord α] [TransOrd α] [BEq α] [LawfulBEqOrd α] {l :
22962296
theorem minKey!_eq_minKey! [Ord α] [TransOrd α] [Inhabited α] [BEq α] [LawfulBEqOrd α]
22972297
{l : Impl α β} (hlo : l.Ordered) :
22982298
l.minKey! = List.minKey! l.toListModel := by
2299-
simp [Impl.minKey!_eq_get!_minKey?, List.minKey!_eq_get!_minKey?, minKey?_eq_minKey? hlo]
2299+
simp [Impl.minKey!_eq_getElem!_minKey?, List.minKey!_eq_get!_minKey?, minKey?_eq_minKey? hlo]
23002300

23012301
theorem minKeyD_eq_minKeyD [Ord α] [TransOrd α] [BEq α] [LawfulBEqOrd α] {l : Impl α β}
23022302
(hlo : l.Ordered) {fallback} :

0 commit comments

Comments
 (0)