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
@@ -202,40 +202,11 @@ Uses of this axiom are not intended to occur in finished proofs, as it can be us
202
202
sorryAx {α : Sort u} (synthetic := true) : α
203
203
```
204
204
205
-
Three final axioms do not truly exist for their _mathematical_ content; from a mathematical perspective they prove trivial statements:
206
-
207
-
* ```signature
208
-
Lean.trustCompiler : True
209
-
```
210
-
211
-
* ```signature
212
-
Lean.ofReduceBool (a b : Bool) : Lean.reduceBool a = b → a = b
213
-
```
214
-
* ```signature
215
-
Lean.ofReduceNat (a b : Nat) : Lean.reduceNat a = b → a = b
216
-
```
217
-
218
-
These axioms instead track proofs that depend on the correctness of the entire compiler, and not just on the much smaller {tech}`kernel`.
219
-
220
-
:::example"Creating and Tracking Proofs That Trust the Compiler"
221
-
The functions {name}`Lean.reduceBool` and {name}`Lean.reduceNat` can be invoked to have the compiler perform a calculation; this can greatly improve performance of implementations of proof by reflection.
Copy file name to clipboardExpand all lines: Manual/BasicTypes/BitVec.lean
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -166,8 +166,9 @@ tag := "BitVec-automation"
166
166
%%%
167
167
168
168
In addition to the full suite of automation and tools provided by Lean for every type, the {tactic}`bv_decide` tactic can solve many bitvector-related problems.
169
-
This tactic invokes an external automated theoremprover (`cadical`) and reconstructs the proof that it provides in Lean's own logic.
170
-
The resulting proofs rely only on the axiom {name}`Lean.ofReduceBool`;theexternalproverisnotpartofthetrustedcodebase.
169
+
This tactic invokes an external automated theoremprover (`cadical`) and validates the certificate returned by the prover with a checker that's written in Lean and proved sound.
170
+
This verified checker is run as native code because reducing it in the kernel is not feasible for performance reasons.
171
+
Because the kernel does not execute native code, the resulting proof relies on a dedicated axiomthatassertstheoutcomeofthenativecomputation;theexternalproverisnotpartofthetrustedcodebase.
Copy file name to clipboardExpand all lines: Manual/BuildTools/Lake/CLI.lean
+171Lines changed: 171 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ COMMANDS:
42
42
check-lint check if there is a properly configured lint driver
43
43
clean remove build outputs
44
44
shake minimize imports in source files
45
+
challenge judge a solution against a challenge
45
46
env <cmd> <args>... execute a command in Lake's environment
46
47
lean <file> elaborate a Lean file in Lake's context
47
48
update update dependencies and save them to the manifest
@@ -821,6 +822,176 @@ The {lakeMeta}`options` may be:
821
822
822
823
::::
823
824
825
+
# Challenges and External Checkers
826
+
%%%
827
+
tag := "lake-challenge"
828
+
%%%
829
+
830
+
Lake supports invoking {ref "validating-comparator"}[`comparator`] to validate a proof against a challenge, including the use of external checkers.
831
+
This should only be necessary in high-risk scenarios, such as proof marketplaces, high-reward competitions, or when dealing with potentially unaligned AI systems.
832
+
833
+
```lakeHelp challenge
834
+
Judge a solution against a challenge
835
+
836
+
USAGE:
837
+
lake challenge --config <FILE>
838
+
839
+
Establishes that every named theoreminthesolutionprovesthesamestatement
Judges a solution against a {deftech}_challenge_: a trusted configuration that states which theorems must be proved and which axioms are permitted.
912
+
{lake}`challenge` establishes that every named theoreminthesolutionprovesthesamestatementasthechallenge,thatthesolutionusesonlypermittedaxioms,andthatitisacceptedbyLean'skernelaswellasbyeveryconfiguredexternalkernel.
913
+
914
+
ThecurrentLakeworkspaceisconsideredtobethe {deftech}_solution_ project: it should satisfy the specification provided by the challenge.
915
+
The solution is considered untrusted input.
916
+
Its configuration is evaluated, and its code built and exported, inside a [`landrun`](https://github.com/Zouuup/landrun) sandbox, and its {tech}[`.olean` files] are kept out of Lake's own address space.
917
+
Because `landrun` is required, the command is only available on Linux.
918
+
The `landrun` executable name is determined by the {envVar +def}`COMPARATOR_LANDRUN` environment variable, defaulting to `landrun` if this is not set.
919
+
The executable is resolved via the {envVar}`PATH`.
920
+
The export is produced by the toolchain's own `leanexport` executable, so the export format matches the compiler that produced the {tech}[`.olean` files].
921
+
922
+
The challenge author writes the {ref "lake-challenge-config"}[configuration file] in JSON format and distributes it with the challenge.
923
+
Solutions are checked byusing {lake}`challenge` with {lakeOptDef option}`--config=FILE`.
924
+
925
+
The exit code distinguishes an accepted solution (`0`) and a rejected one (`1`) from an environment in which the judgment could not run at all (`2`).
926
+
927
+
This command is a frontend to the [`comparator`](https://github.com/leanprover/comparator) proof-checking pipeline; {ref "validating-comparator"}[the section on validating proofs] describes the security model and the assumptions that remain.
928
+
::::
929
+
930
+
## Configuration
931
+
%%%
932
+
tag := "lake-challenge-config"
933
+
%%%
934
+
935
+
:::paragraph
936
+
The challenge configuration is a JSON file that contains an object with the following keys:
937
+
938
+
: `challenge_module` (required)
939
+
940
+
The name of the {tech}[challenge] module.
941
+
942
+
: `solution_module` (required)
943
+
944
+
The name of the {tech}[solution] module to be checked.
945
+
946
+
: `theorem_names` (required)
947
+
948
+
An array of theoremnames.
949
+
Thesetheoremsshouldbecompleteinthesolution,but {lean}`sorry` in the challenge.
950
+
951
+
: `permitted_axioms` (required)
952
+
953
+
An array of axiomnamesthatarepermittedinthesolution.
954
+
955
+
: `definition_names`
956
+
957
+
An array of names of definitions that should be filled out in the solution.
958
+
959
+
: `external_kernels`
960
+
961
+
An object in which each key names an external checker.
962
+
The value associated with the key is the command to be run, and must be a non-empty array of strings.
963
+
The first element in the array is the executable (found via {envVar}`PATH`), and the remaining elements are its arguments.
964
+
965
+
Each checker runs in the sandbox with one further argument appended to its command.
966
+
A checker whose name contains `noda` receives the path to a generated `nanoda`-style configuration file that specifies the export file and the permitted axioms, while every other checker receives the path to a file that contains the {tech}[solution]'s export.
967
+
A checker signals acceptance by exiting successfully, and the solution must be accepted by every configured checker in addition to Lean's kernel.
968
+
969
+
: `enable_nanoda`
970
+
971
+
A Boolean for which `true` is equivalent to an `external_kernels` entry that maps `"nanoda"` to `["nanoda_bin"]`.
972
+
It may be `true` only when `external_kernels` is empty or omitted.
973
+
974
+
:::
975
+
976
+
## Sandbox
977
+
978
+
:::paragraph
979
+
The sandbox restricts only filesystem writes and outbound TCP connections:
980
+
981
+
* Writes are confined to the project's `.lake` directory.
982
+
* Only dependency resolution may open connections, on ports 443 and 22, the ports used by git's `https` and `ssh` transports.
983
+
984
+
Reads, execution, and network traffic other than TCP are unrestricted.
985
+
:::
986
+
987
+
On Linux kernels that predate the Landlock fix released in Linux 7.1, `landrun` can be escaped through an `AF_UNIX` socket.
988
+
Where that matters, run the command under a wrapper that removes the capability:
* If {name}`sorryAx` is reported, then this theoremoroneofitsdependenciesuses {lean}`sorry` or is otherwise incomplete.
113
-
* If {name}`Lean.trustCompiler` is reported, then native evaluation is used; see below for a discussion.
113
+
* If axioms with {lit}`_native` in their names are reported, then{ref "validating-trustCompiler"}[native evaluation] is used.
114
114
* Any other axiommeansthatacustomaxiomwasdeclaredandused,andthetheoremisonlyvalidrelativetothesoundnessoftheseaxioms.
115
115
116
116
## Trust
@@ -178,7 +178,8 @@ This should only be necessary for high risk scenarios (proof marketplaces, high-
178
178
179
179
## Instructions
180
180
181
-
In a trusted environment, write the theorem *statement* (the “challenge”), and then feed the challenge as well as the proposed proof to the [`comparator`](https://github.com/leanprover/comparator) tool, with external checkers enabled, as documented there.
181
+
In a trusted environment, write the theorem *statement* (the “challenge”), and then judge the proposed proof against it with {ref "lake-challenge"}[`lake challenge`], with external checkers enabled.
182
+
This command is a frontend to the [`comparator`](https://github.com/leanprover/comparator) tool.
182
183
183
184
## Significance
184
185
@@ -227,11 +228,12 @@ This is used by the {tactic}`decide`{keywordOf Lean.Parser.Tactic.decide}` +nati
227
228
Specific uses wrapped in {tech}[honest] tactics (e.g. {tactic}`bv_decide`) are generally trustworthy.
228
229
The trusted code base is larger (it includes Lean's compilation toolchain and library annotations in the standard library), but still fixed and vetted.
229
230
230
-
General use ({tactic}`decide`{keywordOf Lean.Parser.Tactic.decide}` +native` or direct use of {name}`Lean.ofReduceBool`) can be used to create invalid proofs whenever the native evaluation of a term disagrees with the kernel's evaluation.
231
+
In general, native computation ({tactic}`decide`{keywordOf Lean.Parser.Tactic.decide}` +native` or direct use of {lit}`Lean.ofReduceBool`) can be used to create invalid proofs whenever the native evaluation of a term disagrees with the kernel's evaluation.
231
232
In particular, for every {attr}`implemented_by`/{attr}`extern` attribute in libraries it becomes part of the trusted code base that the replacement is semantically equivalent.
232
233
233
-
All these uses show up as an axiom {name}`Lean.trustCompiler`in {keywordOf Lean.Parser.Command.printAxioms}`#print axioms`.
234
+
All these uses show up as an axiom {lit}`Lean.trustCompiler`in {keywordOf Lean.Parser.Command.printAxioms}`#print axioms`.
234
235
External checkers (`lean4checker`, `comparator`) cannot check such proofs, as they do not have access to the Lean compiler.
235
236
When that level of checking is needed, proofs have to avoid using native evaluation.
236
237
237
-
Since Lean 4.29.0, the {tactic}`decide`{keywordOf Lean.Parser.Tactic.decide}` +native` and {tactic}`bv_decide` tactics no longer use {name}`Lean.trustCompiler`, but instead introduce one dedicated axiomforeachcomputationthatisassertedbynativecomputation.The {name}`Lean.trustCompiler` machinery is deprecated and will eventually be removed.
238
+
Since Lean 4.29.0, the {tactic}`decide`{keywordOf Lean.Parser.Tactic.decide}` +native` and {tactic}`bv_decide` tactics introduce one dedicated axiomforeachcomputationthatisassertedbynativecomputation.
239
+
The {lit}`Lean.trustCompiler` machinery was removed from Lean in version 4.35.0.
0 commit comments