From 6abb8aad4351f8145ebbf721cef1dc0ba1f9f45d Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Mon, 9 Dec 2024 09:03:23 +1100 Subject: [PATCH] chore: cleanup of Array lemmas (#6337) This PRs continues cleaning up Array lemmas and improving alignment with List. --- src/Init/Data/Array/Basic.lean | 2 + src/Init/Data/Array/Lemmas.lean | 263 ++++++------------ src/Init/Data/Array/TakeDrop.lean | 2 +- src/Init/Data/List/Lemmas.lean | 45 +-- src/Init/Data/List/MapIdx.lean | 6 +- src/Init/GetElem.lean | 18 +- src/Std/Data/DHashMap/Internal/WF.lean | 2 +- .../Tactic/BVDecide/LRAT/Internal/Clause.lean | 2 +- .../LRAT/Internal/Formula/Lemmas.lean | 6 +- .../LRAT/Internal/Formula/RatAddSound.lean | 6 +- .../LRAT/Internal/Formula/RupAddResult.lean | 36 ++- 11 files changed, 143 insertions(+), 245 deletions(-) diff --git a/src/Init/Data/Array/Basic.lean b/src/Init/Data/Array/Basic.lean index 52fb7faecf06..8e2a62e791f9 100644 --- a/src/Init/Data/Array/Basic.lean +++ b/src/Init/Data/Array/Basic.lean @@ -85,6 +85,8 @@ theorem ext' {as bs : Array α} (h : as.toList = bs.toList) : as = bs := by @[simp] theorem getElem_toList {a : Array α} {i : Nat} (h : i < a.size) : a.toList[i] = a[i] := rfl +@[simp] theorem getElem?_toList {a : Array α} {i : Nat} : a.toList[i]? = a[i]? := rfl + /-- `a ∈ as` is a predicate which asserts that `a` is in the array `as`. -/ -- NB: This is defined as a structure rather than a plain def so that a lemma -- like `sizeOf_lt_of_mem` will not apply with no actual arrays around. diff --git a/src/Init/Data/Array/Lemmas.lean b/src/Init/Data/Array/Lemmas.lean index ea8a4f931c9a..75a760a29abf 100644 --- a/src/Init/Data/Array/Lemmas.lean +++ b/src/Init/Data/Array/Lemmas.lean @@ -29,7 +29,7 @@ that we need to write lemmas about `List.toArray`. -/ namespace Array -theorem getElem?_eq_getElem {a : Array α} {i : Nat} (h : i < a.size) : a[i]? = some a[i] := +@[simp] theorem getElem?_eq_getElem {a : Array α} {i : Nat} (h : i < a.size) : a[i]? = some a[i] := getElem?_pos .. @[simp] theorem getElem?_eq_none_iff {a : Array α} : a[i]? = none ↔ a.size ≤ i := by @@ -91,6 +91,9 @@ theorem toArray_inj {a b : List α} (h : a.toArray = b.toArray) : a = b := by @[simp] theorem back?_toArray (l : List α) : l.toArray.back? = l.getLast? := by simp [back?, List.getLast?_eq_getElem?] +@[simp] theorem set_toArray (l : List α) (i : Nat) (a : α) (h : i < l.length) : + (l.toArray.set i a) = (l.set i a).toArray := rfl + @[simp] theorem forIn'_loop_toArray [Monad m] (l : List α) (f : (a : α) → a ∈ l.toArray → β → m (ForInStep β)) (i : Nat) (h : i ≤ l.length) (b : β) : Array.forIn'.loop l.toArray f i h b = @@ -526,38 +529,50 @@ theorem exists_push_of_size_eq_add_one {xs : Array α} (h : xs.size = n + 1) : /-! ## L[i] and L[i]? -/ -@[deprecated List.getElem_toArray (since := "2024-11-29")] -theorem getElem_mk {xs : List α} {i : Nat} (h : i < xs.length) : (Array.mk xs)[i] = xs[i] := rfl - -theorem getElem_eq_getElem_toList {a : Array α} (h : i < a.size) : a[i] = a.toList[i] := rfl +-- getElem?_eq_none_iff is above. @[simp] theorem none_eq_getElem?_iff {a : Array α} {i : Nat} : none = a[i]? ↔ a.size ≤ i := by simp [eq_comm (a := none)] -theorem getElem?_eq {a : Array α} {i : Nat} : - a[i]? = if h : i < a.size then some a[i] else none := by - split - · simp_all [getElem?_eq_getElem] - · simp_all - theorem getElem?_eq_some_iff {a : Array α} : a[i]? = some b ↔ ∃ h : i < a.size, a[i] = b := by - simp [getElem?_eq] + simp [getElem?_def] + +theorem getElem?_eq_none {a : Array α} (h : a.size ≤ i) : a[i]? = none := by + simp [getElem?_eq_none_iff, h] + +-- getElem?_eq_getElem is above. theorem some_eq_getElem?_iff {a : Array α} : some b = a[i]? ↔ ∃ h : i < a.size, a[i] = b := by rw [eq_comm, getElem?_eq_some_iff] -theorem getElem?_eq_getElem?_toList (a : Array α) (i : Nat) : a[i]? = a.toList[i]? := by - rw [getElem?_eq] - split <;> simp_all +-- getElem?_eq_some_iff is above. + +@[simp] theorem some_getElem_eq_getElem?_iff (a : Array α) (i : Nat) (h : i < a.size) : + (some a[i] = a[i]?) ↔ True := by + simp [h] + +@[simp] theorem getElem?_eq_some_getElem_iff (a : Array α) (i : Nat) (h : i < a.size) : + (a[i]? = some a[i]) ↔ True := by + simp [h] + +theorem getElem_eq_iff {a : Array α} {n : Nat} {h : n < a.size} : a[n] = x ↔ a[n]? = some x := by + simp only [getElem?_eq_some_iff] + exact ⟨fun w => ⟨h, w⟩, fun h => h.2⟩ + +theorem getElem_eq_getElem?_get (a : Array α) (i : Nat) (h : i < a.size) : + a[i] = a[i]?.get (by simp [getElem?_eq_getElem, h]) := by + simp [getElem_eq_iff] + +@[simp] theorem getElem?_empty {n : Nat} : (#[] : Array α)[n]? = none := rfl theorem getElem_push_lt (a : Array α) (x : α) (i : Nat) (h : i < a.size) : have : i < (a.push x).size := by simp [*, Nat.lt_succ_of_le, Nat.le_of_lt] (a.push x)[i] = a[i] := by - simp only [push, getElem_eq_getElem_toList, List.concat_eq_append, List.getElem_append_left, h] + simp only [push, ← getElem_toList, List.concat_eq_append, List.getElem_append_left, h] @[simp] theorem getElem_push_eq (a : Array α) (x : α) : (a.push x)[a.size] = x := by - simp only [push, getElem_eq_getElem_toList, List.concat_eq_append] - rw [List.getElem_append_right] <;> simp [getElem_eq_getElem_toList, Nat.zero_lt_one] + simp only [push, ← getElem_toList, List.concat_eq_append] + rw [List.getElem_append_right] <;> simp [← getElem_toList, Nat.zero_lt_one] theorem getElem_push (a : Array α) (x : α) (i : Nat) (h : i < (a.push x).size) : (a.push x)[i] = if h : i < a.size then a[i] else x := by @@ -566,9 +581,12 @@ theorem getElem_push (a : Array α) (x : α) (i : Nat) (h : i < (a.push x).size) · simp at h simp [getElem_push_lt, Nat.le_antisymm (Nat.le_of_lt_succ h) (Nat.ge_of_not_lt h')] -@[deprecated getElem_push (since := "2024-10-21")] abbrev get_push := @getElem_push -@[deprecated getElem_push_lt (since := "2024-10-21")] abbrev get_push_lt := @getElem_push_lt -@[deprecated getElem_push_eq (since := "2024-10-21")] abbrev get_push_eq := @getElem_push_eq +theorem getElem?_push {a : Array α} {x} : (a.push x)[i]? = if i = a.size then some x else a[i]? := by + simp [getElem?_def, getElem_push] + (repeat' split) <;> first | rfl | omega + +@[simp] theorem getElem?_push_size {a : Array α} {x} : (a.push x)[a.size]? = some x := by + simp [getElem?_push] @[simp] theorem mem_push {a : Array α} {x y : α} : x ∈ a.push y ↔ x ∈ a ∨ x = y := by simp [mem_def] @@ -755,12 +773,14 @@ theorem get!_eq_getD [Inhabited α] (a : Array α) : a.get! n = a.getD n default @[simp] theorem getElem_set_eq (a : Array α) (i : Nat) (h : i < a.size) (v : α) {j : Nat} (eq : i = j) (p : j < (a.set i v).size) : (a.set i v)[j]'p = v := by - simp [set, getElem_eq_getElem_toList, ←eq] + cases a + simp + simp [set, ← getElem_toList, ←eq] @[simp] theorem getElem_set_ne (a : Array α) (i : Nat) (h' : i < a.size) (v : α) {j : Nat} (pj : j < (a.set i v).size) (h : i ≠ j) : (a.set i v)[j]'pj = a[j]'(size_set a i v _ ▸ pj) := by - simp only [set, getElem_eq_getElem_toList, List.getElem_set_ne h] + simp only [set, ← getElem_toList, List.getElem_set_ne h] theorem getElem_set (a : Array α) (i : Nat) (h' : i < a.size) (v : α) (j : Nat) (h : j < (a.set i v).size) : @@ -882,7 +902,7 @@ theorem ofFn_succ (f : Fin (n+1) → α) : theorem mkArray_eq_toArray_replicate (n : Nat) (v : α) : mkArray n v = (List.replicate n v).toArray := rfl @[simp] theorem getElem_mkArray (n : Nat) (v : α) (h : i < (mkArray n v).size) : - (mkArray n v)[i] = v := by simp [Array.getElem_eq_getElem_toList] + (mkArray n v)[i] = v := by simp [← getElem_toList] theorem getElem?_mkArray (n : Nat) (v : α) (i : Nat) : (mkArray n v)[i]? = if i < n then some v else none := by @@ -927,10 +947,10 @@ theorem getElem?_size_le (a : Array α) (i : Nat) (h : a.size ≤ i) : a[i]? = n @[deprecated getElem?_size_le (since := "2024-10-21")] abbrev get?_len_le := @getElem?_size_le theorem getElem_mem_toList (a : Array α) (h : i < a.size) : a[i] ∈ a.toList := by - simp only [getElem_eq_getElem_toList, List.getElem_mem] + simp only [← getElem_toList, List.getElem_mem] theorem get?_eq_get?_toList (a : Array α) (i : Nat) : a.get? i = a.toList.get? i := by - simp [getElem?_eq_getElem?_toList] + simp [← getElem?_toList] theorem get!_eq_get? [Inhabited α] (a : Array α) : a.get! n = (a.get? n).getD default := by simp only [get!_eq_getElem?, get?_eq_getElem?] @@ -939,7 +959,7 @@ theorem back!_eq_back? [Inhabited α] (a : Array α) : a.back! = a.back?.getD de simp only [back!, get!_eq_getElem?, get?_eq_getElem?, back?] @[simp] theorem back?_push (a : Array α) : (a.push x).back? = some x := by - simp [back?, getElem?_eq_getElem?_toList] + simp [back?, ← getElem?_toList] @[simp] theorem back!_push [Inhabited α] (a : Array α) : (a.push x).back! = x := by simp [back!_eq_back?] @@ -959,21 +979,6 @@ theorem getElem?_push_eq (a : Array α) (x : α) : (a.push x)[a.size]? = some x @[deprecated getElem?_push_eq (since := "2024-10-21")] abbrev get?_push_eq := @getElem?_push_eq -theorem getElem?_push {a : Array α} : (a.push x)[i]? = if i = a.size then some x else a[i]? := by - match Nat.lt_trichotomy i a.size with - | Or.inl g => - have h1 : i < a.size + 1 := by omega - have h2 : i ≠ a.size := by omega - simp [getElem?_def, size_push, g, h1, h2, getElem_push_lt] - | Or.inr (Or.inl heq) => - simp [heq, getElem?_pos, getElem_push_eq] - | Or.inr (Or.inr g) => - simp only [getElem?_def, size_push] - have h1 : ¬ (i < a.size) := by omega - have h2 : ¬ (i < a.size + 1) := by omega - have h3 : i ≠ a.size := by omega - simp [h1, h2, h3] - @[deprecated getElem?_push (since := "2024-10-21")] abbrev get?_push := @getElem?_push @[simp] theorem getElem?_size {a : Array α} : a[a.size]? = none := by @@ -985,7 +990,7 @@ theorem getElem?_push {a : Array α} : (a.push x)[i]? = if i = a.size then some theorem get_set_eq (a : Array α) (i : Nat) (v : α) (h : i < a.size) : (a.set i v h)[i]'(by simp [h]) = v := by - simp only [set, getElem_eq_getElem_toList, List.getElem_set_self] + simp only [set, ← getElem_toList, List.getElem_set_self] theorem get?_set_eq (a : Array α) (i : Nat) (v : α) (h : i < a.size) : (a.set i v)[i]? = v := by simp [getElem?_pos, h] @@ -1004,7 +1009,7 @@ theorem get_set (a : Array α) (i : Nat) (hi : i < a.size) (j : Nat) (hj : j < a @[simp] theorem get_set_ne (a : Array α) (i : Nat) (hi : i < a.size) {j : Nat} (v : α) (hj : j < a.size) (h : i ≠ j) : (a.set i v)[j]'(by simp [*]) = a[j] := by - simp only [set, getElem_eq_getElem_toList, List.getElem_set_ne h] + simp only [set, ← getElem_toList, List.getElem_set_ne h] theorem set_set (a : Array α) (i : Nat) (h) (v v' : α) : (a.set i v h).set i v' (by simp [h]) = a.set i v' := by simp [set, List.set_set] @@ -1090,23 +1095,23 @@ theorem size_eq_length_toList (as : Array α) : as.size = as.toList.length := rf @[simp] theorem getElem_range {n : Nat} {x : Nat} (h : x < (Array.range n).size) : (Array.range n)[x] = x := by - simp [getElem_eq_getElem_toList] + simp [← getElem_toList] @[simp] theorem toList_reverse (a : Array α) : a.reverse.toList = a.toList.reverse := by let rec go (as : Array α) (i j hj) (h : i + j + 1 = a.size) (h₂ : as.size = a.size) (H : ∀ k, as.toList[k]? = if i ≤ k ∧ k ≤ j then a.toList[k]? else a.toList.reverse[k]?) (k : Nat) : (reverse.loop as i ⟨j, hj⟩).toList[k]? = a.toList.reverse[k]? := by - rw [reverse.loop]; dsimp; split <;> rename_i h₁ + rw [reverse.loop]; dsimp only; split <;> rename_i h₁ · match j with | j+1 => ?_ simp only [Nat.add_sub_cancel] rw [(go · (i+1) j)] · rwa [Nat.add_right_comm i] · simp [size_swap, h₂] · intro k - rw [← getElem?_eq_getElem?_toList, getElem?_swap] - simp only [H, getElem_eq_getElem_toList, ← List.getElem?_eq_getElem, Nat.le_of_lt h₁, - getElem?_eq_getElem?_toList] + rw [getElem?_toList, getElem?_swap] + simp only [H, ← getElem_toList, ← List.getElem?_eq_getElem, Nat.le_of_lt h₁, + ← getElem?_toList] split <;> rename_i h₂ · simp only [← h₂, Nat.not_le.2 (Nat.lt_succ_self _), Nat.le_refl, and_false] exact (List.getElem?_reverse' (j+1) i (Eq.trans (by simp_arith) h)).symm @@ -1533,7 +1538,7 @@ theorem getElem_append {as bs : Array α} (h : i < (as ++ bs).size) : theorem getElem_append_left {as bs : Array α} {h : i < (as ++ bs).size} (hlt : i < as.size) : (as ++ bs)[i] = as[i] := by - simp only [getElem_eq_getElem_toList] + simp only [← getElem_toList] have h' : i < (as.toList ++ bs.toList).length := by rwa [← length_toList, toList_append] at h conv => rhs; rw [← List.getElem_append_left (bs := bs.toList) (h' := h')] apply List.get_of_eq; rw [toList_append] @@ -1541,7 +1546,7 @@ theorem getElem_append_left {as bs : Array α} {h : i < (as ++ bs).size} (hlt : theorem getElem_append_right {as bs : Array α} {h : i < (as ++ bs).size} (hle : as.size ≤ i) (hlt : i - as.size < bs.size := Nat.sub_lt_left_of_lt_add hle (size_append .. ▸ h)) : (as ++ bs)[i] = bs[i - as.size] := by - simp only [getElem_eq_getElem_toList] + simp only [← getElem_toList] have h' : i < (as.toList ++ bs.toList).length := by rwa [← length_toList, toList_append] at h conv => rhs; rw [← List.getElem_append_right (h₁ := hle) (h₂ := h')] apply List.get_of_eq; rw [toList_append] @@ -1853,9 +1858,9 @@ theorem all_toList {p : α → Bool} (as : Array α) : as.toList.all p = as.all rw [Bool.eq_iff_iff, all_eq_true, List.all_eq_true]; simp only [List.mem_iff_getElem] constructor · intro w i - exact w as[i] ⟨i, i.2, (getElem_eq_getElem_toList i.2).symm⟩ + exact w as[i] ⟨i, i.2, getElem_toList i.2⟩ · rintro w x ⟨r, h, rfl⟩ - rw [← getElem_eq_getElem_toList] + rw [getElem_toList] exact w ⟨r, h⟩ theorem all_eq_true_iff_forall_mem {l : Array α} : l.all p ↔ ∀ x, x ∈ l → p x := by @@ -2018,11 +2023,6 @@ Our goal is to have `simp` "pull `List.toArray` outwards" as much as possible. apply ext' simp -@[simp] theorem set_toArray (l : List α) (i : Fin l.toArray.size) (a : α) : - l.toArray.set i a = (l.set i a).toArray := by - apply ext' - simp - @[simp] theorem uset_toArray (l : List α) (i : USize) (a : α) (h : i.toNat < l.toArray.size) : l.toArray.uset i a h = (l.set i.toNat a).toArray := by apply ext' @@ -2355,15 +2355,6 @@ end Array namespace List -@[deprecated toArray_toList (since := "2024-09-09")] -abbrev toArray_data := @toArray_toList - -@[deprecated "Use the reverse direction of `List.push_toArray`." (since := "2024-09-27")] -theorem toArray_concat {as : List α} {x : α} : - (as ++ [x]).toArray = as.toArray.push x := by - apply ext' - simp - @[deprecated back!_toArray (since := "2024-10-31")] abbrev back_toArray := @back!_toArray @[deprecated setIfInBounds_toArray (since := "2024-11-24")] abbrev setD_toArray := @setIfInBounds_toArray @@ -2372,141 +2363,29 @@ end List namespace Array -@[deprecated getElem_eq_getElem_toList (since := "2024-09-25")] -abbrev getElem_eq_toList_getElem := @getElem_eq_getElem_toList - -@[deprecated getElem_eq_toList_getElem (since := "2024-09-09")] -abbrev getElem_eq_data_getElem := @getElem_eq_getElem_toList - -@[deprecated getElem_eq_toList_getElem (since := "2024-06-12")] -theorem getElem_eq_toList_get (a : Array α) (h : i < a.size) : a[i] = a.toList.get ⟨i, h⟩ := by - simp - -@[deprecated toArray_toList (since := "2024-09-09")] -abbrev toArray_data := @toArray_toList - -@[deprecated length_toList (since := "2024-09-09")] -abbrev data_length := @length_toList - -@[deprecated toList_map (since := "2024-09-09")] -abbrev map_data := @toList_map - @[deprecated foldl_toList_eq_flatMap (since := "2024-10-16")] abbrev foldl_toList_eq_bind := @foldl_toList_eq_flatMap @[deprecated foldl_toList_eq_flatMap (since := "2024-10-16")] abbrev foldl_data_eq_bind := @foldl_toList_eq_flatMap -@[deprecated foldl_toList_eq_map (since := "2024-09-09")] -abbrev foldl_data_eq_map := @foldl_toList_eq_map - -@[deprecated toList_mkArray (since := "2024-09-09")] -abbrev mkArray_data := @toList_mkArray - -@[deprecated mem_toList (since := "2024-09-09")] -abbrev mem_data := @mem_toList - @[deprecated getElem_mem (since := "2024-10-17")] abbrev getElem?_mem := @getElem_mem @[deprecated getElem_fin_eq_getElem_toList (since := "2024-10-17")] abbrev getElem_fin_eq_toList_get := @getElem_fin_eq_getElem_toList -@[deprecated getElem_fin_eq_getElem_toList (since := "2024-09-09")] -abbrev getElem_fin_eq_data_get := @getElem_fin_eq_getElem_toList - -@[deprecated getElem_mem_toList (since := "2024-09-09")] -abbrev getElem_mem_data := @getElem_mem_toList - -@[deprecated getElem?_eq_getElem?_toList (since := "2024-10-17")] -abbrev getElem?_eq_toList_getElem? := @getElem?_eq_getElem?_toList - -@[deprecated getElem?_eq_toList_getElem? (since := "2024-09-30")] -theorem getElem?_eq_toList_get? (a : Array α) (i : Nat) : a[i]? = a.toList.get? i := by - by_cases i < a.size <;> simp_all [getElem?_pos, getElem?_neg, List.get?_eq_get, eq_comm] - -set_option linter.deprecated false in -@[deprecated getElem?_eq_toList_getElem? (since := "2024-09-09")] -abbrev getElem?_eq_data_get? := @getElem?_eq_toList_get? +@[deprecated "Use reverse direction of `getElem?_toList`" (since := "2024-10-17")] +abbrev getElem?_eq_toList_getElem? := @getElem?_toList @[deprecated get?_eq_get?_toList (since := "2024-10-17")] abbrev get?_eq_toList_get? := @get?_eq_get?_toList -@[deprecated get?_eq_toList_get? (since := "2024-09-09")] -abbrev get?_eq_data_get? := @get?_eq_get?_toList - -@[deprecated toList_set (since := "2024-09-09")] -abbrev data_set := @toList_set - -@[deprecated toList_swap (since := "2024-09-09")] -abbrev data_swap := @toList_swap - @[deprecated getElem?_swap (since := "2024-10-17")] abbrev get?_swap := @getElem?_swap -@[deprecated toList_pop (since := "2024-09-09")] abbrev data_pop := @toList_pop - -@[deprecated size_eq_length_toList (since := "2024-09-09")] -abbrev size_eq_length_data := @size_eq_length_toList - -@[deprecated toList_range (since := "2024-09-09")] -abbrev data_range := @toList_range - -@[deprecated toList_reverse (since := "2024-09-30")] -abbrev reverse_toList := @toList_reverse - -@[deprecated mapM_eq_mapM_toList (since := "2024-09-09")] -abbrev mapM_eq_mapM_data := @mapM_eq_mapM_toList - -@[deprecated getElem_modify (since := "2024-08-08")] -theorem get_modify {arr : Array α} {x i} (h : i < (arr.modify x f).size) : - (arr.modify x f).get i h = - if x = i then f (arr.get i (by simpa using h)) else arr.get i (by simpa using h) := by - simp [getElem_modify h] - -@[deprecated toList_filter (since := "2024-09-09")] -abbrev filter_data := @toList_filter - -@[deprecated toList_filterMap (since := "2024-09-09")] -abbrev filterMap_data := @toList_filterMap - -@[deprecated toList_empty (since := "2024-09-09")] -abbrev empty_data := @toList_empty - -@[deprecated getElem_append_left (since := "2024-09-30")] -abbrev get_append_left := @getElem_append_left - -@[deprecated getElem_append_right (since := "2024-09-30")] -abbrev get_append_right := @getElem_append_right - -@[deprecated "Use the reverse direction of `Array.any_toList`" (since := "2024-09-30")] -abbrev any_def := @any_toList - -@[deprecated "Use the reverse direction of `Array.all_toList`" (since := "2024-09-30")] -abbrev all_def := @all_toList - -@[deprecated getElem_extract_loop_lt_aux (since := "2024-09-30")] -abbrev get_extract_loop_lt_aux := @getElem_extract_loop_lt_aux -@[deprecated getElem_extract_loop_lt (since := "2024-09-30")] -abbrev get_extract_loop_lt := @getElem_extract_loop_lt -@[deprecated getElem_extract_loop_ge_aux (since := "2024-09-30")] -abbrev get_extract_loop_ge_aux := @getElem_extract_loop_ge_aux -@[deprecated getElem_extract_loop_ge (since := "2024-09-30")] -abbrev get_extract_loop_ge := @getElem_extract_loop_ge -@[deprecated getElem_extract_aux (since := "2024-09-30")] -abbrev get_extract_aux := @getElem_extract_aux -@[deprecated getElem_extract (since := "2024-09-30")] -abbrev get_extract := @getElem_extract - -@[deprecated getElem_swap_right (since := "2024-09-30")] -abbrev get_swap_right := @getElem_swap_right -@[deprecated getElem_swap_left (since := "2024-09-30")] -abbrev get_swap_left := @getElem_swap_left -@[deprecated getElem_swap_of_ne (since := "2024-09-30")] -abbrev get_swap_of_ne := @getElem_swap_of_ne -@[deprecated getElem_swap (since := "2024-09-30")] -abbrev get_swap := @getElem_swap -@[deprecated getElem_swap' (since := "2024-09-30")] -abbrev get_swap' := @getElem_swap' +@[deprecated getElem_push (since := "2024-10-21")] abbrev get_push := @getElem_push +@[deprecated getElem_push_lt (since := "2024-10-21")] abbrev get_push_lt := @getElem_push_lt +@[deprecated getElem_push_eq (since := "2024-10-21")] abbrev get_push_eq := @getElem_push_eq @[deprecated back!_eq_back? (since := "2024-10-31")] abbrev back_eq_back? := @back!_eq_back? @[deprecated back!_push (since := "2024-10-31")] abbrev back_push := @back!_push @@ -2520,4 +2399,20 @@ abbrev eq_push_pop_back_of_size_ne_zero := @eq_push_pop_back!_of_size_ne_zero @[deprecated getD_get?_setIfInBounds (since := "2024-11-24")] abbrev getD_setD := @getD_get?_setIfInBounds @[deprecated getElem_setIfInBounds (since := "2024-11-24")] abbrev getElem_setD := @getElem_setIfInBounds +@[deprecated List.getElem_toArray (since := "2024-11-29")] +theorem getElem_mk {xs : List α} {i : Nat} (h : i < xs.length) : (Array.mk xs)[i] = xs[i] := rfl + +@[deprecated Array.getElem_toList (since := "2024-12-08")] +theorem getElem_eq_getElem_toList {a : Array α} (h : i < a.size) : a[i] = a.toList[i] := rfl + +@[deprecated Array.getElem?_toList (since := "2024-12-08")] +theorem getElem?_eq_getElem?_toList (a : Array α) (i : Nat) : a[i]? = a.toList[i]? := by + rw [getElem?_def] + split <;> simp_all + +@[deprecated LawfulGetElem.getElem?_def (since := "2024-12-08")] +theorem getElem?_eq {a : Array α} {i : Nat} : + a[i]? = if h : i < a.size then some a[i] else none := by + rw [getElem?_def] + end Array diff --git a/src/Init/Data/Array/TakeDrop.lean b/src/Init/Data/Array/TakeDrop.lean index 6b160b2e0aa4..d654dd40cec2 100644 --- a/src/Init/Data/Array/TakeDrop.lean +++ b/src/Init/Data/Array/TakeDrop.lean @@ -12,7 +12,7 @@ namespace Array theorem exists_of_uset (self : Array α) (i d h) : ∃ l₁ l₂, self.toList = l₁ ++ self[i] :: l₂ ∧ List.length l₁ = i.toNat ∧ (self.uset i d h).toList = l₁ ++ d :: l₂ := by - simpa only [ugetElem_eq_getElem, getElem_eq_getElem_toList, uset, toList_set] using + simpa only [ugetElem_eq_getElem, ← getElem_toList, uset, toList_set] using List.exists_of_set _ end Array diff --git a/src/Init/Data/List/Lemmas.lean b/src/Init/Data/List/Lemmas.lean index 7789ce13fb3a..e48820b9bacd 100644 --- a/src/Init/Data/List/Lemmas.lean +++ b/src/Init/Data/List/Lemmas.lean @@ -220,15 +220,6 @@ We simplify `l[n]!` to `(l[n]?).getD default`. /-! ### getElem? and getElem -/ -@[simp] theorem getElem?_eq_getElem {l : List α} {n} (h : n < l.length) : l[n]? = some l[n] := by - simp only [getElem?_def, h, ↓reduceDIte] - -theorem getElem?_eq_some_iff {l : List α} : l[n]? = some a ↔ ∃ h : n < l.length, l[n] = a := by - simp only [← get?_eq_getElem?, get?_eq_some_iff, get_eq_getElem] - -theorem some_eq_getElem?_iff {l : List α} : some a = l[n]? ↔ ∃ h : n < l.length, l[n] = a := by - rw [eq_comm, getElem?_eq_some_iff] - @[simp] theorem getElem?_eq_none_iff : l[n]? = none ↔ length l ≤ n := by simp only [← get?_eq_getElem?, get?_eq_none_iff] @@ -237,11 +228,20 @@ theorem some_eq_getElem?_iff {l : List α} : some a = l[n]? ↔ ∃ h : n < l.le theorem getElem?_eq_none (h : length l ≤ n) : l[n]? = none := getElem?_eq_none_iff.mpr h -@[simp] theorem some_getElem_eq_getElem?_iff {α} (xs : List α) (i : Nat) (h : i < xs.length) : +@[simp] theorem getElem?_eq_getElem {l : List α} {n} (h : n < l.length) : l[n]? = some l[n] := + getElem?_pos .. + +theorem getElem?_eq_some_iff {l : List α} : l[n]? = some a ↔ ∃ h : n < l.length, l[n] = a := by + simp only [← get?_eq_getElem?, get?_eq_some_iff, get_eq_getElem] + +theorem some_eq_getElem?_iff {l : List α} : some a = l[n]? ↔ ∃ h : n < l.length, l[n] = a := by + rw [eq_comm, getElem?_eq_some_iff] + +@[simp] theorem some_getElem_eq_getElem?_iff (xs : List α) (i : Nat) (h : i < xs.length) : (some xs[i] = xs[i]?) ↔ True := by simp [h] -@[simp] theorem getElem?_eq_some_getElem_iff {α} (xs : List α) (i : Nat) (h : i < xs.length) : +@[simp] theorem getElem?_eq_some_getElem_iff (xs : List α) (i : Nat) (h : i < xs.length) : (xs[i]? = some xs[i]) ↔ True := by simp [h] @@ -253,6 +253,12 @@ theorem getElem_eq_getElem?_get (l : List α) (i : Nat) (h : i < l.length) : l[i] = l[i]?.get (by simp [getElem?_eq_getElem, h]) := by simp [getElem_eq_iff] +theorem isSome_getElem? {l : List α} {n : Nat} : l[n]?.isSome ↔ n < l.length := by + simp + +theorem isNone_getElem? {l : List α} {n : Nat} : l[n]?.isNone ↔ l.length ≤ n := by + simp + @[simp] theorem getElem?_nil {n : Nat} : ([] : List α)[n]? = none := rfl theorem getElem?_cons_zero {l : List α} : (a::l)[0]? = some a := by simp @@ -264,6 +270,13 @@ theorem getElem?_cons_zero {l : List α} : (a::l)[0]? = some a := by simp theorem getElem?_cons : (a :: l)[i]? = if i = 0 then some a else l[i-1]? := by cases i <;> simp +@[simp] theorem getElem_singleton (a : α) (h : i < 1) : [a][i] = a := + match i, h with + | 0, _ => rfl + +theorem getElem?_singleton (a : α) (i : Nat) : [a][i]? = if i = 0 then some a else none := by + simp [getElem?_cons] + /-- If one has `l[i]` in an expression and `h : l = l'`, `rw [h]` will give a "motive it not type correct" error, as it cannot rewrite the @@ -273,10 +286,6 @@ such a rewrite, with `rw [getElem_of_eq h]`. theorem getElem_of_eq {l l' : List α} (h : l = l') {i : Nat} (w : i < l.length) : l[i] = l'[i]'(h ▸ w) := by cases h; rfl -@[simp] theorem getElem_singleton (a : α) (h : i < 1) : [a][i] = a := - match i, h with - | 0, _ => rfl - theorem getElem_zero {l : List α} (h : 0 < l.length) : l[0] = l.head (length_pos.mp h) := match l, h with | _ :: _, _ => rfl @@ -300,12 +309,6 @@ theorem ext_getElem {l₁ l₂ : List α} (hl : length l₁ = length l₂) theorem getElem?_concat_length (l : List α) (a : α) : (l ++ [a])[l.length]? = some a := by simp -theorem isSome_getElem? {l : List α} {n : Nat} : l[n]?.isSome ↔ n < l.length := by - simp - -theorem isNone_getElem? {l : List α} {n : Nat} : l[n]?.isNone ↔ l.length ≤ n := by - simp - /-! ### mem -/ @[simp] theorem not_mem_nil (a : α) : ¬ a ∈ [] := nofun diff --git a/src/Init/Data/List/MapIdx.lean b/src/Init/Data/List/MapIdx.lean index d2592361745e..2e07ff93e339 100644 --- a/src/Init/Data/List/MapIdx.lean +++ b/src/Init/Data/List/MapIdx.lean @@ -237,15 +237,15 @@ theorem getElem?_mapIdx_go : ∀ {l : List α} {arr : Array β} {i : Nat}, if h : i < arr.size then some arr[i] else Option.map (f i) l[i - arr.size]? | [], arr, i => by simp only [mapIdx.go, Array.toListImpl_eq, getElem?_def, Array.length_toList, - Array.getElem_eq_getElem_toList, length_nil, Nat.not_lt_zero, ↓reduceDIte, Option.map_none'] + ← Array.getElem_toList, length_nil, Nat.not_lt_zero, ↓reduceDIte, Option.map_none'] | a :: l, arr, i => by rw [mapIdx.go, getElem?_mapIdx_go] simp only [Array.size_push] split <;> split · simp only [Option.some.injEq] - rw [Array.getElem_eq_getElem_toList] + rw [← Array.getElem_toList] simp only [Array.push_toList] - rw [getElem_append_left, Array.getElem_eq_getElem_toList] + rw [getElem_append_left, ← Array.getElem_toList] · have : i = arr.size := by omega simp_all · omega diff --git a/src/Init/GetElem.lean b/src/Init/GetElem.lean index 992b32990c24..31bc54bd99c2 100644 --- a/src/Init/GetElem.lean +++ b/src/Init/GetElem.lean @@ -118,12 +118,16 @@ instance (priority := low) [GetElem coll idx elem valid] [∀ xs i, Decidable (v GetElem? coll idx elem valid where getElem? xs i := decidableGetElem? xs i -theorem getElem_congr_coll [GetElem coll idx elem valid] {c d : coll} {i : idx} {h : valid c i} - (h' : c = d) : c[i] = d[i]'(h' ▸ h) := by - cases h'; rfl +theorem getElem_congr [GetElem coll idx elem valid] {c d : coll} (h : c = d) + {i j : idx} (h' : i = j) (w : valid c i) : c[i] = d[j]'(h' ▸ h ▸ w) := by + cases h; cases h'; rfl + +theorem getElem_congr_coll [GetElem coll idx elem valid] {c d : coll} {i : idx} {w : valid c i} + (h : c = d) : c[i] = d[i]'(h ▸ w) := by + cases h; rfl -theorem getElem_congr [GetElem coll idx elem valid] {c : coll} {i j : idx} {h : valid c i} - (h' : i = j) : c[i] = c[j]'(h' ▸ h) := by +theorem getElem_congr_idx [GetElem coll idx elem valid] {c : coll} {i j : idx} {w : valid c i} + (h' : i = j) : c[i] = c[j]'(h' ▸ w) := by cases h'; rfl class LawfulGetElem (cont : Type u) (idx : Type v) (elem : outParam (Type w)) @@ -216,13 +220,9 @@ instance : GetElem (List α) Nat α fun as i => i < as.length where @[simp] theorem getElem_cons_zero (a : α) (as : List α) (h : 0 < (a :: as).length) : getElem (a :: as) 0 h = a := by rfl -@[deprecated getElem_cons_zero (since := "2024-06-12")] abbrev cons_getElem_zero := @getElem_cons_zero - @[simp] theorem getElem_cons_succ (a : α) (as : List α) (i : Nat) (h : i + 1 < (a :: as).length) : getElem (a :: as) (i+1) h = getElem as i (Nat.lt_of_succ_lt_succ h) := by rfl -@[deprecated getElem_cons_succ (since := "2024-06-12")] abbrev cons_getElem_succ := @getElem_cons_succ - @[simp] theorem getElem_mem : ∀ {l : List α} {n} (h : n < l.length), l[n]'h ∈ l | _ :: _, 0, _ => .head .. | _ :: l, _+1, _ => .tail _ (getElem_mem (l := l) ..) diff --git a/src/Std/Data/DHashMap/Internal/WF.lean b/src/Std/Data/DHashMap/Internal/WF.lean index a18eb53c2cdc..d0c9b83a0550 100644 --- a/src/Std/Data/DHashMap/Internal/WF.lean +++ b/src/Std/Data/DHashMap/Internal/WF.lean @@ -216,7 +216,7 @@ theorem expand.go_eq [BEq α] [Hashable α] [PartialEquivBEq α] (source : Array refine ih.trans ?_ simp only [Array.get_eq_getElem, AssocList.foldl_eq, Array.toList_set] rw [List.drop_eq_getElem_cons hi, List.flatMap_cons, List.foldl_append, - List.drop_set_of_lt _ _ (by omega), Array.getElem_eq_getElem_toList] + List.drop_set_of_lt _ _ (by omega), Array.getElem_toList] · next i source target hi => rw [expand.go_neg hi, List.drop_eq_nil_of_le, flatMap_nil, foldl_nil] rwa [Array.size_eq_length_toList, Nat.not_lt] at hi diff --git a/src/Std/Tactic/BVDecide/LRAT/Internal/Clause.lean b/src/Std/Tactic/BVDecide/LRAT/Internal/Clause.lean index a5e9f2c98f32..a4052c900dec 100644 --- a/src/Std/Tactic/BVDecide/LRAT/Internal/Clause.lean +++ b/src/Std/Tactic/BVDecide/LRAT/Internal/Clause.lean @@ -297,7 +297,7 @@ theorem ofArray_eq (arr : Array (Literal (PosFin n))) dsimp; omega rw [List.getElem?_eq_getElem i_in_bounds, List.getElem?_eq_getElem i_in_bounds'] simp only [List.get_eq_getElem, Nat.zero_add] at h - rw [← Array.getElem_eq_getElem_toList] + rw [Array.getElem_toList] simp [h] · have arr_data_length_le_i : arr.toList.length ≤ i := by dsimp; omega diff --git a/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/Lemmas.lean b/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/Lemmas.lean index 02edc9f085f2..410e68e7b36a 100644 --- a/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/Lemmas.lean +++ b/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/Lemmas.lean @@ -497,7 +497,7 @@ theorem deleteOne_preserves_strongAssignmentsInvariant {n : Nat} (f : DefaultFor conv => rhs; rw [Array.size_mk] exact hbound simp only [getElem!, id_eq_idx, Array.length_toList, idx_in_bounds2, ↓reduceDIte, - Fin.eta, Array.get_eq_getElem, Array.getElem_eq_getElem_toList, decidableGetElem?] at heq + Fin.eta, Array.get_eq_getElem, ← Array.getElem_toList, decidableGetElem?] at heq rw [hidx, hl] at heq simp only [unit, Option.some.injEq, DefaultClause.mk.injEq, List.cons.injEq, and_true] at heq simp only [← heq] at l_ne_b @@ -530,7 +530,7 @@ theorem deleteOne_preserves_strongAssignmentsInvariant {n : Nat} (f : DefaultFor conv => rhs; rw [Array.size_mk] exact hbound simp only [getElem!, id_eq_idx, Array.length_toList, idx_in_bounds2, ↓reduceDIte, - Fin.eta, Array.get_eq_getElem, Array.getElem_eq_getElem_toList, decidableGetElem?] at heq + Fin.eta, Array.get_eq_getElem, ← Array.getElem_toList, decidableGetElem?] at heq rw [hidx, hl] at heq simp only [unit, Option.some.injEq, DefaultClause.mk.injEq, List.cons.injEq, and_true] at heq have i_eq_l : i = l.1 := by rw [← heq] @@ -590,7 +590,7 @@ theorem deleteOne_preserves_strongAssignmentsInvariant {n : Nat} (f : DefaultFor conv => rhs; rw [Array.size_mk] exact hbound simp only [getElem!, id_eq_idx, Array.length_toList, idx_in_bounds2, ↓reduceDIte, - Fin.eta, Array.get_eq_getElem, Array.getElem_eq_getElem_toList, decidableGetElem?] at heq + Fin.eta, Array.get_eq_getElem, ← Array.getElem_toList, decidableGetElem?] at heq rw [hidx] at heq simp only [Option.some.injEq] at heq rw [← heq] at hl diff --git a/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RatAddSound.lean b/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RatAddSound.lean index 1e5dca56a1f8..5143b8163073 100644 --- a/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RatAddSound.lean +++ b/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RatAddSound.lean @@ -461,7 +461,7 @@ theorem existsRatHint_of_ratHintsExhaustive {n : Nat} (f : DefaultFormula n) constructor · rw [← Array.mem_toList] apply Array.getElem_mem_toList - · rw [← Array.getElem_eq_getElem_toList] at c'_in_f + · rw [Array.getElem_toList] at c'_in_f simp only [getElem!, Array.getElem_range, i_lt_f_clauses_size, dite_true, c'_in_f, DefaultClause.contains_iff, Array.get_eq_getElem, decidableGetElem?] simpa [Clause.toList] using negPivot_in_c' @@ -472,8 +472,8 @@ theorem existsRatHint_of_ratHintsExhaustive {n : Nat} (f : DefaultFormula n) dsimp at * omega simp only [List.get_eq_getElem, Array.toList_map, Array.length_toList, List.getElem_map] at h' - rw [← Array.getElem_eq_getElem_toList] at h' - rw [← Array.getElem_eq_getElem_toList] at c'_in_f + rw [Array.getElem_toList] at h' + rw [Array.getElem_toList] at c'_in_f exists ⟨j.1, j_in_bounds⟩ simp [getElem!, h', i_lt_f_clauses_size, dite_true, c'_in_f, decidableGetElem?] diff --git a/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RupAddResult.lean b/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RupAddResult.lean index 2407b761393e..4ba79bcc390f 100644 --- a/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RupAddResult.lean +++ b/src/Std/Tactic/BVDecide/LRAT/Internal/Formula/RupAddResult.lean @@ -1133,25 +1133,24 @@ theorem nodup_derivedLits {n : Nat} (f : DefaultFormula n) specialize h3 ⟨j.1, j_in_bounds⟩ j_ne_k simp only [derivedLits_arr_def, Fin.getElem_fin] at li_eq_lj simp only [Fin.getElem_fin, derivedLits_arr_def, ne_eq, li, li_eq_lj] at h3 - simp only [List.get_eq_getElem, Array.getElem_eq_getElem_toList, not_true_eq_false] at h3 + simp only [List.get_eq_getElem, ← Array.getElem_toList, not_true_eq_false] at h3 · next k_ne_i => have i_ne_k : ⟨i.1, i_in_bounds⟩ ≠ k := by intro i_eq_k; simp only [← i_eq_k, not_true] at k_ne_i specialize h3 ⟨i.1, i_in_bounds⟩ i_ne_k - simp +decide [Fin.getElem_fin, derivedLits_arr_def, ne_eq, - Array.getElem_eq_getElem_toList, li] at h3 + simp +decide [Fin.getElem_fin, derivedLits_arr_def, ne_eq, li] at h3 · by_cases li.2 = true · next li_eq_true => have i_ne_k2 : ⟨i.1, i_in_bounds⟩ ≠ k2 := by intro i_eq_k2 rw [← i_eq_k2] at k2_eq_false simp only [List.get_eq_getElem] at k2_eq_false - simp [derivedLits_arr_def, Array.getElem_eq_getElem_toList, k2_eq_false, li] at li_eq_true + simp [derivedLits_arr_def, k2_eq_false, li] at li_eq_true have j_ne_k2 : ⟨j.1, j_in_bounds⟩ ≠ k2 := by intro j_eq_k2 rw [← j_eq_k2] at k2_eq_false simp only [List.get_eq_getElem] at k2_eq_false - simp only [derivedLits_arr_def, Fin.getElem_fin, Array.getElem_eq_getElem_toList] at li_eq_lj - simp [derivedLits_arr_def, Array.getElem_eq_getElem_toList, k2_eq_false, li_eq_lj, li] at li_eq_true + simp only [derivedLits_arr_def, Fin.getElem_fin] at li_eq_lj + simp [derivedLits_arr_def, k2_eq_false, li_eq_lj, li] at li_eq_true by_cases ⟨i.1, i_in_bounds⟩ = k1 · next i_eq_k1 => have j_ne_k1 : ⟨j.1, j_in_bounds⟩ ≠ k1 := by @@ -1160,12 +1159,11 @@ theorem nodup_derivedLits {n : Nat} (f : DefaultFormula n) simp only [Fin.mk.injEq] at i_eq_k1 exact i_ne_j (Fin.eq_of_val_eq i_eq_k1) specialize h3 ⟨j.1, j_in_bounds⟩ j_ne_k1 j_ne_k2 - simp [li, li_eq_lj, derivedLits_arr_def, Array.getElem_eq_getElem_toList] at h3 + simp [li, li_eq_lj, derivedLits_arr_def] at h3 · next i_ne_k1 => specialize h3 ⟨i.1, i_in_bounds⟩ i_ne_k1 i_ne_k2 apply h3 - simp +decide only [Fin.getElem_fin, Array.getElem_eq_getElem_toList, - ne_eq, derivedLits_arr_def, li] + simp +decide only [Fin.getElem_fin, ne_eq, derivedLits_arr_def, li] rfl · next li_eq_false => simp only [Bool.not_eq_true] at li_eq_false @@ -1173,13 +1171,13 @@ theorem nodup_derivedLits {n : Nat} (f : DefaultFormula n) intro i_eq_k1 rw [← i_eq_k1] at k1_eq_true simp only [List.get_eq_getElem] at k1_eq_true - simp [derivedLits_arr_def, Array.getElem_eq_getElem_toList, k1_eq_true, li] at li_eq_false + simp [derivedLits_arr_def, k1_eq_true, li] at li_eq_false have j_ne_k1 : ⟨j.1, j_in_bounds⟩ ≠ k1 := by intro j_eq_k1 rw [← j_eq_k1] at k1_eq_true simp only [List.get_eq_getElem] at k1_eq_true - simp only [derivedLits_arr_def, Fin.getElem_fin, Array.getElem_eq_getElem_toList] at li_eq_lj - simp [derivedLits_arr_def, Array.getElem_eq_getElem_toList, k1_eq_true, li_eq_lj, li] at li_eq_false + simp only [derivedLits_arr_def, Fin.getElem_fin] at li_eq_lj + simp [derivedLits_arr_def, k1_eq_true, li_eq_lj, li] at li_eq_false by_cases ⟨i.1, i_in_bounds⟩ = k2 · next i_eq_k2 => have j_ne_k2 : ⟨j.1, j_in_bounds⟩ ≠ k2 := by @@ -1188,10 +1186,10 @@ theorem nodup_derivedLits {n : Nat} (f : DefaultFormula n) simp only [Fin.mk.injEq] at i_eq_k2 exact i_ne_j (Fin.eq_of_val_eq i_eq_k2) specialize h3 ⟨j.1, j_in_bounds⟩ j_ne_k1 j_ne_k2 - simp [li, li_eq_lj, derivedLits_arr_def, Array.getElem_eq_getElem_toList] at h3 + simp [li, li_eq_lj, derivedLits_arr_def] at h3 · next i_ne_k2 => specialize h3 ⟨i.1, i_in_bounds⟩ i_ne_k1 i_ne_k2 - simp +decide [Array.getElem_eq_getElem_toList, derivedLits_arr_def, li] at h3 + simp +decide [derivedLits_arr_def, li] at h3 theorem restoreAssignments_performRupCheck_base_case {n : Nat} (f : DefaultFormula n) (f_assignments_size : f.assignments.size = n) @@ -1225,7 +1223,7 @@ theorem restoreAssignments_performRupCheck_base_case {n : Nat} (f : DefaultFormu constructor · apply Nat.zero_le · constructor - · simp only [derivedLits_arr_def, Fin.getElem_fin, Array.getElem_eq_getElem_toList, ← j_eq_i] + · simp only [derivedLits_arr_def, Fin.getElem_fin, ← j_eq_i] rfl · apply And.intro h1 ∘ And.intro h2 intro k _ k_ne_j @@ -1237,7 +1235,7 @@ theorem restoreAssignments_performRupCheck_base_case {n : Nat} (f : DefaultFormu apply Fin.ne_of_val_ne simp only exact Fin.val_ne_of_ne k_ne_j - simp only [Fin.getElem_fin, Array.getElem_eq_getElem_toList, ne_eq, derivedLits_arr_def] + simp only [Fin.getElem_fin, ne_eq, derivedLits_arr_def] exact h3 ⟨k.1, k_in_bounds⟩ k_ne_j · apply Or.inr ∘ Or.inr have j1_lt_derivedLits_arr_size : j1.1 < derivedLits_arr.size := by @@ -1251,11 +1249,11 @@ theorem restoreAssignments_performRupCheck_base_case {n : Nat} (f : DefaultFormu ⟨j2.1, j2_lt_derivedLits_arr_size⟩, i_gt_zero, Nat.zero_le j1.1, Nat.zero_le j2.1, ?_⟩ constructor - · simp only [derivedLits_arr_def, Fin.getElem_fin, Array.getElem_eq_getElem_toList, ← j1_eq_i] + · simp only [derivedLits_arr_def, Fin.getElem_fin, ← j1_eq_i] rw [← j1_eq_true] rfl · constructor - · simp only [derivedLits_arr_def, Fin.getElem_fin, Array.getElem_eq_getElem_toList, ← j2_eq_i] + · simp only [derivedLits_arr_def, Fin.getElem_fin, ← j2_eq_i] rw [← j2_eq_false] rfl · apply And.intro h1 ∘ And.intro h2 @@ -1272,7 +1270,7 @@ theorem restoreAssignments_performRupCheck_base_case {n : Nat} (f : DefaultFormu apply Fin.ne_of_val_ne simp only exact Fin.val_ne_of_ne k_ne_j2 - simp only [Fin.getElem_fin, Array.getElem_eq_getElem_toList, ne_eq, derivedLits_arr_def] + simp only [Fin.getElem_fin, ne_eq, derivedLits_arr_def] exact h3 ⟨k.1, k_in_bounds⟩ k_ne_j1 k_ne_j2 theorem restoreAssignments_performRupCheck {n : Nat} (f : DefaultFormula n) (f_assignments_size : f.assignments.size = n)