@@ -18,13 +18,16 @@ then `getCoin s ≡ getCoin s'`.
1818Recall (from ` Ledger.lagda.md ` ) that ` getCoin (LedgerState) ` is
1919
2020 getCoin (UTxOStateOf s)
21- + rewardsBalance (DStateOf ( CertStateOf s) )
21+ + coinFromRewards ( CertStateOf s)
2222 + coinFromDeposits (CertStateOf s)
2323 + coinFromGovDeposit (GovStateOf s)
2424
25- This is the sum of UTxO coin, rewards balance, the deposits from ` DState ` , ` PState ` ,
26- and ` GState ` (` coinFromDeposits ` {.AgdaFunction}), and the governance-action deposits
27- (` coinFromGovDeposit ` {.AgdaFunction}).
25+ This is the sum of UTxO coin, the cert-state rewards balance
26+ (` coinFromRewards ` {.AgdaFunction}), the deposits from ` DState ` , ` PState ` , and ` GState `
27+ (` coinFromDeposits ` {.AgdaFunction}), and the governance-action deposits
28+ (` coinFromGovDeposit ` {.AgdaFunction}). Note ` getCoin (CertState) ` itself now sums the
29+ rewards balance * and* the deposit pots (` coinFromRewards + coinFromDeposits ` ), so the
30+ two middle summands are exactly ` getCoin (CertStateOf s) ` .
2831
2932> ** Status — complete.** ` LEDGER-pov ` typechecks end-to-end under ` --safe ` (no
3033> postulates or holes). Following the top-down plan, this module proves only the
@@ -206,7 +209,7 @@ module LEDGER-PoV
206209 -- Certs-PoV stubs (discharged later by #1210). These were the `Certs.Properties.PoV`
207210 -- provider lemmas; under the top-down plan they are module parameters here.
208211 ( CERTS-pov : ∀ {Γ : CertEnv} {s s' : CertState} {dCerts : List DCert}
209- → Γ ⊢ s ⇀⦇ dCerts ,CERTS⦈ s' → getCoin s ≡ getCoin s' )
212+ → Γ ⊢ s ⇀⦇ dCerts ,CERTS⦈ s' → coinFromRewards s ≡ coinFromRewards s' )
210213 -- Closed-form cert-deposit coin equation: the post-`CERTS` `CertState` has the same
211214 -- `coinFromDeposits` as the closed-form `updateCertDeposits` applied to the initial
212215 -- state and the cert list. (#1210 discharges this using the ledger-level
@@ -422,8 +425,8 @@ deposits.
422425 SUBLEDGERS-certs-pov : ∀ {Γ : SubLedgerEnv} {s₀ s₁ : LedgerState} {stxs : List SubLevelTx}
423426 → SubLedgerEnv.isTopLevelValid Γ ≡ true
424427 → Γ ⊢ s₀ ⇀⦇ stxs ,SUBLEDGERS⦈ s₁
425- → getCoin (CertStateOf s₀) + sum (map ddwl stxs)
426- ≡ getCoin (CertStateOf s₁) + sum (map wdrwl stxs)
428+ → coinFromRewards (CertStateOf s₀) + sum (map ddwl stxs)
429+ ≡ coinFromRewards (CertStateOf s₁) + sum (map wdrwl stxs)
427430
428431 SUBLEDGERS-certs-pov _ (BS-base Id-nop) = refl
429432
@@ -433,28 +436,28 @@ deposits.
433436 SUBLEDGERS-certs-pov {Γ} isV (BS-ind {s = s₀} {s' = s₁} {sigs} {s'' = sₙ}
434437 (SUBLEDGER-V {stx = stx} (isV' , subutxowStep , entitiesStep , _)) rest) =
435438 begin
436- getCoin (CertStateOf s₀) + (getCoin (DirectDepositsOf stx) + sum (map ddwl sigs))
437- ≡⟨ sym (+-assoc (getCoin (CertStateOf s₀))
439+ coinFromRewards (CertStateOf s₀) + (getCoin (DirectDepositsOf stx) + sum (map ddwl sigs))
440+ ≡⟨ sym (+-assoc (coinFromRewards (CertStateOf s₀))
438441 (getCoin (DirectDepositsOf stx))
439442 (sum (map ddwl sigs))) ⟩
440- (getCoin (CertStateOf s₀) + getCoin (DirectDepositsOf stx)) + sum (map ddwl sigs)
443+ (coinFromRewards (CertStateOf s₀) + getCoin (DirectDepositsOf stx)) + sum (map ddwl sigs)
441444 ≡⟨ cong (_+ sum (map ddwl sigs))
442445 (ENTITIES-pov wd-netId dd-netId entitiesStep) ⟩
443- (getCoin (CertStateOf s₁) + getCoin (WithdrawalsOf stx)) + sum (map ddwl sigs)
444- ≡⟨ swap-right (getCoin (CertStateOf s₁))
446+ (coinFromRewards (CertStateOf s₁) + getCoin (WithdrawalsOf stx)) + sum (map ddwl sigs)
447+ ≡⟨ swap-right (coinFromRewards (CertStateOf s₁))
445448 (getCoin (WithdrawalsOf stx))
446449 (sum (map ddwl sigs)) ⟩
447- (getCoin (CertStateOf s₁) + sum (map ddwl sigs)) + getCoin (WithdrawalsOf stx)
450+ (coinFromRewards (CertStateOf s₁) + sum (map ddwl sigs)) + getCoin (WithdrawalsOf stx)
448451 ≡⟨ cong (_+ getCoin (WithdrawalsOf stx)) ih ⟩
449- (getCoin (CertStateOf sₙ) + sum (map wdrwl sigs)) + getCoin (WithdrawalsOf stx)
450- ≡⟨ swap-right (getCoin (CertStateOf sₙ))
452+ (coinFromRewards (CertStateOf sₙ) + sum (map wdrwl sigs)) + getCoin (WithdrawalsOf stx)
453+ ≡⟨ swap-right (coinFromRewards (CertStateOf sₙ))
451454 (sum (map wdrwl sigs))
452455 (getCoin (WithdrawalsOf stx)) ⟩
453- (getCoin (CertStateOf sₙ) + getCoin (WithdrawalsOf stx)) + sum (map wdrwl sigs)
454- ≡⟨ +-assoc (getCoin (CertStateOf sₙ))
456+ (coinFromRewards (CertStateOf sₙ) + getCoin (WithdrawalsOf stx)) + sum (map wdrwl sigs)
457+ ≡⟨ +-assoc (coinFromRewards (CertStateOf sₙ))
455458 (getCoin (WithdrawalsOf stx))
456459 (sum (map wdrwl sigs)) ⟩
457- getCoin (CertStateOf sₙ) + (getCoin (WithdrawalsOf stx) + sum (map wdrwl sigs))
460+ coinFromRewards (CertStateOf sₙ) + (getCoin (WithdrawalsOf stx) + sum (map wdrwl sigs))
458461 ∎
459462 where
460463 -- The two NetworkId witnesses, extracted from the SUBUTXOW step.
@@ -477,8 +480,8 @@ deposits.
477480 wd-netId = proj₁ netIds
478481 dd-netId = proj₂ netIds
479482
480- ih : getCoin (CertStateOf s₁) + sum (map ddwl sigs)
481- ≡ getCoin (CertStateOf sₙ) + sum (map wdrwl sigs)
483+ ih : coinFromRewards (CertStateOf s₁) + sum (map ddwl sigs)
484+ ≡ coinFromRewards (CertStateOf sₙ) + sum (map wdrwl sigs)
482485 ih = SUBLEDGERS-certs-pov isV rest
483486```
484487
@@ -557,15 +560,15 @@ are unchanged. Only the `UTXOW` step affects `getCoin`, and it preserves it via
557560
558561``` agda
559562 LEDGER-pov {Γ} {s} (LEDGER-I (invalid , _ , utxoStep)) =
560- cong (λ u → u + getCoin (CertStateOf s) + coinFromDeposits (CertStateOf s)
563+ cong (λ u → u + coinFromRewards (CertStateOf s) + coinFromDeposits (CertStateOf s)
561564 + coinFromGovDeposit (GovStateOf s))
562565 (utxow-pov-invalid utxoStep invalid)
563566```
564567
565568### ` LEDGER-V ` case (valid transaction)
566569
567570The proof is a single equational chain over ` LedgerState ` coin totals. Setting
568- ` U = getCoin (UTxOState) ` , ` R = rewardsBalance ` , ` D = coinFromDeposits ` ,
571+ ` U = getCoin (UTxOState) ` , ` R = coinFromRewards ` , ` D = coinFromDeposits ` ,
569572` G = coinFromGovDeposit ` , and ` allDirectDeps ` / ` allWdrls ` for the top-level and
570573sub-level totals of direct deposits and withdrawals respectively, the goal
571574` getCoin s ≡ getCoin s' ` is
@@ -626,8 +629,8 @@ are stated explicitly to keep the chain readable.
626629 D₂ = coinFromDeposits cs₂
627630
628631 R₀ R₂ : Coin
629- R₀ = rewardsBalance (DStateOf ( CertStateOf s) )
630- R₂ = rewardsBalance (DStateOf cs₂)
632+ R₀ = coinFromRewards ( CertStateOf s)
633+ R₂ = coinFromRewards cs₂
631634
632635 -- Governance-deposit summands of the LedgerState totals. G₀ is the initial
633636 -- GovState's deposit; G' is the final state's (`rmOrphanDRepVotes cs₂ govSt₂`),
@@ -708,27 +711,27 @@ The "combined" `ENTITIES-pov` invocation: pre-batch `certState` + all direct dep
708711key step where direct deposits cancel between the UTxO and CertState sides of the ledger.
709712
710713``` agda
711- combined-certs : getCoin (CertStateOf s) + allDirectDeps
712- ≡ getCoin cs₂ + allWdrls
714+ combined-certs : coinFromRewards (CertStateOf s) + allDirectDeps
715+ ≡ coinFromRewards cs₂ + allWdrls
713716 combined-certs =
714717 begin
715- getCoin (CertStateOf s) + allDirectDeps
716- ≡⟨ cong (getCoin (CertStateOf s) +_)
718+ coinFromRewards (CertStateOf s) + allDirectDeps
719+ ≡⟨ cong (coinFromRewards (CertStateOf s) +_)
717720 (+-comm (getCoin (DirectDepositsOf tx)) subDirectDepsCoin) ⟩
718- getCoin (CertStateOf s) + (subDirectDepsCoin + getCoin (DirectDepositsOf tx))
719- ≡⟨ sym (+-assoc (getCoin (CertStateOf s))
721+ coinFromRewards (CertStateOf s) + (subDirectDepsCoin + getCoin (DirectDepositsOf tx))
722+ ≡⟨ sym (+-assoc (coinFromRewards (CertStateOf s))
720723 subDirectDepsCoin
721724 (getCoin (DirectDepositsOf tx))) ⟩
722- getCoin (CertStateOf s) + subDirectDepsCoin + getCoin (DirectDepositsOf tx)
725+ coinFromRewards (CertStateOf s) + subDirectDepsCoin + getCoin (DirectDepositsOf tx)
723726 ≡⟨ cong (_+ getCoin (DirectDepositsOf tx))
724727 (SUBLEDGERS-certs-pov valid subStep) ⟩
725- getCoin cs₁ + subWdrlsCoin + getCoin (DirectDepositsOf tx)
726- ≡⟨ swap-right (getCoin cs₁) subWdrlsCoin (getCoin (DirectDepositsOf tx)) ⟩
727- getCoin cs₁ + getCoin (DirectDepositsOf tx) + subWdrlsCoin
728+ coinFromRewards cs₁ + subWdrlsCoin + getCoin (DirectDepositsOf tx)
729+ ≡⟨ swap-right (coinFromRewards cs₁) subWdrlsCoin (getCoin (DirectDepositsOf tx)) ⟩
730+ coinFromRewards cs₁ + getCoin (DirectDepositsOf tx) + subWdrlsCoin
728731 ≡⟨ cong (_+ subWdrlsCoin) (ENTITIES-pov top-wd-netId top-dd-netId entitiesStep) ⟩
729- getCoin cs₂ + getCoin (WithdrawalsOf tx) + subWdrlsCoin
730- ≡⟨ +-assoc (getCoin cs₂) (getCoin (WithdrawalsOf tx)) subWdrlsCoin ⟩
731- getCoin cs₂ + (getCoin (WithdrawalsOf tx) + subWdrlsCoin)
732+ coinFromRewards cs₂ + getCoin (WithdrawalsOf tx) + subWdrlsCoin
733+ ≡⟨ +-assoc (coinFromRewards cs₂) (getCoin (WithdrawalsOf tx)) subWdrlsCoin ⟩
734+ coinFromRewards cs₂ + (getCoin (WithdrawalsOf tx) + subWdrlsCoin)
732735 ∎
733736```
734737
0 commit comments