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/Elaboration.lean
+3-23Lines changed: 3 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ Author: David Thrane Christiansen
6
6
import VersoManual
7
7
8
8
import Manual.Meta
9
+
import Manual.Papers
9
10
10
11
open Verso.Genre Manual
11
12
@@ -14,27 +15,6 @@ set_option pp.rawOnError true
14
15
open Lean (Syntax SourceInfo)
15
16
16
17
17
-
defpratt73 : InProceedings where
18
-
title := .concat (inlines!"Top down operator precedence")
19
-
authors := #[.concat (inlines!"Vaughan Pratt")]
20
-
year := 1973
21
-
booktitle := .concat (inlines!"Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages")
22
-
23
-
defcarneiro19 : Thesis where
24
-
title := .concat (inlines!"The Type Theory of Lean")
25
-
author := .concat (inlines!"Mario Carneiro")
26
-
year := 2019
27
-
university := .concat (inlines!"Carnegie Mellon University")
28
-
url := some "https://github.com/digama0/lean-type-theory/releases/download/v1.0/main.pdf"
29
-
degree := .concat (inlines!"Masters thesis")
30
-
31
-
defullrich23 : Thesis where
32
-
title := .concat (inlines!"An Extensible Theorem Proving Frontend")
33
-
author := .concat (inlines!"Sebastian Ullrich")
34
-
year := 2023
35
-
university := .concat (inlines!"Karlsruhe Institute of Technology")
36
-
url := some "https://www.lean-lang.org/papers/thesis-sebastian.pdf"
37
-
degree := .concat (inlines!"Dr. Ing. dissertation")
38
18
39
19
#doc (Manual) "Elaboration and Compilation" =>
40
20
%%%
@@ -92,7 +72,7 @@ tag := "parser"
92
72
Lean's parser is a recursive-descent parser that uses dynamic tables based on Pratt parsing{citep pratt73}[] to resolve operator precedence and associativity.
93
73
When grammars are unambiguous, the parser does not need to backtrack; in the case of ambiguous grammars, a memoization table similar to that used in Packrat parsing avoids exponential blowup.
94
74
Parsers are highly extensible: users may define new syntaxin any command, and that syntax becomes available in the next command.
95
-
The open namespaces in the current {tech}[scope] also influences which parsing rules are used, because parser extensions may be set to be active only when a given namespace is open.
75
+
The open namespaces in the current {tech}[sectionscope] also influence which parsing rules are used, because parser extensions may be set to be active only when a given namespace is open.
96
76
97
77
When ambiguity is encountered, the longest matching parse is selected.
98
78
If there is no unique longest match, then both matching parses are saved in the syntax tree in a {deftech}[choice node] to be resolved later by the elaborator.
@@ -127,7 +107,7 @@ Elaboration of both commands and terms may be recursive, both because of command
127
107
Command and term elaboration have different capabilities.
128
108
Command elaboration may have side effects on an environment, and it has access to run arbitrary computations in {lean}`IO`.
129
109
Lean environments contain the usual mapping from names to definitions along with additional data defined in {deftech}[environment extensions], which are additional tables associated with an environment; environment extensions are used to track most other information about Lean code, including {tactic}`simp` lemmas, custom pretty printers, and internals such as the compiler's intermediate representations.
130
-
Command elaboration also maintains a message log with the contents of the compiler's informational output, warnings, and errors, a set of {tech}[info trees] that associate metadata with the original syntax (used for interactive features such as displaying proof states, identifier completion, and showing documentation), accumulated debugging traces, the open {tech}[scopes], and some internal state related to macro expansion.
110
+
Command elaboration also maintains a message log with the contents of the compiler's informational output, warnings, and errors, a set of {tech}[info trees] that associate metadata with the original syntax (used for interactive features such as displaying proof states, identifier completion, and showing documentation), accumulated debugging traces, the open {tech}[sectionscopes], and some internal state related to macro expansion.
131
111
Term elaboration may modify all of these fields except the open scopes.
132
112
Additionally, it has access to all the machinery needed to create fully-explicit terms in the core language from Lean's terse, friendly syntax, including unification, type classinstancesynthesis,andtypechecking.
Copy file name to clipboardExpand all lines: Manual/Language.lean
+44-3Lines changed: 44 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -468,7 +468,7 @@ unknown universe level 'v'
468
468
```
469
469
:::
470
470
471
-
In addition to using `autoImplicit`, particular identifiers can be declared as universe variables in a particular {tech}[scope] using the `universe` command.
471
+
In addition to using `autoImplicit`, particular identifiers can be declared as universe variables in a particular {tech}[sectionscope] using the `universe` command.
472
472
473
473
:::syntax Lean.Parser.Command.universe
474
474
```grammar
@@ -712,19 +712,36 @@ tag := "scopes"
712
712
713
713
::: planned 54
714
714
715
-
Many commands have an effect for the current {deftech key:="scope"}[_section scope_] (sometimes just called "scope" when clear).
715
+
Many commands have an effect for the current {deftech}[_section scope_] (sometimes just called "scope" when clear).
716
716
A section scope ends when a namespace ends, a section ends, or a file ends.
717
717
They can also be anonymously and locally created via `in`.
718
718
Section scopes track the following:
719
719
* The {deftech}_current namespace_
720
-
* The {deftech}_open namespaces_
720
+
* The {deftech key:="open namespace"}_open namespaces_
721
721
* The values of all {deftech}_options_
722
722
* Variable and universe declarations
723
723
724
724
This section will describe this mechanism.
725
725
726
726
:::
727
727
728
+
:::syntax attrKind (open := false)
729
+
Globally-scoped declarations (the default) are in effect whenever the {tech}[module] in which they're established is transitively imported.
730
+
They are indicated by the absence of another scope modifier.
731
+
```grammar
732
+
```
733
+
734
+
Locally-scoped declarations are in effect only for the extent of the {tech}[section scope] in which they are established.
735
+
```grammar
736
+
local
737
+
```
738
+
739
+
Scoped declarations are in effect whenever the {tech key:="open namespace"}[namespace] in which they are established is opened.
740
+
```grammar
741
+
scoped
742
+
```
743
+
:::
744
+
728
745
# Axioms
729
746
730
747
:::planned 78
@@ -774,6 +791,18 @@ This section will describe `partial` and `unsafe` definitions:
774
791
775
792
:::
776
793
794
+
# Attributes
795
+
%%%
796
+
tag := "attributes"
797
+
%%%
798
+
799
+
:::planned 144
800
+
* Concrete syntax of {deftech}[attributes]
801
+
* Use cases
802
+
* Scope
803
+
* When can they be added?
804
+
:::
805
+
777
806
{include0 Manual.Language.Classes}
778
807
779
808
# Dynamic Typing
@@ -785,3 +814,15 @@ This section will describe `partial` and `unsafe` definitions:
The {lean}`Coe` classrepresentsautomatically-insertedcoercionsfromonetypetoanother,and {lean}`MonadLift` represents a way to run operations with one kind of effect in a context that expects another kind.
84
84
* Type classes can represent a framework of type-driven code generation, where instances for polymorphic types each contribute some portion of a final program.
85
-
The {name}`Repr` classdefinesacanonicalpretty-printerforatype,andpolymorphictypesendupwith polymorphic {name}`Repr` instances.
85
+
The {name}`Repr` classdefinesacanonicalprettyprinterforatype,andpolymorphictypesendupwith polymorphic {name}`Repr` instances.
86
86
When pretty printing is finally invoked on an expression with a known concrete type, such as {lean}`List (Nat × (String ⊕ Int))`, the resulting pretty printer contains code assembled from the {name}`Repr` instances for {name}`List`, {name}`Prod`, {name}`Nat`, {name}`Sum`, {name}`String`, and {name}`Int`.
87
87
88
88
# Class Declarations
@@ -285,7 +285,6 @@ The problem is that a heap constructed with one {name}`Ord` instance may later b
285
285
286
286
One way to correct this is to making the heap type depend on the selected `Ord` instance:
Copy file name to clipboardExpand all lines: Manual/Language/Files.lean
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,7 @@ tag := "keywords-and-identifiers"
87
87
%%%
88
88
89
89
90
-
An {deftech}[identifier] consists of one or more identifier components, separated by `'.'`.{index}[identifier]
90
+
An {tech}[identifier] consists of one or more identifier components, separated by `'.'`.{index}[identifier]
91
91
92
92
{deftech}[Identifier components] consist of a letter or letter-like character or an underscore (`'_'`), followed by zero or more identifier continuation characters.
93
93
Letters are English letters, upper- or lowercase, and the letter-like characters include a range of non-English alphabetic scripts, including the Greek script which is widely used in Lean, as well as the members of the Unicode letter-like symbol block, which contains a number of double-struck characters (including `ℕ` and `ℤ`) and abbreviations.
0 commit comments