Skip to content

Commit ae00aec

Browse files
chore: bump to nightly-2025-06-23 (#477)
1 parent 860abdb commit ae00aec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+347
-266
lines changed

Manual/Axioms.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ partial def List.length' : List α → Nat
147147
| _ :: xs => xs.length' + 1
148148
```
149149
```leanOutput otherZero2
150-
failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Nat.otherZero', and it does not have executable code
150+
axiom 'Nat.otherZero' not supported by code generator; consider marking definition as 'noncomputable'
151151
```
152152

153153
Axioms used in proofs rather than programs do not prevent a function from being compiled.

Manual/BasicProps.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,9 @@ end
418418

419419
:::::leanSection
420420
::::example "Heterogeneous Equality"
421-
````lean (show := false)
421+
```lean (show := false)
422422
variable {α : Type u} {n k l₁ l₂ l₃ : Nat}
423-
````
423+
```
424424

425425
The type {lean}`Vector α n` is wrapper around an {lean}`Array α` that includes a proof that the array has size {lean}`n`.
426426
Appending {name}`Vector`s is associative, but this fact cannot be straightforwardly stated using ordinary propositional equality:

Manual/BasicTypes/Array/FFI.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ The representation of arrays in C. See {ref "array-runtime"}[the description of
3333
:::
3434

3535
:::ffi "lean_is_array"
36-
````
36+
```
3737
bool lean_is_array(lean_object * o)
38-
````
38+
```
3939

4040
Returns `true` if `o` is an array, or `false` otherwise.
4141
:::
4242

4343
:::ffi "lean_to_array"
44-
````
44+
```
4545
lean_array_object * lean_to_array(lean_object * o)
46-
````
46+
```
4747
Performs a runtime check that `o` is indeed an array. If `o` is not an array, an assertion fails.
4848
:::
4949

Manual/BasicTypes/Maps.lean

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,12 @@ structure Maze where
195195
This definition is rejected:
196196

197197
```leanOutput badNesting
198-
(kernel) arg #1 of '_nested.Std.HashMap_1.mk' contains a non valid occurrence of the datatypes being declared
198+
(kernel) application type mismatch
199+
DHashMap.Raw.WF inner
200+
argument has type
201+
_nested.Std.DHashMap.Raw_3
202+
but function has type
203+
(DHashMap.Raw String fun x => Maze) → Prop
199204
```
200205

201206
Making this work requires separating the well-formedness predicates from the structure.

Manual/BasicTypes/String/FFI.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ The representation of strings in C. See {ref "string-runtime"}[the description o
3737
:::
3838

3939
:::ffi "lean_is_string"
40-
````
40+
```
4141
bool lean_is_string(lean_object * o)
42-
````
42+
```
4343

4444
Returns `true` if `o` is a string, or `false` otherwise.
4545
:::
4646

4747
:::ffi "lean_to_string"
48-
````
48+
```
4949
lean_string_object * lean_to_string(lean_object * o)
50-
````
50+
```
5151
Performs a runtime check that `o` is indeed a string. If `o` is not a string, an assertion fails.
5252
:::
5353

Manual/BasicTypes/UInt.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def Permissions.decode (i : UInt8) : Permissions :=
103103
theorem Permissions.decode_encode (p : Permissions) : p = .decode (p.encode) := by
104104
let ⟨r, w, x⟩ := p
105105
cases r <;> cases w <;> cases x <;>
106-
simp +decide [encode, decode]
106+
simp +decide [decode]
107107
```
108108
:::
109109

Manual/BuildTools/Lake.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ Because they are Lean definitions, Lake scripts can only be defined in the Lean
479479

480480
Restore the following once we can import enough of Lake to elaborate it
481481

482-
`````
482+
````
483483
```lean (show := false)
484484
section
485485
open Lake DSL
@@ -507,7 +507,7 @@ script "list-deps" := do
507507
```lean (show := false)
508508
end
509509
```
510-
`````
510+
````
511511

512512
:::::
513513

@@ -525,7 +525,7 @@ Lint drivers may be executables or scripts, which are run by {lake}`lint`.
525525
A test or lint driver can be configured by either setting the {tomlField Lake.PackageConfig}`testDriver` or {tomlField Lake.PackageConfig}`lintDriver` package configuration options or by tagging a script, executable, or library with the `test_driver` or `lint_driver` attribute in a Lean-format configuration file.
526526
A definition in a dependency can be used as a test or lint driver by using the `<pkg>/<name>` syntax for the appropriate configuration option.
527527
:::TODO
528-
Restore the ``{attr}`` role for `test_driver` and `lint_driver` above. Right now, importing the attributes crashes the compiler.
528+
Restore the `{attr}` role for `test_driver` and `lint_driver` above. Right now, importing the attributes crashes the compiler.
529529
:::
530530

531531
## GitHub Release Builds

Manual/BuildTools/Lake/CLI.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ Other hosts are not yet supported.
918918

919919
## Cached Cloud Builds
920920

921-
**These commands are still experimental.**
921+
*These commands are still experimental.*
922922
They are likely change in future versions of Lake based on user feedback.
923923
Packages that use Reservoir cloud build archives should enable the {tomlField Lake.PackageConfig}`platformIndependent` setting.
924924

Manual/Classes.lean

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ use the command `set_option checkBinderAnnotations false` to disable the check
158158

159159
::::example "Class vs Structure Constructors"
160160
A very small algebraic hierarchy can be represented either as structures ({name}`S.Magma`, {name}`S.Semigroup`, and {name}`S.Monoid` below), a mix of structures and classes ({name}`C1.Monoid`), or only using classes ({name}`C2.Magma`, {name}`C2.Semigroup`, and {name}`C2.Monoid`):
161-
````lean
161+
```lean
162162
namespace S
163163
structure Magma (α : Type u) where
164164
op : α → α → α
@@ -191,7 +191,7 @@ class Monoid (α : Type u) extends Semigroup α where
191191
ident_left : ∀ x, op ident x = x
192192
ident_right : ∀ x, op x ident = x
193193
end C2
194-
````
194+
```
195195

196196

197197
{name}`S.Monoid.mk` and {name}`C1.Monoid.mk` have identical signatures, because the parent of the class {name}`C1.Monoid` is not itself a class:
@@ -257,7 +257,7 @@ Two instances of the same class with the same parameters are not necessarily ide
257257
::::example "Instances are Not Unique"
258258

259259
This implementation of binary heap insertion is buggy:
260-
````lean
260+
```lean
261261
structure Heap (α : Type u) where
262262
contents : Array α
263263
deriving Repr
@@ -274,7 +274,7 @@ def Heap.bubbleUp [Ord α] (i : Nat) (xs : Heap α) : Heap α :=
274274
def Heap.insert [Ord α] (x : α) (xs : Heap α) : Heap α :=
275275
let i := xs.contents.size
276276
{xs with contents := xs.contents.push x}.bubbleUp i
277-
````
277+
```
278278

279279
The problem is that a heap constructed with one {name}`Ord` instance may later be used with another, leading to the breaking of the heap invariant.
280280

@@ -283,7 +283,9 @@ One way to correct this is to making the heap type depend on the selected `Ord`
283283
structure Heap' (α : Type u) [Ord α] where
284284
contents : Array α
285285

286-
def Heap'.bubbleUp [inst : Ord α] (i : Nat) (xs : @Heap' α inst) : @Heap' α inst :=
286+
def Heap'.bubbleUp [inst : Ord α]
287+
(i : Nat) (xs : @Heap' α inst) :
288+
@Heap' α inst :=
287289
if h : i = 0 then xs
288290
else if h : i ≥ xs.contents.size then xs
289291
else

Manual/Coercions.lean

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def tomorrow : Later String :=
354354
section
355355
variable {α : Type u}
356356
```
357-
:::example "Duplicate Evaluation in Coercions"
357+
::::example "Duplicate Evaluation in Coercions"
358358
Because the contents of {lean}`Coe` instances are unfolded during coercion insertion, coercions that use their argument more than once should be careful to ensure that evaluation occurs just once.
359359
This can be done by using a helper function that is not part of the instance, or by using {keywordOf Lean.Parser.Term.let}`let` to evaluate the coerced term and then re-use its resulting value.
360360

@@ -378,47 +378,58 @@ def twice (x : α) : Twice α where
378378
instance : Coe α (Twice α) := ⟨twice⟩
379379
```
380380
When the {name}`Coe` instance is unfolded, the call to {name}`twice` remains, which causes its argument to be evaluated before the body of the function is executed.
381-
As a result, the {keywordOf Lean.Parser.Term.dbgTrace}`dbg_trace` executes just once:
381+
As a result, the {keywordOf Lean.Parser.Term.dbgTrace}`dbg_trace` is included in the resulting term just once:
382382
```lean (name := eval1)
383-
#eval ((dbg_trace "hello"; 5 : Nat) : Twice Nat)
383+
#check ((dbg_trace "hello"; 5 : Nat) : Twice Nat)
384384
```
385+
:::comment
386+
This used to demonstrate the effect:
385387
```leanOutput eval1
386388
hello
387389
```
390+
:::
388391
```leanOutput eval1
389-
{ first := 5, second := 5, first_eq_second := _ }
392+
↑(dbgTrace (toString "hello") fun x => 5) : Twice Nat
390393
```
391394

392395
Inlining the helper into the {name}`Coe` instance results in a term that duplicates the {keywordOf Lean.Parser.Term.dbgTrace}`dbg_trace`:
393396
```lean (name := eval2)
394397
instance : Coe α (Twice α) where
395398
coe x := ⟨x, x, rfl⟩
396399

397-
#eval ((dbg_trace "hello"; 5 : Nat) : Twice Nat)
400+
#check ((dbg_trace "hello"; 5 : Nat) : Twice Nat)
398401
```
402+
:::comment
403+
This used to check the effects, but can't in the new codegen
399404
```leanOutput eval2
400405
hello
401406
hello
402407
```
408+
:::
403409
```leanOutput eval2
404-
{ first := 5, second := 5, first_eq_second := _ }
410+
{ first := dbgTrace (toString "hello") fun x => 5, second := dbgTrace (toString "hello") fun x => 5,
411+
first_eq_second := ⋯ } : Twice Nat
405412
```
406413

407-
Introducing an intermediate name for the result of the evaluation prevents the duplicated work:
414+
Introducing an intermediate name for the result of the evaluation prevents the duplication of {keywordOf Lean.Parser.Term.dbgTrace}`dbg_trace`:
408415
```lean (name := eval3)
409416
instance : Coe α (Twice α) where
410417
coe x := let y := x; ⟨y, y, rfl⟩
411418

412-
#eval ((dbg_trace "hello"; 5 : Nat) : Twice Nat)
419+
#check ((dbg_trace "hello"; 5 : Nat) : Twice Nat)
413420
```
421+
:::comment
422+
This also checked the effects
414423
```leanOutput eval3
415424
hello
416425
```
426+
:::
417427
```leanOutput eval3
418-
{ first := 5, second := 5, first_eq_second := _ }
428+
let y := dbgTrace (toString "hello") fun x => 5;
429+
{ first := y, second := y, first_eq_second := ⋯ } : Twice Nat
419430
```
420431

421-
:::
432+
::::
422433
```lean (show := false)
423434
end
424435
```
@@ -485,12 +496,12 @@ Non-dependent coercions are used whenever all values of the inferred type can be
485496

486497
:::example "Defining Dependent Coercions"
487498
The string "four" can be coerced into the natural number {lean type:="Nat"}`4` with this instance declaration:
488-
````lean (name := fourCoe)
499+
```lean (name := fourCoe)
489500
instance : CoeDep String "four" Nat where
490501
coe := 4
491502

492503
#eval ("four" : Nat)
493-
````
504+
```
494505
```leanOutput fourCoe
495506
4
496507
```

0 commit comments

Comments
 (0)