Background
The Foreign layer (added for Dijkstra in #1134) uses postulate-based shortcuts at three sites where Haskell-side values must be promoted to Agda-side values that carry proof obligations.
ppWF in src/Ledger/Dijkstra/Foreign/ExternalStructures.lagda.md (already marked FIXME) — postulates well-formedness of applyPParamsUpdate.
trustMe-flowConservation, trustMe-nonneg, trustMe-nonpos in src/Ledger/Dijkstra/Foreign/Rewards.lagda.md — postulate the three invariants of RewardUpdate when reconstructing it from a HsRewardUpdate.
The latter two are jointly inconsistent if ever instantiated on the same ℤ value, though current call sites avoid this.
Goal
Replace each postulate with one of the following:
- a decision procedure that runs at the Haskell-Agda boundary and produces
failure if the invariant is violated (preferred for fields the Haskell side can construct freely);
- a genuine proof, where the structure of the construction makes one available.
The pattern in Foreign/Chain.lagda.md (decidable check on bBodySize ≡ hBbsize, returning error on mismatch) is a good template.
Acceptance
Background
The Foreign layer (added for Dijkstra in #1134) uses
postulate-based shortcuts at three sites where Haskell-side values must be promoted to Agda-side values that carry proof obligations.ppWFinsrc/Ledger/Dijkstra/Foreign/ExternalStructures.lagda.md(already markedFIXME) — postulates well-formedness ofapplyPParamsUpdate.trustMe-flowConservation,trustMe-nonneg,trustMe-nonposinsrc/Ledger/Dijkstra/Foreign/Rewards.lagda.md— postulate the three invariants ofRewardUpdatewhen reconstructing it from aHsRewardUpdate.The latter two are jointly inconsistent if ever instantiated on the same
ℤvalue, though current call sites avoid this.Goal
Replace each postulate with one of the following:
failureif the invariant is violated (preferred for fields the Haskell side can construct freely);The pattern in
Foreign/Chain.lagda.md(decidable check onbBodySize ≡ hBbsize, returningerroron mismatch) is a good template.Acceptance
postulateblocks inLedger/Dijkstra/Foreign/*.lagda.mdoutside of clearly-scoped TODOs with a tracking issue link.trustMe-nonnegandtrustMe-nonposdeleted (replaced by decidable bounds checks inConv-RewardUpdate.from).