Repository navigation
Expand file tree
/
Copy pathFile.lean
More file actions
34 lines (28 loc) · 1.42 KB
/
Copy pathFile.lean
File metadata and controls
34 lines (28 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Library.Hashing.Sha512.Bytes
import LeanExe.Pipeline.FileBytes
/-! Checked after `tests/verified/run.sh` writes `build/verified/sha512.wasm`, with
`tools/leanrun --timeout 10m lake env lean Library/Hashing/Sha512/File.lean`: the file holds
`encode compiled.module`, which `compiled.encoded` states as literal bytes, so it decodes to the
module of `sha512_module` and of the call theorems of `Library.Hashing.Sha512.Bytes`. The file's
bytes are a term nested as deep as the file is long, which the kernel checks under a raised
`maxRecDepth`. -/
namespace Library.Hashing.Sha512.File
set_option maxRecDepth 100000 in
/-- `build/verified/sha512.wasm` holds `encode compiled.module`. -/
theorem sha512_file :
Wasm.Encoding.encode compiled.module =
.ok (binary_file% "../../../build/verified/sha512.wasm") :=
LeanExe.Pipeline.encode_eq_of_encoding compiled.encoded.1 (by decide +kernel)
set_option maxRecDepth 100000 in
/-- `build/verified/sha512.wasm` decodes to the module of `sha512_module`. -/
theorem sha512_file_decode :
Wasm.Encoding.decode (binary_file% "../../../build/verified/sha512.wasm") =
.ok compiled.module := by
obtain ⟨⟨bytes, henc, hdec⟩, _⟩ := sha512_module
have h : binary_file% "../../../build/verified/sha512.wasm" = bytes :=
Except.ok.inj (sha512_file.symm.trans henc)
rw [h]
exact hdec
#print axioms sha512_file
#print axioms sha512_file_decode
end Library.Hashing.Sha512.File