You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Manual/Runtime.lean
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -368,7 +368,6 @@ For simple examples of how to call foreign code from Lean and vice versa, see [t
368
368
## The Lean ABI
369
369
370
370
:::leanSection
371
-
372
371
```lean -show
373
372
variable {α₁ αₙ β αᵢ}
374
373
privateaxiom «α₂→…→αₙ₋₁».{u} : Type u
@@ -402,6 +401,7 @@ In the case of {attr}`extern`, all {tech}[irrelevant] types are removed first.
402
401
tag := "ffi-types"
403
402
%%%
404
403
404
+
:::leanSection
405
405
```lean -show
406
406
universe u
407
407
variable (p : Prop)
@@ -422,9 +422,11 @@ In the {tech (key := "application binary interface")}[ABI], Lean types are trans
422
422
Itisthesameasthe {ref "run-time-inductives"}[run-time representation] of these types.
423
423
Its runtime value is either a pointer to an object of a subtype of {c}`lean_object` (see the “Inductive types” section below) or it is the value {c}`lean_box(cidx)` for the {c}`cidx`th constructor of an inductivetypeifthisconstructordoesnothaveanyrelevantparameters.
424
424
425
-
```lean -show
426
-
variable (u : Unit)
427
-
```
425
+
:::
426
+
427
+
```lean -show
428
+
variable (u : Unit)
429
+
```
428
430
429
431
:::example"`Unit` in the ABI"
430
432
The runtime value of {lean}`u`` : `{lean}`Unit` is always `lean_box(0)`.
This function is correct if it returns {name}`true` for every list that satisfies {name}`List.Nodup` and {name}`false` for every list that does not.
221
250
Just as it was in {name}`mySum`, the use of {keywordOf Lean.Parser.Term.do}`do`-notation and the {name}`Id` monad is an internal implementation detail of {name}`nodup`.
222
251
Thus, the proof begins byusing {name}`Id.of_wp_run_eq` to make the proof state amenable to {tactic}`mvcgen`:
@@ -226,13 +255,13 @@ theorem nodup_correct (l : List Int) : nodup l ↔ l.Nodup := by
226
255
apply Id.of_wp_run_eq h
227
256
mvcgen
228
257
invariants
229
-
· Invariant.withEarlyReturn
258
+
· withEarlyReturn
230
259
(onReturn := fun ret seen => ⌜ret = false ∧ ¬l.Nodup⌝)
231
260
(onContinue := fun xs seen =>
232
261
⌜(∀ x, x ∈ seen ↔ x ∈ xs.prefix) ∧ xs.prefix.Nodup⌝)
233
262
with grind
234
263
```
235
-
:::
264
+
::::
236
265
237
266
238
267
:::paragraph
@@ -262,7 +291,7 @@ end
262
291
:::
263
292
264
293
:::paragraph
265
-
Note that the form `mvcgen invariants?` will suggest an initial invariantusing {name}`Invariant.withEarlyReturn`, so there is no need to memorize the exact syntaxfor specifying invariants:
294
+
Note that the form `mvcgen invariants?` will suggest an initial invariant, so there is no need to memorize the exact syntaxfor specifying invariants:
266
295
```lean (name := invariants?)
267
296
example (l : List Int) : nodup l ↔ l.Nodup := by
268
297
generalize h : nodup l = r
@@ -274,9 +303,9 @@ This starting point will not allow the proof to succeed—after all, if the inva
274
303
```leanOutput invariants?
275
304
Try this:
276
305
[apply] invariants
277
-
·
278
-
Invariant.withEarlyReturn (onReturn := fun r letMuts => ⌜l.Nodup ∧ (r = true ↔ l.Nodup)⌝) (onContinue :=
0 commit comments