Skip to content

Commit 77bbf59

Browse files
committed
feat: update to v4.10.0
1 parent 0f11bc6 commit 77bbf59

File tree

8 files changed

+46
-62
lines changed

8 files changed

+46
-62
lines changed

Regex/Backtrack.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def next (cp : CharPos) : CharPos :=
9393
else
9494
match cp.curr? with
9595
| some c =>
96-
let nextPos : String.Pos := ⟨cp.pos.byteIdx + (String.csize c)
96+
let nextPos : String.Pos := ⟨cp.pos.byteIdx + c.utf8Size
9797
{cp with pos := nextPos, prev? := cp.curr?, curr? := get? cp.s nextPos}
9898
| none => cp
9999

@@ -1067,9 +1067,9 @@ private def slotsWithUnanchoredPrefix (s : Substring) («at» : String.Pos) (nfa
10671067
match (msgs, slots) with
10681068
| (msgs, #[]) =>
10691069
let c : Char := s.get «at»
1070-
let size := c.utf8Size.toNat
1070+
let size := c.utf8Size
10711071
have : s.stopPos.byteIdx - (at.byteIdx + size) < s.stopPos.byteIdx - at.byteIdx := by
1072-
have : 0 < c.utf8Size.toNat := Char.utf8Size_pos c
1072+
have : 0 < c.utf8Size := Char.utf8Size_pos c
10731073
have ha : at.byteIdx < s.stopPos.byteIdx := by omega
10741074
have hb : at.byteIdx < at.byteIdx + size := by omega
10751075
simp [Nat.sub_lt_sub_left ha hb]

Regex/Data/Array/Lemmas.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ theorem last?_eq_getLast (a : Array α) (h1: Array.last? a = some last) (h2 : a.
7777
: List.getLast a.data h2 = last := by
7878
unfold Array.last? at h1
7979
split at h1 <;> simp_all
80-
rw [← List.getLast_eq_get a.data h2] at h1
81-
simp [h1]
80+
rw [← h1]
81+
simp [List.getLast_eq_get a.data h2]
8282

8383
theorem lt_of_pop?_eq_last? {arr : Array α} (h : Array.pop? arr = some (last, arr'))
8484
: 0 < arr.data.length := by
@@ -94,7 +94,7 @@ theorem get_last_of_pop? {arr : Array α} (h1 : Array.pop? arr = some (last, arr
9494
theorem concat_of_pop? {arr : Array α} (h : Array.pop? arr = some (last, arr'))
9595
: arr.data = arr'.data ++ [last] := by
9696
have hlt : 0 < arr.data.length := by simp_all[Array.lt_of_pop?_eq_last? h]
97-
have hlt : arr.data.length - 1 < arr.data.length := Nat.pred_lt' hlt
97+
have hlt : arr.data.length - 1 < arr.data.length := Nat.pred_lt_of_lt hlt
9898
have hlast : List.get arr.data ⟨arr.data.length - 1, hlt⟩ = last :=
9999
Array.get_last_of_pop? h hlt
100100
unfold Array.pop? at h
@@ -108,4 +108,4 @@ theorem concat_of_pop? {arr : Array α} (h : Array.pop? arr = some (last, arr'))
108108
rw [← hy] at hr
109109
rw [hr]
110110
simp [List.eq_of_dropLast_eq_last_eq hz hlt (by simp_all)
111-
(by rw [List.get_last_of_concat _]; rw [hlast])]
111+
(by rw [List.get_last_of_concat _]; rw [hlast]; simp_all)]

Regex/Data/List/Lemmas.lean

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ namespace List
1010

1111
theorem singleton_val_of (a : α) (arr : List α) (h1 : arr = [a]) (h2 : 0 < List.length arr)
1212
: List.get arr ⟨0, h2⟩ = a := by
13-
unfold List.get
14-
split <;> simp_all
15-
unfold List.get
16-
split <;> simp_all
13+
simp_all [List.get]
1714

1815
theorem singleton_val (a : α) (h : 0 < List.length [a])
1916
: List.get [a] ⟨0, h⟩ = a := by
@@ -37,8 +34,8 @@ theorem eq_of_dropLast_eq_last_eq {l1 l2 : List α} (hd : List.dropLast l1 = Lis
3734
List.ext_get hl fun n h1 h2 =>
3835
if hx1 : n < l1.dropLast.length then by
3936
have hx2 : n < l2.dropLast.length := Nat.lt_of_lt_of_eq hx1 hdl
40-
have hy1 : l1.dropLast.get ⟨n, hx1⟩ = l1.get ⟨n, h1⟩ := List.get_dropLast l1 ⟨n, hx1
41-
have hy2 : l2.dropLast.get ⟨n, hx2⟩ = l2.get ⟨n, h2⟩ := List.get_dropLast l2 ⟨n, hx2
37+
have hy1 : l1.dropLast.get ⟨n, hx1⟩ = l1.get ⟨n, h1⟩ := List.getElem_dropLast l1 n hx1
38+
have hy2 : l2.dropLast.get ⟨n, hx2⟩ = l2.get ⟨n, h2⟩ := List.getElem_dropLast l2 n hx2
4239
have hy3 : l1.dropLast.get ⟨n, hx1⟩ = l2.dropLast.get ⟨n, hx2⟩ := List.get_of_fun_eq hd ⟨n, hx1⟩
4340
rw [hy3, hy2] at hy1
4441
rw [hy1]
@@ -59,6 +56,22 @@ theorem get_last_of_concat {l : List α} (h : (l ++ [last]).length - 1 < (l ++ [
5956
: List.get (l ++ [last]) ⟨(l ++ [last]).length - 1, h⟩ = last := by
6057
simp [List.get_last _]
6158

59+
theorem eq_succ_of_tail_nth {head : α} {tail : List α} (data : List α) (h1 : n+1 < data.length)
60+
(h2 : data = head :: tail) (h3 : n < tail.length)
61+
: tail.get ⟨n, h3⟩ = data.get ⟨n+1, h1⟩ := by
62+
cases h2
63+
have h : (head :: tail).get ⟨n+1, h1⟩ = tail.get ⟨n, h3⟩ := List.get_cons_succ
64+
exact h.symm
65+
66+
theorem eq_succ_of_tail_nth_pred {head : α} {tail : List α} (data : List α) (h0 : n ≠ 0)
67+
(h1 : n < data.length) (h2 : data = head :: tail) (h3 : n - 1 < tail.length)
68+
: tail.get ⟨n - 1, h3⟩ = data.get ⟨n, h1⟩ := by
69+
have hps : n - 1 + 1 = n := Nat.succ_pred (by simp_all)
70+
have hpl : n - 1 + 1 < data.length := by simp only [hps, h1]
71+
have : data.get ⟨n, h1⟩ = data.get ⟨n - 1 + 1, hpl⟩ := by simp_all
72+
rw [this]
73+
exact List.eq_succ_of_tail_nth data hpl h2 h3
74+
6275
/- see Mathlib/Data/List/Chain.lean -/
6376
theorem chain_split {a b : α} {l₁ l₂ : List α} :
6477
Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by
@@ -86,7 +99,7 @@ theorem chain_iff_get {R} : ∀ {a : α} {l : List α}, Chain R a l ↔
8699
exact R
87100
intro i w
88101
cases i
89-
· simp [h0]
102+
· apply h0
90103
· rename_i i
91104
exact h i (by simp only [length_cons] at w; omega)
92105
rintro ⟨h0, h⟩; constructor

Regex/Data/UInt/Basic.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ theorem toNat_sub_toNat {n m : UInt32} (hmn : m.val ≤ n.val) (h2 : n.val < UIn
7070
have h : (n.val.val + (UInt32.size - m.val.val)) % UInt32.size
7171
= n.val.val - m.val.val := Nat.mod_sub_eq_of_lt hmn h1 (Nat.le_of_lt h2)
7272
simp [h]
73+
have : n.val.val + (UInt32.size - m.val.val) = (UInt32.size - m.val.val) + n.val.val := by simp_arith
74+
rw [← this]
75+
simp [h]
7376

7477
theorem toUInt32_add_toUInt32 (n m : Nat) (hn : n < UInt32.size) (hm : m < UInt32.size)
7578
(hnm : n + m < UInt32.size) : n.toUInt32 + m.toUInt32 = (n + m).toUInt32 := by

Regex/Interval/Lemmas.lean

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -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

134133
theorem 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-
197184
theorem 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

228207
theorem 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]

lake-manifest.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
{"version": "1.0.0",
1+
{"version": "1.1.0",
22
"packagesDir": ".lake/packages",
33
"packages":
44
[{"url": "https://github.com/fgdorais/lean4-unicode-basic.git",
55
"type": "git",
66
"subDir": null,
7-
"rev": "48563d6b516f178851bd9abad05ebfaba84a3ee8",
7+
"scope": "",
8+
"rev": "6c260d58b9c9fe49f1312a6ecc0437de84e2fb8d",
89
"name": "UnicodeBasic",
910
"manifestFile": "lake-manifest.json",
10-
"inputRev": "48563d6b516f178851bd9abad05ebfaba84a3ee8",
11+
"inputRev": "6c260d58b9c9fe49f1312a6ecc0437de84e2fb8d",
1112
"inherited": false,
1213
"configFile": "lakefile.lean"},
1314
{"url": "https://github.com/leanprover-community/batteries",
1415
"type": "git",
1516
"subDir": null,
16-
"rev": "54bb04c3119f24fde14b9068c4b2e69db52a1450",
17+
"scope": "",
18+
"rev": "0f3e143dffdc3a591662f3401ce1d7a3405227c0",
1719
"name": "batteries",
1820
"manifestFile": "lake-manifest.json",
19-
"inputRev": "v4.9.0",
21+
"inputRev": "v4.10.0",
2022
"inherited": false,
2123
"configFile": "lakefile.lean"}],
2224
"name": "Regex",

lakefile.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ open Lake DSL
33

44
meta if get_config? env = some "dev" then
55
require «doc-gen4» from git "https://github.com/leanprover/doc-gen4"
6-
@ "v4.9.0"
6+
@ "v4.10.0"
77

88
require UnicodeBasic from git "https://github.com/fgdorais/lean4-unicode-basic.git"
9-
@ "48563d6b516f178851bd9abad05ebfaba84a3ee8"
9+
@ "6c260d58b9c9fe49f1312a6ecc0437de84e2fb8d"
1010

11-
require batteries from git "https://github.com/leanprover-community/batteries" @ "v4.9.0"
11+
require batteries from git "https://github.com/leanprover-community/batteries" @ "v4.10.0"
1212

1313
package «Regex» {
1414
}

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:v4.9.0
1+
leanprover/lean4:v4.10.0

0 commit comments

Comments
 (0)