@@ -128,7 +128,6 @@ theorem nonOverlappingWithLast_of_singleton (l r : NonemptyInterval Char) (h : I
128128 split at heq <;> simp_all
129129 unfold Interval.nonOverlapping at h
130130 rename_i last' _ _ _
131- have heq' : List.get #[l].data ⟨0 , by simp⟩ = l := List.singleton_val l (by simp)
132131 simp_all
133132
134133theorem nonOverlapping_of_push (acc : Acc) (next : NonemptyInterval Char)
@@ -182,18 +181,6 @@ theorem Array.eq_head_of_get_first (arr : Array α) (h1 : 0 < arr.size)
182181 (h2 : arr.data = head :: tail) : head = arr.get ⟨0 , h1⟩ :=
183182 List.eq_head_of_get_first arr.data h1 h2
184183
185- theorem List.eq_succ_of_tail_nth (arr : List α) (h1 : i+1 < arr.length)
186- (h2 : arr = head :: tail) (h3 : i < tail.length)
187- : tail.get ⟨i, h3⟩ = arr.get ⟨i+1 , h1⟩ := by
188- cases h2
189- have h : (head :: tail).get ⟨i+1 , h1⟩ = tail.get ⟨i, h3⟩ := List.get_cons_succ
190- exact h.symm
191-
192- theorem Array.eq_succ_of_tail_nth (arr : Array α) (h1 : i+1 < arr.size)
193- (h2 : arr.data = head :: tail) (h3 : i < tail.length)
194- : tail.get ⟨i, h3⟩ = arr.get ⟨i+1 , h1⟩ :=
195- List.eq_succ_of_tail_nth arr.data h1 h2 h3
196-
197184theorem nonOverlapping_of_nth (ranges : Array $ NonemptyInterval Char) (n : Nat)
198185 (h1 : 0 < n) (h2 : n+1 < Array.size ranges) (h3: ranges.data = head :: tail)
199186 (h4 : ∀ (i : Nat) (h : i < List.length tail-1 ),
@@ -211,18 +198,10 @@ theorem nonOverlapping_of_nth (ranges : Array $ NonemptyInterval Char) (n : Nat)
211198 have ht2 : n-1 < tail.length := by omega
212199 have ht3 : n-1 +1 < tail.length := by simp [hps, ht0]
213200 have : Interval.nonOverlapping (tail.get ⟨n-1 , ht2⟩) (tail.get ⟨n-1 +1 , ht3⟩) := h4 (n-1 ) ht1
214- have : tail.get ⟨n-1 , ht2⟩ = ranges.get ⟨n, hlt⟩ := by
215- let i := n-1
216- have h : i+1 < ranges.size := by simp [hps, hlt]
217- simp [Array.eq_succ_of_tail_nth ranges h h3 ht2]
218- simp [hps]
219- have : tail.get ⟨n-1 +1 , ht3⟩ = ranges.get ⟨n+1 , hf⟩ := by
220- let i := n-1 +1
221- have hi : i = n-1 +1 := by simp
222- have hi' : i = n := by simp_all only [hi]
223- have h : i < tail.length := by simp_all [hps, ht0]
224- simp [Array.eq_succ_of_tail_nth ranges (by rw [← hi'] at hf; simp_all) h3 h]
225- simp_all [hps]
201+ have : tail.get ⟨n-1 , ht2⟩ = ranges.get ⟨n, hlt⟩ :=
202+ List.eq_succ_of_tail_nth_pred ranges.data hne hlt h3 ht2
203+ have : tail.get ⟨n, ht0⟩ = ranges.get ⟨n+1 , hf⟩ :=
204+ List.eq_succ_of_tail_nth ranges.data (by simp [h2]) h3 ht0
226205 simp_all
227206
228207theorem nonOverlapping_of_pred (ranges : Array $ NonemptyInterval Char) (i : Fin (Array.size ranges))
@@ -250,7 +229,7 @@ theorem nonOverlapping_of_pred (ranges : Array $ NonemptyInterval Char) (i : Fin
250229 have hx1 : 0 < ranges.size := by simp [Nat.lt_trans h hf]
251230 have hx2 : 0 < tail.length := by cases tail <;> simp_all
252231 have : head = ranges.get ⟨0 , hx1⟩ := Array.eq_head_of_get_first ranges hx1 heq
253- have : tail.get ⟨0 , hx2⟩ = ranges.get ⟨1 , hf⟩ := Array .eq_succ_of_tail_nth ranges hf heq hx2
232+ have : tail.get ⟨0 , hx2⟩ = ranges.get ⟨1 , hf⟩ := List .eq_succ_of_tail_nth ranges.data hf heq hx2
254233 simp_all
255234 | ⟨n+2 , hf⟩ =>
256235 have hx1 : n+1 < ranges.size := by simp [Nat.lt_trans _ hf]
@@ -266,16 +245,3 @@ theorem nonOverlappingWithLast_of_push(acc : Acc)
266245 rename_i last next heq _
267246 unfold Array.last? at heq
268247 split at heq <;> try simp_all
269- have hne : acc.set.intervals.data ++ [l] ≠ [] := by simp_all
270- have h : List.getLast (acc.set.intervals.data ++ [l]) hne
271- = List.get (acc.set.intervals.data ++ [l]) ⟨acc.set.intervals.data.length, (by simp_all)⟩ := by
272- have h : List.get (acc.set.intervals.data ++ [l]) ⟨acc.set.intervals.data.length, (by simp_all)⟩
273- = List.get (acc.set.intervals.data ++ [l])
274- ⟨(acc.set.intervals.data ++ [l]).length-1 , (by simp_all)⟩ := by
275- simp_all
276- rw [h]
277- rw [List.getLast_eq_get (acc.set.intervals.data ++ [l]) hne]
278- rw [← h] at heq
279- simp [List.getLast_append] at heq
280- rw [heq] at h3
281- simp [h3]
0 commit comments