Skip to content

Commit b791841

Browse files
authored
[Dijkstra] CIP-159-11c: Prove LEDGER preservation of value (#1187)
Prove `LEDGER-pov` for the Dijkstra LEDGER rule: getCoin s ≡ getCoin s', where getCoin (LedgerState) sums UTxO coin, the rewards balance, the three cert-deposit pots, and the gov-action deposits. Typechecks under --safe with no postulates or holes. Top-down plan: the supporting Certs / UTxO / Gov facts are module parameters of `Ledger.Properties.PoV`, forming the frozen contract for the follow-up PRs (#1186 utxo/utxow, #1210 certs, and a future Gov PoV). New modules: - Ledger/Properties/PoV: LEDGER-pov. The LEDGER-V case is a single LedgerState-level equational chain; direct-deposit value cancels between the UTxO and CertState sides, gov-deposit growth is matched against the produced-side govProposalsDeposits, and `bat'` converts the closed-form batch balance (#1186 shape) to the chain's two-level posPart/negPart deposit form via the batch-cert-deposits-bridge (#1210 shape) and net-arith. - Entities/Properties/PoV: ENTITIES-pov and SUBENTITIES-pov, the value-flow equations for the post-#1256 tx-signal rules. NetworkId and domain facts come from the rules' own premises; the no-truncation bound (withdrawal amount ≤ input-state balance) is an explicit hypothesis — the phantom-withdrawal gap flagged in the #1256 review, provided at the LEDGER level by the ENTITIES/SUBENTITIES-wdrls-bounded parameters. - Entities/Properties/ApplyToRewardsPoV: applyWithdrawals-pov and applyDirectDeposits-pov fold lemmas. Spec changes: - Ledger: getCoin (LedgerState) gains a coinFromGovDeposit summand (gov-action deposits live in GovActionState.deposit, not GState.deposits, yet the UTXO batch balance charges govProposalsDeposits on the produced side). - Certs: getCoin (CertState) is now total (rewards + deposit pots), with coinFromRewards / coinFromDeposits projections. - Prelude: era-independent sum lemmas (+-interleave, sum-map-+). Squash of the pre-rebase branch (13 WIP commits, head f677e1b), rebased onto master and adapted to #1250 (explicit cert deposits, closed-form newCertDeposits/refundCertDeposits), #1253/#1256 (EntitiesEnv, SUBENTITIES, tx-signal ENTITIES), #1262 (legacyMode threading), and deposit sign-swap fix in #1250, so it is no longer part of the diff. AI-assisted: Claude Fable 5 (Anthropic)
1 parent cf3a26d commit b791841

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • src/Ledger/Dijkstra/Specification/Entities/Properties

src/Ledger/Dijkstra/Specification/Entities/Properties/PoV.lagda.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,12 @@ conditions) are premises of the rule itself.
181181
aw = applyWithdrawals (WithdrawalsOf txSub) r₀
182182
```
183183

184-
The top-level analogue, with signal `txTop`{.AgdaBound}, by the same argument. (In
185-
legacy mode the rule's own premise forces each top-level withdrawal to equal the
186-
account's current balance, which implies the `amts≤`{.AgdaBound} hypothesis; in
187-
normal mode the rule bounds withdrawals only against the pre-batch
184+
## The `ENTITIES-pov` theorem
185+
186+
The top-level analogue, with signal `txTop`{.AgdaBound}, follows
187+
by the same argument. (In legacy mode the rule's own premise forces each top-level
188+
withdrawal to equal the account's current balance, which implies the `amts≤`{.AgdaBound}
189+
hypothesis; in normal mode the rule bounds withdrawals only against the pre-batch
188190
`rewards₀`{.AgdaField}, so the hypothesis is genuinely extra information.)
189191

190192
```agda
@@ -194,7 +196,11 @@ normal mode the rule bounds withdrawals only against the pre-batch
194196
→ Γ ⊢ s ⇀⦇ txTop ,ENTITIES⦈ s'
195197
→ coinFromRewards s + getCoin (DirectDepositsOf txTop)
196198
≡ coinFromRewards s' + getCoin (WithdrawalsOf txTop)
199+
```
197200

201+
**Proof**.
202+
203+
```agda
198204
ENTITIES-pov {txTop = txTop} {s = ⟦ ⟦ _ , _ , r₀ , _ ⟧ᵈ , _ , _ ⟧ᶜˢ}
199205
amts≤
200206
(ENTITIES {rewards' = r₁} (wd-netId , wdrls⊆ , _ , _ , _ , _ , certsStep , _ , ddCreds⊆)) =

0 commit comments

Comments
 (0)