Skip to content

Commit 44c0b77

Browse files
committed
private adaptions
1 parent 8c7ebb9 commit 44c0b77

File tree

14 files changed

+44
-43
lines changed

14 files changed

+44
-43
lines changed

src/Init/Core.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ structure Thunk (α : Type u) : Type u where
9595
-/
9696
mk ::
9797
/-- Extract the getter function out of a thunk. Use `Thunk.get` instead. -/
98-
private fn : Unit → α
98+
fn : Unit → α
9999

100100
attribute [extern "lean_mk_thunk"] Thunk.mk
101101

src/Init/Data/Array/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3707,7 +3707,7 @@ theorem back?_replicate {a : α} {n : Nat} :
37073707
@[deprecated back?_replicate (since := "2025-03-18")]
37083708
abbrev back?_mkArray := @back?_replicate
37093709

3710-
@[simp] theorem back_replicate (w : 0 < n) : (replicate n a).back (by simpa using w) = a := by
3710+
@[simp] theorem back_replicate {xs : Array α} (w : 0 < n) : (replicate n xs).back (by simpa using w) = xs := by
37113711
simp [back_eq_getElem]
37123712

37133713
@[deprecated back_replicate (since := "2025-03-18")]

src/Init/Data/Array/MapIdx.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ theorem mapIdx_eq_mapIdx_iff {xs : Array α} :
413413
rcases xs with ⟨xs⟩
414414
simp [List.mapIdx_eq_mapIdx_iff]
415415

416-
@[simp] theorem mapIdx_set {xs : Array α} {i : Nat} {h : i < xs.size} {a : α} :
416+
@[simp] theorem mapIdx_set {f : Nat → α → β} {xs : Array α} {i : Nat} {h : i < xs.size} {a : α} :
417417
(xs.set i a).mapIdx f = (xs.mapIdx f).set i (f i a) (by simpa) := by
418418
rcases xs with ⟨xs⟩
419419
simp [List.mapIdx_set]

src/Init/Data/Fin/Basic.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Examples:
8484
* `(2 : Fin 3) + (2 : Fin 3) = (1 : Fin 3)`
8585
-/
8686
protected def add : Fin n → Fin n → Fin n
87-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a + b) % n, mlt h⟩
87+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a + b) % n, by exact mlt h⟩
8888

8989
/--
9090
Multiplication modulo `n`, usually invoked via the `*` operator.
@@ -95,7 +95,7 @@ Examples:
9595
* `(3 : Fin 10) * (7 : Fin 10) = (1 : Fin 10)`
9696
-/
9797
protected def mul : Fin n → Fin n → Fin n
98-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a * b) % n, mlt h⟩
98+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a * b) % n, by exact mlt h⟩
9999

100100
/--
101101
Subtraction modulo `n`, usually invoked via the `-` operator.
@@ -122,7 +122,7 @@ protected def sub : Fin n → Fin n → Fin n
122122
using recursion on the second argument.
123123
See issue #4413.
124124
-/
125-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨((n - b) + a) % n, mlt h⟩
125+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨((n - b) + a) % n, by exact mlt h⟩
126126

127127
/-!
128128
Remark: land/lor can be defined without using (% n), but
@@ -164,19 +164,19 @@ def modn : Fin n → Nat → Fin n
164164
Bitwise and.
165165
-/
166166
def land : Fin n → Fin n → Fin n
167-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(Nat.land a b) % n, mlt h⟩
167+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(Nat.land a b) % n, by exact mlt h⟩
168168

169169
/--
170170
Bitwise or.
171171
-/
172172
def lor : Fin n → Fin n → Fin n
173-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(Nat.lor a b) % n, mlt h⟩
173+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(Nat.lor a b) % n, by exact mlt h⟩
174174

175175
/--
176176
Bitwise xor (“exclusive or”).
177177
-/
178178
def xor : Fin n → Fin n → Fin n
179-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(Nat.xor a b) % n, mlt h⟩
179+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(Nat.xor a b) % n, by exact mlt h⟩
180180

181181
/--
182182
Bitwise left shift of bounded numbers, with wraparound on overflow.
@@ -187,7 +187,7 @@ Examples:
187187
* `(1 : Fin 10) <<< (4 : Fin 10) = (6 : Fin 10)`
188188
-/
189189
def shiftLeft : Fin n → Fin n → Fin n
190-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a <<< b) % n, mlt h⟩
190+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a <<< b) % n, by exact mlt h⟩
191191

192192
/--
193193
Bitwise right shift of bounded numbers.
@@ -201,7 +201,7 @@ Examples:
201201
* `(15 : Fin 17) >>> (2 : Fin 17) = (3 : Fin 17)`
202202
-/
203203
def shiftRight : Fin n → Fin n → Fin n
204-
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a >>> b) % n, mlt h⟩
204+
| ⟨a, h⟩, ⟨b, _⟩ => ⟨(a >>> b) % n, by exact mlt h⟩
205205

206206
instance : Add (Fin n) where
207207
add := Fin.add

src/Init/Data/Format/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private structure State where
294294
out : String := ""
295295
column : Nat := 0
296296

297-
instance : MonadPrettyFormat (StateM State) where
297+
private instance : MonadPrettyFormat (StateM State) where
298298
-- We avoid a structure instance update, and write these functions using pattern matching because of issue #316
299299
pushOutput s := modify fun ⟨out, col⟩ => ⟨out ++ s, col + s.length⟩
300300
pushNewline indent := modify fun ⟨out, _⟩ => ⟨out ++ "\n".pushn ' ' indent, indent⟩

src/Init/Data/Int/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ set_option bootstrap.genMatcherCode false in
269269
270270
Implemented by efficient native code. -/
271271
@[extern "lean_int_dec_nonneg"]
272-
private def decNonneg (m : @& Int) : Decidable (NonNeg m) :=
272+
def decNonneg (m : @& Int) : Decidable (NonNeg m) :=
273273
match m with
274274
| ofNat m => isTrue <| NonNeg.mk m
275275
| -[_ +1] => isFalse <| fun h => nomatch h

src/Init/Data/Option/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ This is the monadic analogue of `Option.getD`.
437437
@[simp, grind] theorem getDM_some [Pure m] (a : α) (y : m α) : (some a).getDM y = pure a := rfl
438438

439439
instance (α) [BEq α] [ReflBEq α] : ReflBEq (Option α) where
440-
rfl {x} :=
440+
rfl {x} := by
441441
match x with
442-
| some _ => BEq.rfl (α := α)
442+
| some _ => exact BEq.rfl (α := α)
443443
| none => rfl
444444

445445
instance (α) [BEq α] [LawfulBEq α] : LawfulBEq (Option α) where

src/Init/Data/Repr.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ protected def _root_.USize.repr (n : @& USize) : String :=
210210
private def reprArray : Array String := Id.run do
211211
List.range 128 |>.map (·.toUSize.repr) |> Array.mk
212212

213-
private def reprFast (n : Nat) : String :=
213+
def reprFast (n : Nat) : String :=
214214
if h : n < Nat.reprArray.size then Nat.reprArray.getInternal n h else
215215
if h : n < USize.size then (USize.ofNatLT n h).repr
216216
else (toDigits 10 n).asString

src/Init/Data/Vector/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2968,7 +2968,7 @@ abbrev all_mkVector := @all_replicate
29682968
section replace
29692969
variable [BEq α]
29702970

2971-
@[simp] theorem replace_cast {xs : Vector α n} {a b : α} :
2971+
@[simp] theorem replace_cast {h : n = m} {xs : Vector α n} {a b : α} :
29722972
(xs.cast h).replace a b = (xs.replace a b).cast (by simp [h]) := by
29732973
rcases xs with ⟨xs, rfl⟩
29742974
simp

src/Init/GetElem.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,13 @@ abbrev get_drop_eq_drop := @getElem_cons_drop_succ_eq_drop
264264
/-! ### getElem? -/
265265

266266
/-- Internal implementation of `as[i]?`. Do not use directly. -/
267-
private def get?Internal : (as : List α) → (i : Nat) → Option α
267+
def get?Internal : (as : List α) → (i : Nat) → Option α
268268
| a::_, 0 => some a
269269
| _::as, n+1 => get?Internal as n
270270
| _, _ => none
271271

272272
/-- Internal implementation of `as[i]!`. Do not use directly. -/
273-
private def get!Internal [Inhabited α] : (as : List α) → (i : Nat) → α
273+
def get!Internal [Inhabited α] : (as : List α) → (i : Nat) → α
274274
| a::_, 0 => a
275275
| _::as, n+1 => get!Internal as n
276276
| _, _ => panic! "invalid index"

src/Init/Meta.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Additional goodies for writing macros
88
module
99

1010
prelude
11+
import all Init.Prelude -- for unfolding `Name.beq`
1112
import Init.MetaTypes
1213
import Init.Syntax
1314
import Init.Data.Array.GetLit
@@ -1190,7 +1191,7 @@ instance : Quote Nat numLitKind := ⟨fun n => Syntax.mkNumLit <| toString n⟩
11901191
instance : Quote Substring := ⟨fun s => Syntax.mkCApp ``String.toSubstring' #[quote s.toString]⟩
11911192

11921193
-- in contrast to `Name.toString`, we can, and want to be, precise here
1193-
private def getEscapedNameParts? (acc : List String) : Name → Option (List String)
1194+
def getEscapedNameParts? (acc : List String) : Name → Option (List String)
11941195
| Name.anonymous => if acc.isEmpty then none else some acc
11951196
| Name.str n s => do
11961197
let s ← Name.escapePart s
@@ -1211,14 +1212,14 @@ instance [Quote α `term] [Quote β `term] : Quote (α × β) `term where
12111212
quote
12121213
| ⟨a, b⟩ => Syntax.mkCApp ``Prod.mk #[quote a, quote b]
12131214

1214-
private def quoteList [Quote α `term] : List α → Term
1215+
def quoteList [Quote α `term] : List α → Term
12151216
| [] => mkCIdent ``List.nil
12161217
| (x::xs) => Syntax.mkCApp ``List.cons #[quote x, quoteList xs]
12171218

12181219
instance [Quote α `term] : Quote (List α) `term where
12191220
quote := quoteList
12201221

1221-
private def quoteArray [Quote α `term] (xs : Array α) : Term :=
1222+
def quoteArray [Quote α `term] (xs : Array α) : Term :=
12221223
if xs.size <= 8 then
12231224
go 0 #[]
12241225
else

src/Init/Prelude.lean

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,7 @@ structure Char where
24592459
/-- The value must be a legal scalar value. -/
24602460
valid : val.isValidChar
24612461

2462-
private theorem isValidChar_UInt32 {n : Nat} (h : n.isValidChar) : LT.lt n UInt32.size :=
2462+
theorem isValidChar_UInt32 {n : Nat} (h : n.isValidChar) : LT.lt n UInt32.size :=
24632463
match h with
24642464
| Or.inl h => Nat.lt_trans h (of_decide_eq_true rfl)
24652465
| Or.inr ⟨_, h⟩ => Nat.lt_trans h (of_decide_eq_true rfl)
@@ -4060,8 +4060,13 @@ protected opaque String.hash (s : @& String) : UInt64
40604060
instance : Hashable String where
40614061
hash := String.hash
40624062

4063+
end -- don't expose `Lean` defs
4064+
40634065
namespace Lean
40644066

4067+
open BEq (beq)
4068+
open HAdd (hAdd)
4069+
40654070
/--
40664071
Hierarchical names consist of a sequence of components, each of
40674072
which is either a string or numeric, that are written separated by dots (`.`).
@@ -4146,35 +4151,35 @@ abbrev mkSimple (s : String) : Name :=
41464151
.str .anonymous s
41474152

41484153
/-- Make name `s₁` -/
4149-
@[reducible] def mkStr1 (s₁ : String) : Name :=
4154+
@[expose, reducible] def mkStr1 (s₁ : String) : Name :=
41504155
.str .anonymous s₁
41514156

41524157
/-- Make name `s₁.s₂` -/
4153-
@[reducible] def mkStr2 (s₁ s₂ : String) : Name :=
4158+
@[expose, reducible] def mkStr2 (s₁ s₂ : String) : Name :=
41544159
.str (.str .anonymous s₁) s₂
41554160

41564161
/-- Make name `s₁.s₂.s₃` -/
4157-
@[reducible] def mkStr3 (s₁ s₂ s₃ : String) : Name :=
4162+
@[expose, reducible] def mkStr3 (s₁ s₂ s₃ : String) : Name :=
41584163
.str (.str (.str .anonymous s₁) s₂) s₃
41594164

41604165
/-- Make name `s₁.s₂.s₃.s₄` -/
4161-
@[reducible] def mkStr4 (s₁ s₂ s₃ s₄ : String) : Name :=
4166+
@[expose, reducible] def mkStr4 (s₁ s₂ s₃ s₄ : String) : Name :=
41624167
.str (.str (.str (.str .anonymous s₁) s₂) s₃) s₄
41634168

41644169
/-- Make name `s₁.s₂.s₃.s₄.s₅` -/
4165-
@[reducible] def mkStr5 (s₁ s₂ s₃ s₄ s₅ : String) : Name :=
4170+
@[expose, reducible] def mkStr5 (s₁ s₂ s₃ s₄ s₅ : String) : Name :=
41664171
.str (.str (.str (.str (.str .anonymous s₁) s₂) s₃) s₄) s₅
41674172

41684173
/-- Make name `s₁.s₂.s₃.s₄.s₅.s₆` -/
4169-
@[reducible] def mkStr6 (s₁ s₂ s₃ s₄ s₅ s₆ : String) : Name :=
4174+
@[expose, reducible] def mkStr6 (s₁ s₂ s₃ s₄ s₅ s₆ : String) : Name :=
41704175
.str (.str (.str (.str (.str (.str .anonymous s₁) s₂) s₃) s₄) s₅) s₆
41714176

41724177
/-- Make name `s₁.s₂.s₃.s₄.s₅.s₆.s₇` -/
4173-
@[reducible] def mkStr7 (s₁ s₂ s₃ s₄ s₅ s₆ s₇ : String) : Name :=
4178+
@[expose, reducible] def mkStr7 (s₁ s₂ s₃ s₄ s₅ s₆ s₇ : String) : Name :=
41744179
.str (.str (.str (.str (.str (.str (.str .anonymous s₁) s₂) s₃) s₄) s₅) s₆) s₇
41754180

41764181
/-- Make name `s₁.s₂.s₃.s₄.s₅.s₆.s₇.s₈` -/
4177-
@[reducible] def mkStr8 (s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈ : String) : Name :=
4182+
@[expose, reducible] def mkStr8 (s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈ : String) : Name :=
41784183
.str (.str (.str (.str (.str (.str (.str (.str .anonymous s₁) s₂) s₃) s₄) s₅) s₆) s₇) s₈
41794184

41804185
/-- (Boolean) equality comparator for names. -/
@@ -4423,7 +4428,7 @@ def Syntax.node8 (info : SourceInfo) (kind : SyntaxNodeKind) (a₁ a₂ a₃ a
44234428
Singleton `SyntaxNodeKinds` are extremely common. They are written as name literals, rather than as
44244429
lists; list syntax is required only for empty or non-singleton sets of kinds.
44254430
-/
4426-
def SyntaxNodeKinds := List SyntaxNodeKind
4431+
@[expose] def SyntaxNodeKinds := List SyntaxNodeKind
44274432

44284433
/--
44294434
Typed syntax, which tracks the potential kinds of the `Syntax` it contains.
@@ -5110,7 +5115,8 @@ namespace Macro
51105115
/-- References -/
51115116
private opaque MethodsRefPointed : NonemptyType.{0}
51125117

5113-
private def MethodsRef : Type := MethodsRefPointed.type
5118+
/-- An opaque reference to the `Methods` object. -/
5119+
def MethodsRef : Type := MethodsRefPointed.type
51145120

51155121
private instance : Nonempty MethodsRef := MethodsRefPointed.property
51165122

src/Init/Util.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ def dbgStackTrace {α : Type u} (f : Unit → α) : α := f ()
3232
@[extern "lean_dbg_sleep"]
3333
def dbgSleep {α : Type u} (ms : UInt32) (f : Unit → α) : α := f ()
3434

35-
@[noinline] private def mkPanicMessage (modName : String) (line col : Nat) (msg : String) : String :=
35+
@[noinline] def mkPanicMessage (modName : String) (line col : Nat) (msg : String) : String :=
3636
"PANIC at " ++ modName ++ ":" ++ toString line ++ ":" ++ toString col ++ ": " ++ msg
3737

3838
@[never_extract, inline, expose] def panicWithPos {α : Sort u} [Inhabited α] (modName : String) (line col : Nat) (msg : String) : α :=
3939
panic (mkPanicMessage modName line col msg)
4040

41-
@[noinline, expose] private def mkPanicMessageWithDecl (modName : String) (declName : String) (line col : Nat) (msg : String) : String :=
41+
@[noinline, expose] def mkPanicMessageWithDecl (modName : String) (declName : String) (line col : Nat) (msg : String) : String :=
4242
"PANIC at " ++ declName ++ " " ++ modName ++ ":" ++ toString line ++ ":" ++ toString col ++ ": " ++ msg
4343

4444
@[never_extract, inline, expose] def panicWithPosWithDecl {α : Sort u} [Inhabited α] (modName : String) (declName : String) (line col : Nat) (msg : String) : α :=

src/Init/WF.lean

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,8 @@ end Subrelation
157157
namespace InvImage
158158
variable {α : Sort u} {β : Sort v} {r : β → β → Prop}
159159

160-
private def accAux (f : α → β) {b : β} (ac : Acc r b) : (x : α) → f x = b → Acc (InvImage r f) x := by
161-
induction ac with
162-
| intro x acx ih =>
163-
intro z e
164-
apply Acc.intro
165-
intro y lt
166-
subst x
167-
apply ih (f y) lt y rfl
160+
def accAux (f : α → β) {b : β} (ac : Acc r b) : (x : α) → f x = b → Acc (InvImage r f) x :=
161+
Acc.recOn ac fun _ _ ih => fun _ e => Acc.intro _ (fun y lt => ih (f y) (e ▸ lt) y rfl)
168162

169163
-- `def` for `WellFounded.fix`
170164
def accessible {a : α} (f : α → β) (ac : Acc r (f a)) : Acc (InvImage r f) a :=

0 commit comments

Comments
 (0)