6.5. Saving and reusing a proof
Writing out every modular inverse soon becomes inconvenient.
ecpp_cert% gives a shorter representation of the same mathematical
data. For the certificate above:
example : Nat.Prime 17 := ⊢ Nat.Prime 17
All goals completed! 🐙
end HexECPPChapter
The string records a curve and point in PARI's row format. The
expression after using proves the prime that ends the chain.
During elaboration, Hex reconstructs the modular inverses and builds
an ordinary Hex.ECPP.Cert. Lean then verifies that certificate in
the same way as the explicit one. The compact expression does not
invoke PARI or repeat the curve search.
There are two convenient ways to retain a generated certificate:
apply the tactic's Try this: suggestion in your proof, or export
the certificate to a separate Lean module.
6.5.1. Exporting a certificate to a module
In a file importing HexECPPTheory.Native, add:
#ecpp_export (method := ecpp) MyCertificates.Prime cert for 17
Build the file with lake build. The command searches for a
certificate, checks the resulting proof in Lean's kernel, and creates
MyCertificates/Prime.lean containing MyCertificates.Prime.cert.
It refuses to overwrite an existing file. When used in the editor,
the command displays the batch-build instructions instead of writing
a file.
Remove the export command after generation. Import the new module and use its certificate in subsequent proofs:
module public import MyCertificates.Prime example : Nat.Prime 17 := by ecpp using MyCertificates.Prime.cert
The exported module imports HexECPPTheory.Compact, which provides
the checker, soundness theorem and compact certificate notation.
Checking an exported certificate needs neither native search nor GP.
This is useful when several files need the same prime, or when you
want to preserve a successful search independently of later changes
to the search procedure.