Make additional dependency records and lifted LCNF closures deterministic in module output

Aperta
#16,875 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
compilers

Direzione di ricerca

Read src/Lean/ExtraModUses.lean at the exporter and src/Lean/Compiler/LCNF/ExtractClosed.lean at closed-term extraction, then compare the save path with src/Lean/Compiler/LCNF/Passes.lean. Reproduce the module-part comparison with Lean.readModuleDataParts and the ClosedProducer.lean fixture described in the issue. Done means both write changes make private module output deterministic while public and server parts and downstream imports remain unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Lean 4.36.0 can preserve the same declarations and dependencies while writing different bytes to a module's private olean part. We observed this on release commit 611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9 in a repeat build with experimental early inductive signature publication enabled. The comparison used the Linux release recipe with the oldGlibc Nix shell, LLVM 23.1.1 and Stage2. The other six module outputs, the setup file and Lake dependency hash were identical in the repeat.

The first difference in GapCVP.olean.private was at byte 78,640,569, using one-based offsets. Both files had 91,830,704 bytes. Reading the public, server and private parts together with readModuleDataParts identified two differing extensions out of 50.

  • Three adjacent entries in extraModUses changed order. The full multiset of 4,598 entries matched, including both flags on each entry. The exporter currently preserves insertion order, which can reflect the order in which an asynchronous task first records a dependency. Lake Shake accumulates these entries into sets of requirements. Exporter · Consumer
  • In monoExt, 3,258 lifted _closed_* declarations had different local identifier prefixes. Declaration names, order, signatures and let binder names matched. All affected bodies passed Lean's Code.alphaEqv. The first changed local ID was _uniq.9214764.816 versus _uniq.9214773.816. The normal mono save pass normalizes local IDs. The closed-term extraction path saves the declaration with the ID prefix of the current compilation task. Closed-term extraction · Mono save pass

The two proposed changes apply independently to the release commit.

  1. Sort ExtraModUse records when exporting the private part, by module name using Name.quickCmp, then by isExported and isMeta with false before true. In-memory deduplication and extension replay keep their existing order.
  2. Save (← normalizeFVarIds decl).saveMono in ExtractClosed. The active compiler pass keeps the original declaration and the closed-term cache keeps its original key and name.

We reproduced each archived private part byte for byte by saving the three parts back without changes. Applying both write rules to both archived private parts produced the same SHA-256, 6f09e3a14b8b8c0af584a0c914273ee5636c39b6045b798aa1559cef96214384. Each public and server part kept its original hash. This readback covers the observed drift. The writer can intentionally emit different private bytes from the release even when both builds elaborate the same source. A byte comparison between compiler configurations therefore needs to state which write rules each configuration uses.

Two new CompactnessAndDegeneracy builds compared the release writer with a Stage2 build containing only the two write changes. In each build, the public and server olean parts, ilean, IR, IR signature, C output, setup file and Lake dependency hash matched the release bytes. The first private difference was at byte 89. The reader checked every field and all 40 extensions. Sorting the release writer's 2,224 dependency records reproduced the new array exactly, changing 2,181 positions. Applying normalizeFVarIds reproduced all 50 changed lifted closures among 232 mono declarations, and each changed body passed Code.alphaEqv. A downstream module imported the output of each writer in both runs. The fixture ClosedProducer.lean also reverses the order of recording twelve dependencies while keeping the source fixed. Both fixed-writer private outputs match, and a downstream module can still use the exported definition and read the recorded dependencies.

The four-project Stage2 recheck covered 58 module builds across seven paired blocks. All six non-private outputs per module, the setup file and the Lake dependency hash matched the release. The private file differed in 57 comparisons. Every differing file passed the object check, including all other fields and extensions, and the downstream import succeeded for both writers in all seven blocks. In GapCVP, the release-to-fixed comparison started at byte 89 in both blocks. The fixed export reordered 4,445 positions among 4,598 dependency records and normalized 3,380 of 6,916 mono declarations. Those counts describe the deliberate change from the release writer. The earlier three-record and 3,258-closure counts describe drift between two builds under the original writer. Each fixed-writer GapCVP output also matched its own repeat byte for byte.

The comparison can be reproduced from release commit 611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9 with the two independent write changes above and a three-part reader using Lean.readModuleDataParts. We verified both changes across clean, instrumented, and early-inductive Stage 2 builds using the Linux release recipe.

Lingua principale
Lean
Stelle
10.3k
Fork
1.1k
Merge medio
16h 45m
PR unite (30g)
361

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di leanprover/lean4

Tutte le issue di leanprover/lean4

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.