Skip to content

Commit 9e8df84

Browse files
committed
update to Lean 4.22.0-rc3 and fixed linter warnings
1 parent 0e28e22 commit 9e8df84

13 files changed

+49
-51
lines changed

Fad/Assignment02.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ theorem sum_snoc (ms : List Nat) (n : Nat) :
5454
unfold sum
5555
induction ms with
5656
| nil =>
57-
simp [snoc, sum]
57+
simp [snoc]
5858
| cons m ms ih =>
5959
simp[snoc, ih]
6060
rw [<- Nat.add_assoc, Nat.add_comm m n, Nat.add_assoc]
@@ -72,9 +72,9 @@ theorem sum_append (ms ns : List Nat) :
7272
unfold sum
7373
induction ms with
7474
| nil =>
75-
simp [sum, List.foldr]
75+
simp [List.foldr]
7676
| cons m ms ih =>
77-
simp[sum]
77+
simp
7878
rw [<- foldr_append, ih, Nat.add_assoc]
7979

8080
-- sum (reverse ns) = sum ns --

Fad/Chapter1-Ex.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ termination_by xs.length
189189

190190

191191
def last₁ {a : Type} (as : List a) (ok : as ≠ []) : a :=
192-
as.reverse.head (by simp [List.length_reverse]; assumption)
192+
as.reverse.head (by simp ; assumption)
193193

194194
def init₁ {a : Type} : List a → List a :=
195195
List.reverse ∘ List.tail ∘ List.reverse
@@ -229,7 +229,7 @@ example {a b : Type} (f : b → a → b) (e : b) :
229229
List.map (List.foldl f e) ∘ inits = scanl f e := by
230230
funext xs
231231
induction xs generalizing e with
232-
| nil => simp [map, inits, foldl, scanl]
232+
| nil => simp [inits, scanl]
233233
| cons x xs ih =>
234234
rw [Function.comp, inits]; simp
235235
rw [foldl_comp, scanl]
@@ -242,9 +242,9 @@ example {α β : Type} (f : α → β → β) (e : β) :
242242
induction xs with
243243
| nil =>
244244
simp [Function.comp]
245-
simp [tails, map, List.scanr, List.foldr]
245+
simp [tails, List.foldr]
246246
| cons y ys ih =>
247-
simp [List.map, tails]
247+
simp [tails]
248248
rw [Function.comp] at ih
249249
rw [ih]
250250

Fad/Chapter1.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,15 @@ theorem map_map {α β γ : Type} (f : β → γ) (g : α → β) :
350350
induction as with
351351
| nil => rfl
352352
| cons x xs ih =>
353-
simp [List.map, ih]
353+
simp [List.map]
354354

355355

356356
theorem concatMap_map {α β : Type} (f : α → List β) (g : β → α) :
357357
concatMap f ∘ List.map g = concatMap (f ∘ g) := by
358358
funext as
359359
induction as with
360360
| nil => rfl
361-
| cons x xs ih => simp [concatMap, ih]
361+
| cons x xs ih => simp [concatMap]
362362

363363

364364
theorem foldr_map {α β : Type} (f : α → β → β) (e : β) (g : β → α) :
@@ -390,7 +390,7 @@ example {a : Type} : ∀ xs : List a, [] ++ xs = xs := by
390390
intro h1
391391
induction h1 with
392392
| nil => rfl
393-
| cons ha hs => simp [List.append]
393+
| cons ha hs => grind
394394

395395

396396
example {a b : Type} (xs ys : List a) (f : a → b → b) (e : b)
@@ -517,11 +517,11 @@ def collapse₃ (xss : List (List Int)) : List Int :=
517517
help (0, id) (labelsum xss) []
518518

519519

520-
/-
521-
#eval collapse₃ [[1],[-3],[2,4]]
522-
#eval collapse₃ [[-2,1],[-3],[2,4]]
523-
#eval collapse₃ [[-2,1],[3],[2,4]]
524-
-/
520+
example : collapse₃ [[1],[-3],[2,4]] = [1] :=
521+
rfl
522+
523+
example : collapse₃ [[-2,1],[3],[2,4]] = [-2, 1, 3] :=
524+
rfl
525525

526526

527527
end Chapter1

Fad/Chapter12-Ex.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ example
6464
simp [Function.comp]
6565
induction xs with
6666
| nil =>
67-
simp [List.foldr, concatMap, flip]
67+
simp [List.foldr, flip]
6868
| cons a as ih =>
6969
have h1 := h a
7070
sorry

Fad/Chapter12.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ theorem length_lt_of_cons_split {α : Type} (xs ys zs : List α)
3232
| nil =>
3333
simp [splits] at h
3434
| cons x xs ih =>
35-
simp only [splits, List.map, List.flatMap, List.mem_cons, List.mem_map] at h
35+
simp only [splits, List.mem_cons, List.mem_map] at h
3636
cases h with
3737
| inl h' =>
3838
simp at h'

Fad/Chapter3-Ex.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ example : ∀ (xs : List a), xs = fromRA (toRA xs) := by
192192
match toRA xs with
193193
| [] => rfl
194194
| (Digit.zero :: ds) =>
195-
simp [fromRA, fromT, Tree.mk]
195+
simp [fromRA]
196196
rw [concatMap]
197197
sorry
198198
| (Digit.one t :: ds) =>
199-
simp [fromRA, fromT, Tree.mk]
199+
simp [fromRA]
200200
rw [concatMap]
201201
sorry
202202

Fad/Chapter3.lean

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ example (x : a) : snoc x ∘ fromSL = fromSL ∘ snocSL x := by
124124
unfold snoc snocSL fromSL
125125
match h: lhs with
126126
| [] =>
127-
simp [h]
127+
simp
128128
simp at ok
129129
apply ok.elim <;> intro h2; simp [h2]
130130
have a :: [] := rhs
@@ -270,7 +270,7 @@ example : ∀ (as : SymList a), fromSL (tailSL as) = tail (fromSL as) := by
270270
| nil => simp [tailSL, fromSL, nil]
271271
| cons b bs ih =>
272272
simp [fromSL, tailSL, nil]
273-
simp [ok] at *
273+
simp at *
274274
rw [ok]
275275
rw [List.reverse_nil, List.nil_append, List.tail]
276276
| cons a as =>
@@ -302,7 +302,7 @@ theorem length_tail_lt_length (sl : SymList a) (h : sl ≠ nil)
302302
cases ok with
303303
| intro h1 h2 =>
304304
simp [k] at h1
305-
cases h1 with
305+
cases h1 with
306306
| inl l => simp_all; contradiction
307307
| inr m => simp [m]
308308
· simp [k]
@@ -315,7 +315,7 @@ theorem length_tail_lt_length (sl : SymList a) (h : sl ≠ nil)
315315
omega
316316
simp [l]
317317
apply Nat.sub_lt_self
318-
simp [k]
318+
simp
319319
have h : 0 < lsl.length := by
320320
cases lsl with
321321
| nil => contradiction
@@ -328,7 +328,7 @@ theorem headSL_none_iff_nilSL {sl : SymList a} : headSL sl = none ↔ sl = nil :
328328
split at h
329329
unfold nil
330330
exact rfl
331-
repeat simp [eq_comm, <-Option.isNone_iff_eq_none] at h
331+
repeat simp [eq_comm] at h
332332
rw [h]
333333
unfold headSL nil
334334
simp
@@ -455,7 +455,7 @@ theorem tails_append_singleton (xs : List α) (x : α) :
455455
induction xs with
456456
| nil => simp
457457
| cons y ys ih =>
458-
simp [List.tails, ih, List.map_append]
458+
simp [List.tails, ih]
459459

460460
theorem map_reverse_tails_snoc (x : α) (xs : List α) :
461461
List.map reverse (snoc x xs).tails =
@@ -510,11 +510,9 @@ theorem inits_eq {a : Type} : ∀ xs : List a, inits₁ xs = inits₂ xs
510510
simp
511511
| x :: xs => by
512512
have ih := inits_eq xs
513-
simp [ inits₁, inits₂,
514-
List.reverse_cons,
515-
map_reverse_tails_snoc,
516-
scanl_cons, fromSL_snoc, ih,
517-
Function.comp, flip, map_reverse] at *
513+
simp [inits₁, inits₂,
514+
List.reverse_cons,
515+
Function.comp, flip] at *
518516
sorry
519517

520518

Fad/Chapter5-Ex.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ example (xs : List Nat) : expression₂ xs = reverse xs := by
179179
| nil => rfl
180180
| cons x xs ih =>
181181
simp [expression₂, reverse] at *
182-
simp [List.foldr_cons, List.foldl_cons, flip] at *
182+
simp [List.foldr_cons, flip] at *
183183
sorry
184184

185185

Fad/Chapter6.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,23 @@ theorem partition3_length {a : Type} [LT a] [DecidableRel (α := a) (· < ·)]
180180
by_cases l: x > y
181181
· simp at *
182182
repeat rw [← partition3]
183-
repeat simp [k, l]
183+
repeat simp [k]
184184
rw [← ih]
185185
by_cases m: x = y
186186
· simp [m]
187187
rw [← add_assoc]
188188
rw[add_assoc]
189189
nth_rewrite 3 [add_comm]
190190
rfl
191-
simp [k, l, m]
191+
simp [m]
192192
nth_rewrite 2 [add_assoc]
193193
nth_rewrite 3 [add_comm]
194194
rw [← add_assoc]
195195
rw[add_assoc]
196196
nth_rewrite 3 [add_comm]
197197
rw [← add_assoc]
198198
by_cases m: x = y
199-
· simp [k, l]
199+
· simp [k]
200200
simp at *
201201
simp [m]
202202
repeat rw [← partition3]
@@ -205,7 +205,7 @@ theorem partition3_length {a : Type} [LT a] [DecidableRel (α := a) (· < ·)]
205205
nth_rewrite 3 [add_comm]
206206
rw [← add_assoc]
207207
rw [ih]
208-
simp [k, l, m]
208+
simp [k, m]
209209
repeat rw [← partition3]
210210
nth_rewrite 2 [add_assoc]
211211
nth_rewrite 3 [add_comm]
@@ -216,7 +216,7 @@ theorem partition3_length {a : Type} [LT a] [DecidableRel (α := a) (· < ·)]
216216
rw [ih]
217217

218218
/- may not be necessary -/
219-
def select' (k : Nat) (xs : List a) (q: k ≤ xs.length): a :=
219+
def select' (k : Nat) (xs : List a) (q: k ≤ xs.length): a :=
220220
let rec help (k : Nat) (xs : List a) (q: k ≤ xs.length) (fuel: Nat) : a :=
221221
match fuel with
222222
| 0 => panic!"Never here"
@@ -229,8 +229,8 @@ def select' (k : Nat) (xs : List a) (q: k ≤ xs.length): a :=
229229
if h₁: k ≤ m then help k us (by omega) fuel
230230
else if h₂: k ≤ m + n then vs[k - m - 1]
231231
else help (k-m-n) ws (by
232-
simp [m, n]; rw [partition3_length]; simp [q]) fuel
233-
termination_by fuel
232+
simp [m, n]; rw [partition3_length]; simp [q]) fuel
233+
termination_by fuel
234234
help k xs q xs.length
235-
235+
236236
end Chapter6

Fad/Chapter7-Ex.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ example (x : Nat) : ∀ xs, xs ≠ [] →
119119
minimum (xs.map (x :: ·)) = (x :: ·) (minimum xs)
120120
:= by
121121
intro xs h
122-
simp [Function.comp]
122+
simp
123123
induction xs with
124124
| nil => contradiction
125125
| cons a as ih =>

0 commit comments

Comments
 (0)