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
{{ message }}
This repository was archived by the owner on Jan 5, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: Manual/BasicTypes.lean
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -131,7 +131,7 @@ tag := "char-runtime"
131
131
%%%
132
132
133
133
134
-
In monomorphic contexts, characters are represented as 32-bit immediate values. In other words, a field of a constructor or structureoftype `Char`doesnotrequireindirectiontoaccess.Inpolymorphiccontexts,charactersareboxed.
134
+
In monomorphic contexts, characters are represented as 32-bit immediate values. In other words, a field of a constructor or structureoftype{lean}`Char` does not require indirection to access. In polymorphic contexts, characters are boxed.
Copy file name to clipboardExpand all lines: Manual/Elaboration.lean
+27-3Lines changed: 27 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -201,13 +201,16 @@ In practice, apparent non-termination is indistinguishable from sufficiently slo
201
201
These metatheoretic properties are a result of having impredicativity, quotient types that compute, definitional proof irrelevance, and propositional extensionality; these features are immensely valuable both to support ordinary mathematical practice and to enable automation.
202
202
203
203
# Elaboration Results
204
+
%%%
205
+
tag := "elaboration-results"
206
+
%%%
204
207
205
208
Lean's core type theory does not include pattern matching or recursive definitions.
206
209
Instead, it provides low-level {tech}[recursors] that can be used to implement both case distinction and primitive recursion.
207
-
Thus, the elaborator must translate definitions that use pattern matching and recursion into definitions that use recursors.
210
+
Thus, the elaborator must translate definitions that use pattern matching and recursion into definitions that use recursors.{margin}[More details on the elaboration of recursive definitions is available in the {ref "recursive-definitions"}[dedicated section] on the topic.]
208
211
This translation is additionally a proof that the function terminates for all potential arguments, because all functions that can be translated to recursors also terminate.
209
212
210
-
The translation to recursors happens in two phases: during term elaboration, uses of pattern matching are replaced by appeals to auxiliary functions that implement the particular case distinction that occurs in the code.
213
+
The translation to recursors happens in two phases: during term elaboration, uses of pattern matching are replaced by appeals to {deftech}_auxiliary matching functions_ that implement the particular case distinction that occurs in the code.
211
214
These auxiliary functions are themselves defined using recursors, though they do not make use of the recursors' ability to actually implement recursive behavior.{margin}[They use the `casesOn` construction that is described in the {ref "recursor-elaboration-helpers"}[section on recursors and elaboration].]
212
215
The term elaborator thus returns core-language terms in which pattern matching has been replaced with the use of special functions that implement case distinction, but these terms may still contain recursive occurrences of the function being defined.
213
216
To see auxiliary pattern matching functions in Lean's output, set the option {option}`pp.match` to {lean}`false`.
@@ -251,11 +254,12 @@ This split is for three reasons:
251
254
* The compiler can compile {ref "partial-unsafe"}[`partial` functions] that the kernel treats as opaque constants for the purposes of reasoning.
252
255
* The compiler can also compile {ref "partial-unsafe"}[`unsafe` functions] that bypass the kernel entirely.
253
256
* Translation to recursors does not necessarily preserve the cost model expected by programmers, in particular laziness vs strictness, but compiled code must have predictable performance.
257
+
254
258
The compiler stores an intermediate representation in an environment extension.
255
259
256
260
For straightforwardly structurally recursive functions, the translation will use the type's recursor.
257
261
These functions tend to be relatively efficient when run in the kernel, their defining equations hold definitionally, and they are easy to understand.
258
-
Functions that use other patterns of recursion that cannot be captured by the type's recursor are translated using {deftech}[well-founded recursion], which is structural recursion on a proof that some measure decreases at each recursive call.
262
+
Functions that use other patterns of recursion that cannot be captured by the type's recursor are translated using {deftech}[well-founded recursion], which is structural recursion on a proof that some {deftech}_measure_ decreases at each recursive call.
259
263
Lean can automatically derive many of these cases, but some require manual proofs.
260
264
Well-founded recursion is more flexible, but the resulting functions are often slower to execute in the kernel due to the proof terms that show that a measure decreases, and their defining equations may hold only propositionally.
261
265
To provide a uniform interface to functions defined via structural and well-founded recursion and to check its own correctness, the elaborator proves equational lemmas that relate the function to its original definition.
@@ -377,6 +381,26 @@ A C file is produced for each Lean module; these are then compiled to native cod
377
381
If the `precompileModules` option is set in the build configuration, then this native code can be dynamically loaded and invoked by Lean; otherwise, an interpreter is used.
378
382
For most workloads, the overhead of compilation is larger than the time saved by avoiding the interpreter, but some workloads can be sped up dramatically by pre-compiling tactics, language extensions, or other extensions to Lean.
379
383
384
+
## Memory Allocation and Reference Counting
385
+
386
+
:::planned 208
387
+
388
+
The most important topics related to Lean's reference-counting-based allocator:
389
+
390
+
* Overview of {deftech key:="reference count"}_reference counting_
391
+
392
+
* Compact regions
393
+
394
+
* When are counts incremented and decremented?
395
+
396
+
* Tools for debugging uniqueness issues
397
+
398
+
* When should C code increment or decrement reference counts?
399
+
400
+
* What is the meaning of the borrow annotation (`@&`)?
Copy file name to clipboardExpand all lines: Manual/Language/Classes/BasicClasses.lean
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,9 @@ Many Lean type classes exist in order to allow built-in notations such as additi
37
37
{docstring LE}
38
38
39
39
# Decidability
40
+
%%%
41
+
tag := "decidable-propositions"
42
+
%%%
40
43
41
44
A proposition is {deftech}_decidable_ if it can be checked algorithmically.{index}[decidable]{index subterm:="decidable"}[proposition]
42
45
The Law of the Excluded Middle means that every proposition is true or false, but it provides no way to check which of the two cases holds, which can often be useful.
0 commit comments