Skip to content

Commit 5d349db

Browse files
committed
doc: define trust in "Validating a Lean Proof"
Trust was previously discussed in an informal way. Trust is now defined along three axes: proof authors, verification software, and correctness of statement. The trust definition is also referred to in "Elaboration and Compilation".
1 parent 34ff5ea commit 5d349db

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

Manual/Elaboration.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ where
7676

7777
#doc (Manual) "Elaboration and Compilation" =>
7878
%%%
79+
tag := "elaboration-compilation"
7980
htmlSplit := .never
8081
%%%
8182

@@ -94,12 +95,12 @@ Roughly speaking, Lean's processing of a source file can be divided into the fol
9495
: Elaboration
9596

9697
{deftech (key := "Lean elaborator") -normalize}[Elaboration] is the process of transforming Lean's user-facing syntax into its core type theory.
97-
This core theory is much simpler, enabling the trusted kernel to be very small.
98+
This core theory is much simpler, enabling the {tech (key := "trust")}[trusted] kernel to be very small.
9899
Elaboration additionally produces metadata, such as proof states or the types of expressions, used for Lean's interactive features, storing them in a side table.
99100

100101
: Kernel Checking
101102

102-
Lean's trusted kernel checks the output of the elaborator to ensure that it follows the rules of the type theory.
103+
Lean's {tech (key := "trust")}[trusted] kernel checks the output of the elaborator to ensure that it follows the rules of the type theory.
103104

104105
: Compilation
105106

Manual/ValidatingProofs.lean

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,30 @@ htmlSplit := .never
2929

3030
This section discusses how to validate a proof expressed in Lean.
3131

32-
Depending on the circumstances, additional steps may be recommended to rule out misleading proofs.
33-
In particular, it matters a lot whether one is dealing with an {tech}[honest] proof attempt, and needs protection against only benign mistakes, or a possibly-{tech}[malicious] proof attempt that actively tries to mislead.
32+
The steps needed to rule out a misleading proof depend on the author's {deftech}[trust] assumptions towards the _proof author_ (including authors that proved depended-upon theorems), the _verification software_, and the _correctness of the statement_.
3433

35-
In particular, we use {deftech}_honest_ when the goal is to create a valid proof.
36-
This allows for mistakes and bugs in proofs and meta-code (tactics, attributes, commands, etc.), but not for code that clearly only serves to circumvent the system (such as using the {option}`debug.skipKernelTC`).
37-
Note that the {keyword}`unsafe` marker on API functions is unrelated to whether this API can be used in an dishonest way.
34+
* Regarding the _proof author_, it matters a lot whether one is dealing with an {tech}[honest] proof attempt, and needs protection against only benign mistakes, or a possibly-{tech}[malicious] proof attempt that actively tries to mislead.
3835

39-
In contrast, we use {deftech}_malicious_ to describe code that goes out of its way to trick or mislead the user, exploit bugs or compromise the system.
40-
This includes un-reviewed AI-generated proofs and programs.
36+
In particular, we use {deftech}_honest_ when the goal is to create a valid proof.
37+
This allows for mistakes and bugs in proofs and meta-code (tactics, attributes, commands, etc.), but not for code that clearly only serves to circumvent the system (such as using the {option}`debug.skipKernelTC`).
38+
Note that the {keyword}`unsafe` marker on API functions is unrelated to whether this API can be used in an dishonest way.
4139

42-
Furthermore it is important to distinguish the question “does the theorem have a valid proof” fromwhat does the theorem statement mean”.
40+
In contrast, we use {deftech}_malicious_ to describe code that goes out of its way to trick or mislead the user, exploit bugs or compromise the system.
41+
This includes un-reviewed AI-generated proofs and programs.
42+
43+
* Regarding the verification software, Lean takes {ref "elaboration-compilation"}[a number of steps] to process a theorem and its proof.
44+
Different uses correspond to trusting different steps of this pipeline.
45+
At a minimum, the Lean kernel or an alternative kernel such as [`nanoda`](https://github.com/ammkrn/nanoda_lib) has to be trusted.
46+
47+
* Regarding the correctness of the statement, it is important to distinguish the question “does the theorem have a valid proof” fromwhat does the theorem statement mean”.
48+
No matter what software is used and how trusted the environment is, a theorem is meaningful only if its author(s) and user(s) are certain that its statement mathematically expresses its intended informal meaning.
49+
50+
As written, the statement is {tech (key := "Lean elaborator")}[elaborated] before being passed to the kernel.
51+
To avoid trusting the {tech (key := "Lean elaborator")}[elaborator], one has to {keywordOf Lean.Parser.Command.print}`#print` the statement to get the elaborated type and manually verify that it indeed expresses the desired statement.
52+
This brings {keywordOf Lean.Parser.Command.print}`#print` into the trusted base, which is less than 1000 lines of code.
4353

4454
Below, an escalating sequence of checks are presented, with instructions on how to perform them, an explanation of what they entail and the mistakes or attacks they guard against.
55+
To avoid repetition, we will not discuss trust towards the correctness of the statement every time.
4556

4657
# The Blue Double Check Marks
4758
%%%
@@ -64,7 +75,7 @@ The blue ticks indicate that the theorem statement has been successfully elabora
6475

6576
## Trust
6677

67-
This check is meaningful if one believes the formal theorem statement corresponds to its intended informal meanings and trusts the authors of the imported libraries to be {tech}[honest], that they checked that the theorems in their libraries express their intended informal meanings, and that no unsound axioms have been declared and used.
78+
This check is meaningful if one trusts the authors of the imported libraries to be {tech}[honest], that they checked that the theorems in their libraries express their intended informal meanings, and that no unsound axioms have been declared and used.
6879

6980
## Protection
7081

@@ -115,7 +126,7 @@ The three axioms above are standard axioms of Lean's logic, and benign.
115126

116127
## Trust
117128

118-
This check is meaningful if one believes the formal theorem statement corresponds to its intended informal meanings and one trusts the authors of the imported libraries to be {tech}[honest].
129+
This check is meaningful if one trusts the authors of the imported libraries to be {tech}[honest].
119130

120131
## Protection
121132

@@ -145,7 +156,7 @@ It trusts that the {tech}[`.olean` files] are structurally correct.
145156

146157
## Trust
147158

148-
This check is meaningful if one believes the formal theorem statement corresponds to its intended informal meanings and believes the authors of the imported libraries to not be very cunningly {tech}[malicious], and to neither compromise the user’s system nor use Lean’s extensibility to change the interpretation of the theorem statement.
159+
This check is meaningful if one believes the authors of the imported libraries to not be very cunningly {tech}[malicious], and to neither compromise the user’s system nor use Lean’s extensibility to change the interpretation of the theorem statement.
149160

150161
## Protection
151162

0 commit comments

Comments
 (0)