provenance.pl
Explanatory context, separate from executable IR and safety evidence.
A context(Function, Records) item accompanies a func/5. Bindings and origins have function-local identities. Origins are shallow typed nodes at the enclosing statement's location, not expression spans. Values retain their original identities and hints even when removed; alias/4 records substitution without renaming the surviving value.
site(inst(Label, Index), Origins) uses a zero-based index in THIS stage's instruction list. Passes produce explicit old-to-new site maps while rewriting. Phis and jumps have stable sites phi(Temp) and jump(Label). Context never participates in CFG or safety proofs.
Records
| Record | Meaning |
|---|---|
bindingId, Name, CType, Location | declaration identity and spelling; shadowed names have distinct IDs |
originId, Location, Description, Parents | a typed lowering node, enclosing statement, or generated operation, linked by origin IDs |
valueTemp, Hint, Origins | original definition, retained as history if eliminated |
siteSite, Origins | provenance of a live instruction, phi or terminator |
aliasTemp, Replacement, Hint, Origins | copy/phi substitution, including replacement by a constant |
historyId, Temp, Hint, Origins, Replacement | retired definition when an executable name is reused; Replacement is none or replaced(Value) |
Location is at(File, Line) or none. A typed description is typed(val|obj|fun, CType, ShallowForm), a statement is statement(Kind), and a synthesized operation is generated(Pass, Reason). Parents express containment or contributing origins, not executable uses. Hint is none or named(BindingId, value|address|piece). C types are explanations of source nodes, never substitutes for IR classes.
If a pass reuses a deleted temporary's spelling, its old definition moves to history/5. Incoming alias/history replacements then use historical(Id), referencing that history record, not the new value. This metadata-only reference can never be an executable operand.
Promotion conservatively cites the slot's declaration/initial value and stores, not an assertion that every store reaches every phi. Copies preserve the survivor's primary name. Raw accesses and their adjacent checks inherit the same access origin; checks and poll edges additionally have generated origins. Erasure cannot authorize an otherwise-invalid check/access pair.
Only metadata names consult metadata. Executable fresh names remain exactly what the metadata-free transformation would choose.
Incoming references identify the old definition, not a new proof that happens to reuse its spelling. Historical references are not IR values.
Map is OldSite-NewSite, with one pair per emitted instruction. An instruction that expands has several destinations; one erased has none.
The rewriting loop calls this with the instructions it just emitted.
Legacy loc markers remain valid input. At unchecked transformation boundaries they become context, never before checked-IR validation.