Skip to content

Commit f4a0259

Browse files
authored
chore: cleanups uncovered by Shake (#10572)
* Wrap proof subterms in `by exact` so dependencies can be demoted to private `import`s * Remove trivial instance re-definitions that may cause name collisions on import changes * Remove unused `open`s that may fail on import removals
1 parent 3f81615 commit f4a0259

File tree

18 files changed

+12
-28
lines changed

18 files changed

+12
-28
lines changed

src/Init/Data/BitVec/Decidable.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ instance instDecidableForallBitVecSucc (P : BitVec (n+1) → Prop) [DecidablePre
4949

5050
instance instDecidableExistsBitVecZero (P : BitVec 0Prop) [Decidable (P 0#0)] :
5151
Decidable (∃ v, P v) :=
52-
decidable_of_iff (¬ ∀ v, ¬ P v) Classical.not_forall_not
52+
decidable_of_iff (¬ ∀ v, ¬ P v) (by exact Classical.not_forall_not)
5353

5454
instance instDecidableExistsBitVecSucc (P : BitVec (n+1) → Prop) [DecidablePred P]
5555
[Decidable (∀ (x : Bool) (v : BitVec n), ¬ P (v.cons x))] : Decidable (∃ v, P v) :=
56-
decidable_of_iff (¬ ∀ v, ¬ P v) Classical.not_forall_not
56+
decidable_of_iff (¬ ∀ v, ¬ P v) (by exact Classical.not_forall_not)
5757

5858
/--
5959
For small numerals this isn't necessary (as typeclass search can use the above two instances),

src/Init/Data/Fin/Basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Modulus of bounded numbers, usually invoked via the `%` operator.
140140
The resulting value is that computed by the `%` operator on `Nat`.
141141
-/
142142
protected def mod : Fin n → Fin n → Fin n
143-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨a % b, Nat.lt_of_le_of_lt (Nat.mod_le _ _) h⟩
143+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨a % b, by exact Nat.lt_of_le_of_lt (Nat.mod_le _ _) h⟩
144144

145145
/--
146146
Division of bounded numbers, usually invoked via the `/` operator.
@@ -154,15 +154,15 @@ Examples:
154154
* `(5 : Fin 10) / (7 : Fin 10) = (0 : Fin 10)`
155155
-/
156156
protected def div : Fin n → Fin n → Fin n
157-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨a / b, Nat.lt_of_le_of_lt (Nat.div_le_self _ _) h⟩
157+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨a / b, by exact Nat.lt_of_le_of_lt (Nat.div_le_self _ _) h⟩
158158

159159
/--
160160
Modulus of bounded numbers with respect to a `Nat`.
161161
162162
The resulting value is that computed by the `%` operator on `Nat`.
163163
-/
164164
def modn : Fin n → Nat → Fin n
165-
| ⟨a, h⟩, m => ⟨a % m, Nat.lt_of_le_of_lt (Nat.mod_le _ _) h⟩
165+
| ⟨a, h⟩, m => ⟨a % m, by exact Nat.lt_of_le_of_lt (Nat.mod_le _ _) h⟩
166166

167167
/--
168168
Bitwise and.

src/Init/Data/Int/DivMod/Lemmas.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ theorem eq_one_of_mul_eq_one_right {a b : Int} (H : 0 ≤ a) (H' : a * b = 1) :
122122
theorem eq_one_of_mul_eq_one_left {a b : Int} (H : 0 ≤ b) (H' : a * b = 1) : b = 1 :=
123123
eq_one_of_mul_eq_one_right (b := a) H <| by rw [Int.mul_comm, H']
124124

125-
instance decidableDvd : DecidableRel (α := Int) (· ∣ ·) := fun _ _ =>
126-
decidable_of_decidable_of_iff (dvd_iff_emod_eq_zero ..).symm
125+
instance decidableDvd : DecidableRel (α := Int) (· ∣ ·) := fun a b =>
126+
decidable_of_decidable_of_iff (p := b % a = 0) (by exact (dvd_iff_emod_eq_zero ..).symm)
127127

128128
protected theorem mul_dvd_mul_iff_left {a b c : Int} (h : a ≠ 0) : (a * b) ∣ (a * c) ↔ b ∣ c :=
129129
by rintro ⟨d, h'⟩; exact ⟨d, by rw [Int.mul_assoc] at h'; exact (mul_eq_mul_left_iff h).mp h'⟩,

src/Init/Data/Range/Polymorphic/BitVec.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ instance : LawfulUpwardEnumerableLE (BitVec n) where
4949
· rintro ⟨n, hn, rfl⟩
5050
simp [BitVec.ofNatLT]
5151

52-
instance : LawfulOrderLT (BitVec n) := inferInstance
5352
instance : LawfulUpwardEnumerableLT (BitVec n) := inferInstance
5453
instance : LawfulUpwardEnumerableLT (BitVec n) := inferInstance
5554
instance : LawfulUpwardEnumerableLowerBound .closed (BitVec n) := inferInstance

src/Init/Data/Range/Polymorphic/UInt.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ instance : LawfulUpwardEnumerableLE UInt8 where
5757
simpa [upwardEnumerableLE_ofBitVec, UInt8.le_iff_toBitVec_le] using
5858
LawfulUpwardEnumerableLE.le_iff _ _
5959

60-
instance : LawfulOrderLT UInt8 := inferInstance
6160
instance : LawfulUpwardEnumerableLT UInt8 := inferInstance
6261
instance : LawfulUpwardEnumerableLT UInt8 := inferInstance
6362
instance : LawfulUpwardEnumerableLowerBound .closed UInt8 := inferInstance
@@ -130,7 +129,6 @@ instance : LawfulUpwardEnumerableLE UInt16 where
130129
simpa [upwardEnumerableLE_ofBitVec, UInt16.le_iff_toBitVec_le] using
131130
LawfulUpwardEnumerableLE.le_iff _ _
132131

133-
instance : LawfulOrderLT UInt16 := inferInstance
134132
instance : LawfulUpwardEnumerableLT UInt16 := inferInstance
135133
instance : LawfulUpwardEnumerableLT UInt16 := inferInstance
136134
instance : LawfulUpwardEnumerableLowerBound .closed UInt16 := inferInstance
@@ -203,7 +201,6 @@ instance : LawfulUpwardEnumerableLE UInt32 where
203201
simpa [upwardEnumerableLE_ofBitVec, UInt32.le_iff_toBitVec_le] using
204202
LawfulUpwardEnumerableLE.le_iff _ _
205203

206-
instance : LawfulOrderLT UInt32 := inferInstance
207204
instance : LawfulUpwardEnumerableLT UInt32 := inferInstance
208205
instance : LawfulUpwardEnumerableLT UInt32 := inferInstance
209206
instance : LawfulUpwardEnumerableLowerBound .closed UInt32 := inferInstance
@@ -276,7 +273,6 @@ instance : LawfulUpwardEnumerableLE UInt64 where
276273
simpa [upwardEnumerableLE_ofBitVec, UInt64.le_iff_toBitVec_le] using
277274
LawfulUpwardEnumerableLE.le_iff _ _
278275

279-
instance : LawfulOrderLT UInt64 := inferInstance
280276
instance : LawfulUpwardEnumerableLT UInt64 := inferInstance
281277
instance : LawfulUpwardEnumerableLT UInt64 := inferInstance
282278
instance : LawfulUpwardEnumerableLowerBound .closed UInt64 := inferInstance
@@ -349,7 +345,6 @@ instance : LawfulUpwardEnumerableLE USize where
349345
simpa [upwardEnumerableLE_ofBitVec, USize.le_iff_toBitVec_le] using
350346
LawfulUpwardEnumerableLE.le_iff _ _
351347

352-
instance : LawfulOrderLT USize := inferInstance
353348
instance : LawfulUpwardEnumerableLT USize := inferInstance
354349
instance : LawfulUpwardEnumerableLT USize := inferInstance
355350
instance : LawfulUpwardEnumerableLowerBound .closed USize := inferInstance

src/Init/Data/Rat/Basic.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ because you don't want to unfold it. Use `Rat.inv_def` instead.)
181181
@[irreducible] protected def inv (a : Rat) : Rat :=
182182
if h : a.num < 0 then
183183
{ num := -a.den, den := a.num.natAbs
184-
den_nz := Nat.ne_of_gt (Int.natAbs_pos.2 (Int.ne_of_lt h))
185-
reduced := Int.natAbs_neg a.den ▸ a.reduced.symm }
184+
den_nz := by exact Nat.ne_of_gt (Int.natAbs_pos.2 (Int.ne_of_lt h))
185+
reduced := by exact Int.natAbs_neg a.den ▸ a.reduced.symm }
186186
else if h : a.num > 0 then
187187
{ num := a.den, den := a.num.natAbs
188-
den_nz := Nat.ne_of_gt (Int.natAbs_pos.2 (Int.ne_of_gt h))
189-
reduced := a.reduced.symm }
188+
den_nz := by exact Nat.ne_of_gt (Int.natAbs_pos.2 (Int.ne_of_gt h))
189+
reduced := by exact a.reduced.symm }
190190
else
191191
a
192192

src/Init/Data/Slice.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public import Init.Data.Slice.Basic
1010
public import Init.Data.Slice.Notation
1111
public import Init.Data.Slice.Operations
1212
public import Init.Data.Slice.Array
13+
public import Init.Data.Slice.Lemmas
1314

1415
public section
1516

src/Std/Time/Date/PlainDate.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public section
1515

1616
namespace Std
1717
namespace Time
18-
open Std.Internal
1918
open Std.Time
2019
open Internal
2120
open Lean

src/Std/Time/Date/Unit/Month.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public section
1313
namespace Std
1414
namespace Time
1515
namespace Month
16-
open Std.Internal
1716
open Internal
1817

1918
set_option linter.all true

src/Std/Time/Date/Unit/Week.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public section
1313
namespace Std
1414
namespace Time
1515
namespace Week
16-
open Std.Internal
1716
open Internal
1817

1918
set_option linter.all true

0 commit comments

Comments
 (0)