Skip to content

Commit d419b09

Browse files
committed
chore: fix linter warnings in tests (#662)
1 parent cd40c74 commit d419b09

15 files changed

+68
-67
lines changed

lean_packages/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"name": "Unicode",
2222
"inputRev": "main"},
2323
{"url": "https://github.com/leanprover/std4",
24-
"rev": "4261f9bcb56ada27ad9307beaf8c4dba5a0a6883",
24+
"rev": "eb43042ebfebcc111ccd1986d3f7615cdf986a0d",
2525
"name": "std",
2626
"inputRev": "main"},
2727
{"url": "https://github.com/leanprover/lake",

test/Clear!.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Mathlib.Tactic.Clear!
22

33
-- Most basic test
4-
example (delete_this : Nat) (delete_this_dep : delete_this = delete_this) : Nat := by
4+
example (delete_this : Nat) (_delete_this_dep : delete_this = delete_this) : Nat := by
55
clear! delete_this
66
fail_if_success assumption
77
exact 0
@@ -13,7 +13,7 @@ example [delete_this : Inhabited Nat] : Inhabited Nat := by
1313
infer_instance
1414

1515
-- Confirms clear! can clear the dependencies of multiple hypotheses
16-
example (delete_this : Nat) (delete_this2 : Nat) (delete_this_dep : delete_this = delete_this2) : Nat := by
16+
example (delete_this : Nat) (delete_this2 : Nat) (_delete_this_dep : delete_this = delete_this2) : Nat := by
1717
clear! delete_this delete_this2
1818
fail_if_success assumption
1919
exact 0

test/ClearExcept.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Mathlib.Tactic.ClearExcept
22

33
-- Most basic test
4-
example (delete_this : Nat) (dont_delete_this : Int) : Nat := by
4+
example (_delete_this : Nat) (dont_delete_this : Int) : Nat := by
55
clear * - dont_delete_this
66
fail_if_success assumption
77
exact dont_delete_this.toNat
@@ -12,7 +12,7 @@ example [dont_delete_this : Inhabited Nat] (dont_delete_this2 : Prop) : Inhabite
1212
assumption
1313

1414
-- Confirms that clearExcept can clear hypotheses even when they have dependencies
15-
example (delete_this : Nat) (delete_this2 : delete_this = delete_this) (dont_delete_this : Int) : Nat := by
15+
example (delete_this : Nat) (_delete_this2 : delete_this = delete_this) (dont_delete_this : Int) : Nat := by
1616
clear * - dont_delete_this
1717
fail_if_success assumption
1818
exact dont_delete_this.toNat
@@ -23,7 +23,7 @@ example (dont_delete_this : Nat) (dont_delete_this2 : dont_delete_this = dont_de
2323
exact dont_delete_this
2424

2525
-- Confirms that clearExcept can preserve multiple identifiers
26-
example (delete_this : Nat) (dont_delete_this : Int) (dont_delete_this2 : Int) : Nat := by
26+
example (_delete_this : Nat) (dont_delete_this : Int) (dont_delete_this2 : Int) : Nat := by
2727
clear * - dont_delete_this dont_delete_this2
2828
fail_if_success assumption
2929
exact dont_delete_this.toNat + dont_delete_this2.toNat

test/Clear_.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ example (_delete_this : Type) (_delete_this_dep : _delete_this) (_delete_this_rw
2424
clear_
2525
fail_if_success
2626
rw [← _delete_this_rw]
27-
assumption
2827
exact 0
2928

3029
-- Confirms that clear_ does not clear hypotheses when they have dependencies that should not be cleared

test/Have.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ example {a : Nat} : a = a := by
2626
exact this
2727

2828
example : True := by
29-
(let N) -- FIXME: lean4#1670
29+
(let _N) -- FIXME: lean4#1670
3030
exact Nat
3131
have
3232
· exact 0
33-
have h : Nat
33+
have _h : Nat
3434
· exact 5
35-
have h' x : x < x + 1
35+
have _h' x : x < x + 1
3636
· exact Nat.lt.base x
37-
have h'' (x : Nat) : x < x + 1
37+
have _h'' (x : Nat) : x < x + 1
3838
· exact Nat.lt.base x
39-
let m
39+
let _m
4040
· exact 6
41-
let m' x (y : Nat) : x + y = y + x
41+
let _m' x (y : Nat) : x + y = y + x
4242
rw [Nat.add_comm]
43-
have q
43+
have _q
4444
· exact 6
4545
simp

test/PermuteGoals.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ example (p q r : Prop) : p → q → r → p ∧ q ∧ r := by
1717
example (p q r : Prop) : p → q → r → p ∧ q ∧ r := by
1818
intros a b c
1919
constructor
20-
fail_if_success on_goal -3 => exact a
20+
fail_if_success on_goal -3 => unreachable!
2121
fail_if_success on_goal -1 => exact a
22-
fail_if_success on_goal 0 => exact a
22+
fail_if_success on_goal 0 => unreachable!
2323
fail_if_success on_goal 2 => exact a
24-
fail_if_success on_goal 3 => exact a
24+
fail_if_success on_goal 3 => unreachable!
2525
on_goal 1 => exact a
2626
constructor
2727
swap

test/Replace.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ Authors: Arthur Paulino
55
-/
66
import Mathlib.Tactic.Replace
77

8-
-- tests with a explicitly named hipothesis
8+
set_option linter.unusedVariables false
9+
10+
-- tests with a explicitly named hypothesis
911

1012
example (h : Int) : Nat := by
1113
replace h : Nat := 0

test/Set.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ example (x : Nat) (h : x + x - x = 3) : x + x - x = 3 := by
1919
guard_hyp w := x
2020
guard_hyp h : w + w - w = 3
2121
guard_hyp h2 : w = y
22-
set z := w with h3
22+
set z := w with _h3
2323
set a := 3
2424
guard_target = z + z - z = a
2525
set i'm_the_goal : Prop := z + z - z = a
@@ -28,6 +28,6 @@ example (x : Nat) (h : x + x - x = 3) : x + x - x = 3 := by
2828

2929
example (x : Nat) (h : x - x = 0) : x = x := by
3030
set y : Nat := x
31-
set! z := y + 1 witheq1
32-
set! p : x - x = 0 := h with eq2
31+
set! z := y + 1 with_eq1
32+
set! p : x - x = 0 := h with _eq2
3333
rfl

test/Simps.lean

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ example (n : ℕ) : foo.rfl.invFun n = n := by rw [foo.rfl_invFun]
124124
-- note: in Lean 4 the first test succeeds without `@[simps]`, however, the remaining tests don't
125125
example : foo.1 = 1 := by simp
126126
example {a : ℕ} {h : 1 = a} : foo.1 = a := by rw [foo_fst, h]
127-
example {a : ℕ} {h : 1 = a} : foo.1 = a := by simp <;> rw [h]
128-
example {a : ℤ} {h : 2 = a} : foo.2 = a := by simp <;> rw [h]
129-
example {a : ℕ} {h : 1 = a} : foo.1 = a := by dsimp <;> rw [h] -- check that dsimp also unfolds
130-
example {a : ℤ} {h : 2 = a} : foo.2 = a := by dsimp <;> rw [h]
131-
example {α} (x y : α) (h : x = y) : foo.rfl.toFun x = y := by simp <;> rw [h]
132-
example {α} (x y : α) (h : x = y) : foo.rfl.invFun x = y := by simp <;> rw [h]
127+
example {a : ℕ} {h : 1 = a} : foo.1 = a := by simp; rw [h]
128+
example {a : ℤ} {h : 2 = a} : foo.2 = a := by simp; rw [h]
129+
example {a : ℕ} {h : 1 = a} : foo.1 = a := by dsimp; rw [h] -- check that dsimp also unfolds
130+
example {a : ℤ} {h : 2 = a} : foo.2 = a := by dsimp; rw [h]
131+
example {α} (x y : α) (h : x = y) : foo.rfl.toFun x = y := by simp; rw [h]
132+
example {α} (x y : α) (h : x = y) : foo.rfl.invFun x = y := by simp; rw [h]
133133
-- example {α} (x y : α) (h : x = y) : foo.rfl.toFun = @id α := by { successIfFail {simp}, rfl }
134134

135135
/- check some failures -/
@@ -367,8 +367,8 @@ example {α} {b : Bool} {x} (h : (⟨3, 5⟩ : MyProd _ _) = x) : (@test α).ext
367367
@[simps (config := {simpRhs := true})] def Equiv'.trans {α β γ} (f : α ≃ β) (g : β ≃ γ) : α ≃ γ :=
368368
⟨ g.toFun ∘ f.toFun,
369369
f.invFun ∘ g.invFun,
370-
(by intro x <;> simp [Equiv'.left_inv _ _]),
371-
(by intro x <;> simp [Equiv'.right_inv _ _])⟩
370+
(by intro x; simp [Equiv'.left_inv _ _]),
371+
(by intro x; simp [Equiv'.right_inv _ _])⟩
372372

373373

374374
example {α β γ : Type} (f : α ≃ β) (g : β ≃ γ) (x : α) {z : γ} (h : g.toFun (f.toFun x) = z) :
@@ -378,13 +378,13 @@ example {α β γ : Type} (f : α ≃ β) (g : β ≃ γ) (x : α) {z : γ} (h :
378378

379379
attribute [local simp] Nat.zero_add Nat.one_mul Nat.mul_one
380380
@[simps (config := {simpRhs := true})] def myNatEquiv : ℕ ≃ ℕ :=
381-
⟨λ n => 0 + n, λ n => 1 * n * 1, by intro n <;> simp, by intro n <;> simp⟩
381+
⟨λ n => 0 + n, λ n => 1 * n * 1, by intro n; simp, by intro n; simp⟩
382382

383383
example (n : ℕ) : myNatEquiv.toFun (myNatEquiv.toFun $ myNatEquiv.invFun n) = n :=
384384
by { /-successIfFail { rfl },-/ simp only [myNatEquiv_toFun, myNatEquiv_invFun] }
385385

386386
@[simps (config := {simpRhs := true})] def succeed_without_simplification_possible : ℕ ≃ ℕ :=
387-
⟨λ n => n, λ n => n, by intro n <;> rfl, by intro n <;> rfl⟩
387+
⟨λ n => n, λ n => n, by intro n; rfl, by intro n; rfl⟩
388388

389389

390390
/- test that we don't recursively take projections of `prod` and `PProd` -/
@@ -437,10 +437,10 @@ infixr:80 " ≫ " => CategoryStruct.comp -- type as \gg
437437

438438
@[ext] theorem types.ext {X Y : Type u} {f g : X ⟶ Y} : (∀ x, f x = g x) → f = g := funext
439439

440-
example (X : Type u) {x : Type u} (h : (X → X) = x) : (X ⟶ X) = x := by simp <;> rw [h]
441-
example (X : Type u) {f : X → X} (h : ∀ x, f x = x) : 𝟙 X = f := by ext <;> simp <;> rw [h]
440+
example (X : Type u) {x : Type u} (h : (X → X) = x) : (X ⟶ X) = x := by simp; rw [h]
441+
example (X : Type u) {f : X → X} (h : ∀ x, f x = x) : 𝟙 X = f := by ext; simp; rw [h]
442442
example (X Y Z : Type u) (f : X ⟶ Y) (g : Y ⟶ Z) {k : X → Z} (h : ∀ x, g (f x) = k x) :
443-
f ≫ g = k := by ext <;> simp <;> rw [h]
443+
f ≫ g = k := by ext; simp; rw [h]
444444

445445
namespace coercing
446446

@@ -453,8 +453,8 @@ instance : CoeSort FooStr Type := ⟨FooStr.c⟩
453453
@[simps] def foo : FooStr := ⟨ℕ, 3
454454
@[simps] def foo2 : FooStr := ⟨ℕ, 34
455455

456-
example {x : Type} (h : ℕ = x) : foo = x := by simp only [foo_c] <;> rw [h]
457-
example {x : ℕ} (h : (3 : ℕ) = x) : foo.x = x := by simp only [foo_x] <;> rw [h]
456+
example {x : Type} (h : ℕ = x) : foo = x := by simp only [foo_c]; rw [h]
457+
example {x : ℕ} (h : (3 : ℕ) = x) : foo.x = x := by simp only [foo_x]; rw [h]
458458

459459
structure VooStr (n : ℕ) :=
460460
(c : Type)
@@ -465,8 +465,8 @@ instance (n : ℕ) : CoeSort (VooStr n) Type := ⟨VooStr.c⟩
465465
@[simps] def voo : VooStr 7 := ⟨ℕ, 3
466466
@[simps] def voo2 : VooStr 4 := ⟨ℕ, 34
467467

468-
example {x : Type} (h : ℕ = x) : voo = x := by simp only [voo_c] <;> rw [h]
469-
example {x : ℕ} (h : (3 : ℕ) = x) : voo.x = x := by simp only [voo_x] <;> rw [h]
468+
example {x : Type} (h : ℕ = x) : voo = x := by simp only [voo_c]; rw [h]
469+
example {x : ℕ} (h : (3 : ℕ) = x) : voo.x = x := by simp only [voo_x]; rw [h]
470470

471471
structure Equiv2 (α : Sort _) (β : Sort _) :=
472472
(toFun : α → β)
@@ -480,8 +480,8 @@ instance {α β} : CoeFun (Equiv2 α β) (λ _ => α → β) := ⟨Equiv2.toFun
480480
⟨λ x => x, λ x => x, λ _ => rfl, λ _ => rfl⟩
481481

482482
example {α} (x x' : α) (h : x = x') : coercing.rfl2 x = x' := by rw [coercing.rfl2_toFun, h]
483-
example {α} (x x' : α) (h : x = x') : coercing.rfl2 x = x' := by simp <;> rw [h]
484-
example {α} (x x' : α) (h : x = x') : coercing.rfl2.invFun x = x' := by simp <;> rw [h]
483+
example {α} (x x' : α) (h : x = x') : coercing.rfl2 x = x' := by simp; rw [h]
484+
example {α} (x x' : α) (h : x = x') : coercing.rfl2.invFun x = x' := by simp; rw [h]
485485

486486
@[simps] protected def Equiv2.symm {α β} (f : Equiv2 α β) : Equiv2 β α :=
487487
⟨f.invFun, f, f.right_inv, f.left_inv⟩
@@ -492,12 +492,12 @@ example {α} (x x' : α) (h : x = x') : coercing.rfl2.invFun x = x' := by simp <
492492
@[simps (config := {fullyApplied := false})] protected def Equiv2.symm3 {α β} (f : Equiv2 α β) : Equiv2 β α :=
493493
⟨f.invFun, f, f.right_inv, f.left_inv⟩
494494

495-
example {α β} (f : Equiv2 α β) (y : β) {x} (h : f.invFun y = x) : f.symm y = x := by simp <;> rw [h]
496-
example {α β} (f : Equiv2 α β) (x : α) {z} (h : f x = z) : f.symm.invFun x = z := by simp <;> rw [h]
495+
example {α β} (f : Equiv2 α β) (y : β) {x} (h : f.invFun y = x) : f.symm y = x := by simp; rw [h]
496+
example {α β} (f : Equiv2 α β) (x : α) {z} (h : f x = z) : f.symm.invFun x = z := by simp; rw [h]
497497

498498
-- example {α β} (f : Equiv2 α β) {x} (h : f = x) : f.symm.invFun = x :=
499499
-- by { /-successIfFail {simp <;> rw [h]} <;>-/ rfl }
500-
example {α β} (f : Equiv2 α β) {x} (h : f = x) : f.symm3.invFun = x := by simp <;> rw [h]
500+
example {α β} (f : Equiv2 α β) {x} (h : f = x) : f.symm3.invFun = x := by simp; rw [h]
501501

502502
class Semigroup (G : Type u) extends Mul G where
503503
mul_assoc : ∀ a b c : G, a * b * c = a * (b * c)
@@ -587,7 +587,7 @@ protected def Equiv.trans (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=
587587

588588
example (e₁ : α ≃ β) (e₂ : β ≃ γ) (x : γ) {z} (h : e₁.symm (e₂.symm x) = z) :
589589
(e₁.trans e₂).symm x = z :=
590-
by simp only [Equiv.trans_invFun] <;> rw [h]
590+
by simp only [Equiv.trans_invFun]; rw [h]
591591

592592
end ManualCoercion
593593

@@ -641,7 +641,7 @@ protected def Equiv.trans (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=
641641

642642
example (e₁ : α ≃ β) (e₂ : β ≃ γ) (x : γ) {z} (h : e₁.symm (e₂.symm x) = z) :
643643
(e₁.trans e₂).symm x = z :=
644-
by simp only [Equiv.trans_invFun] <;> rw [h]
644+
by simp only [Equiv.trans_invFun]; rw [h]
645645

646646
end ManualInitialize
647647

@@ -725,11 +725,11 @@ protected def Equiv.trans (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=
725725
⟨e₂ ∘ (e₁ : α → β), e₁.symm ∘ (e₂.symm : γ → β)⟩
726726

727727
example (e₁ : α ≃ β) (e₂ : β ≃ γ) (x : α) {z} (h : e₂ (e₁ x) = z) : (e₁.trans e₂) x = z :=
728-
by simp only [Equiv.trans_apply] <;> rw [h]
728+
by simp only [Equiv.trans_apply]; rw [h]
729729

730730
example (e₁ : α ≃ β) (e₂ : β ≃ γ) (x : γ) {z} (h : e₁.symm (e₂.symm x) = z) :
731731
(e₁.trans e₂).symm x = z :=
732-
by simp only [Equiv.trans_symm_apply] <;> rw [h]
732+
by simp only [Equiv.trans_symm_apply]; rw [h]
733733

734734
-- the new projection names are parsed correctly (the old projection names won't work anymore)
735735
@[simps apply symm_apply] protected def Equiv.trans2 (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=
@@ -1110,8 +1110,7 @@ initialize_simps_projections OneMore
11101110
Q_toFun := λ y => ⟨y, rfl⟩
11111111
Q_invFun := λ y => ⟨y, rfl⟩ }
11121112

1113-
example {α : Type} (x : α) : (fffoo α).symm x = x :=
1114-
by dsimp <;> guard_target = x = x <;> rfl
1113+
example {α : Type} (x : α) : (fffoo α).symm x = x := by dsimp
11151114

11161115
@[simps apply to_dequiv_apply toFurtherDecoratedEquiv_apply to_dequiv]
11171116
def fffoo2 (α : Type) : OneMore α α := fffoo α

test/SolveByElim.lean

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ example (h : Nat) : Nat := by solve_by_elim
99
example {α β : Type} (f : α → β) (a : α) : β := by solve_by_elim
1010
example {α β : Type} (f : α → α → β) (a : α) : β := by solve_by_elim
1111
example {α β γ : Type} (f : α → β) (g : β → γ) (a : α) : γ := by solve_by_elim
12-
example {α β γ : Type} (f : α → β) (g : β → γ) (b : β) : γ := by solve_by_elim
12+
example {α β γ : Type} (_f : α → β) (g : β → γ) (b : β) : γ := by solve_by_elim
1313
example {α : Nat → Type} (f : (n : Nat) → α n → α (n+1)) (a : α 0) : α 5 := by solve_by_elim
1414

1515
example (h : Nat) : Nat := by solve_by_elim []
1616
example {α β : Type} (f : α → β) (a : α) : β := by solve_by_elim []
1717
example {α β : Type} (f : α → α → β) (a : α) : β := by solve_by_elim []
1818
example {α β γ : Type} (f : α → β) (g : β → γ) (a : α) : γ := by solve_by_elim []
19-
example {α β γ : Type} (f : α → β) (g : β → γ) (b : β) : γ := by solve_by_elim []
19+
example {α β γ : Type} (_f : α → β) (g : β → γ) (b : β) : γ := by solve_by_elim []
2020
example {α : Nat → Type} (f : (n : Nat) → α n → α (n+1)) (a : α 0) : α 5 := by solve_by_elim []
2121

2222
example {α β : Type} (f : α → β) (a : α) : β := by
@@ -27,12 +27,13 @@ example (h : Nat) : Nat := by solve_by_elim only [h]
2727
example {α β : Type} (f : α → β) (a : α) : β := by solve_by_elim only [f, a]
2828
example {α β : Type} (f : α → α → β) (a : α) : β := by solve_by_elim only [f, a]
2929
example {α β γ : Type} (f : α → β) (g : β → γ) (a : α) : γ := by solve_by_elim only [f, g, a]
30-
example {α β γ : Type} (f : α → β) (g : β → γ) (b : β) : γ := by solve_by_elim only [g, b]
31-
example {α : Nat → Type} (f : (n : Nat) → α n → α (n+1)) (a : α 0) : α 5 := by solve_by_elim only [f, a]
30+
example {α β γ : Type} (_f : α → β) (g : β → γ) (b : β) : γ := by solve_by_elim only [g, b]
31+
example {α : Nat → Type} (f : (n : Nat) → α n → α (n+1)) (a : α 0) : α 5 := by
32+
solve_by_elim only [f, a]
3233

3334
-- Verify that already assigned metavariables are skipped.
34-
example (P₁ P₂: α → Prop) (f: forall (a: α), P₁ a → P₂ a → β)
35-
(a: α) (ha₁: P₁ a) (ha₂ : P₂ a) : β := by
35+
example (P₁ P₂ : α → Prop) (f : ∀ (a : α), P₁ a → P₂ a → β)
36+
(a : α) (ha₁ : P₁ a) (ha₂ : P₂ a) : β := by
3637
solve_by_elim
3738

3839
example {X : Type} (x : X) : x = x := by
@@ -41,16 +42,16 @@ example {X : Type} (x : X) : x = x := by
4142

4243
-- Needs to apply `rfl` twice, with different implicit arguments each time.
4344
-- A naive implementation of solve_by_elim would get stuck.
44-
example {X : Type} (x y : X) (p : Prop) (h: x = x → y = y → p) : p := by solve_by_elim
45+
example {X : Type} (x y : X) (p : Prop) (h : x = x → y = y → p) : p := by solve_by_elim
4546

4647
example : True := by
4748
fail_if_success solve_by_elim only -- needs the `trivial` lemma
4849
solve_by_elim
4950

5051
-- Requires backtracking.
51-
example (P₁ P₂: α → Prop) (f: forall (a: α), P₁ a → P₂ a → β)
52-
(a: α) (ha₁: P₁ a)
53-
(a': α) (ha'₁: P₁ a') (ha'₂: P₂ a'): β := by
52+
example (P₁ P₂ : α → Prop) (f : ∀ (a: α), P₁ a → P₂ a → β)
53+
(a : α) (_ha₁ : P₁ a)
54+
(a' : α) (ha'₁ : P₁ a') (ha'₂ : P₂ a') : β := by
5455
solve_by_elim
5556

5657
-- TODO this works in mathlib3 but not here yet, for some reason.

0 commit comments

Comments
 (0)