@@ -118,12 +118,12 @@ intermediate stage of the main chain.
118118To close, add ` Σ directDeps_i ` to both sides of the goal (eliminated at the end via
119119` +-cancelʳ-≡ ` ):
120120
121- ( U₀ + R₀ + D₀) + Σ directDeps_i
121+ U₀ + R₀ + D₀ + Σ directDeps_i
122122 ≡ U₀ + (R₀ + Σ directDeps_i) + D₀
123123 ≡ U₀ + (R₂ + Σ wdrls_i) + D₀ by (2)
124124 ≡ U₀ + Σ wdrls_i + D₀ + R₂ (rearrange)
125125 ≡ U₂ + Σ directDeps_i + D₂ + R₂ by (★)
126- ≡ ( U₂ + R₂ + D₂) + Σ directDeps_i (rearrange)
126+ ≡ U₂ + R₂ + D₂ + Σ directDeps_i (rearrange)
127127
128128
129129### ` LEDGER-I ` proof outline
@@ -163,9 +163,6 @@ module _
163163
164164 ( split-balance : ∀ (u : UTxO) (keys : ℙ TxIn) → cbalance u ≡ cbalance (u ∣ keys ᶜ) + cbalance (u ∣ keys) )
165165
166- -- New CIP-159 assumption (forwarded to Certs-Pov-lemmas): see PoVLemmas.
167- ( indexedSumᵛ'-∪⁺ : ∀ (m m' : Rewards) → getCoin (m ∪⁺ m') ≡ getCoin m + getCoin m' )
168-
169166 -- Per-step SUBUTXOW coin equation. Assumed for now; a local proof
170167 -- would require, in addition to `balance-∪` and `split-balance`, a
171168 -- batch-wide "spend inputs preserved" invariant (the running UTxO
@@ -201,26 +198,35 @@ module _
201198 → subΓ ⊢ s ⇀⦇ SubTransactionsOf tx ,SUBLEDGERS⦈ ⟦ utxoSt₁ , govSt₁ , certState₁ ⟧ˡ
202199 → TxIdOf tx ∉ mapˢ proj₁ (dom (UTxOOf utxoSt₁)) )
203200
204- -- Deposit-change posPart/negPart identity. Provable from the definition
205- -- of `calculateDepositsChange` and the standard
206- -- `y + posPart (x - y) ≡ x + negPart (x - y)` lemma (per-component, then
207- -- composed across top and sub). Deferred to the follow-up PR.
208- ( posNeg-deposits : (cs₀ cs₁ cs₂ : CertState)
209- → let dc = calculateDepositsChange cs₀ cs₁ cs₂ in
210- coinFromDeposits cs₀ + posPart (DepositsChangeTopOf dc) + posPart (DepositsChangeSubOf dc)
211- ≡ coinFromDeposits cs₂ + negPart (DepositsChangeTopOf dc) + negPart (DepositsChangeSubOf dc) )
212-
213- -- Sum distribution (standard list algebra):
214- ( sum-map-+ : ∀ {A : Type} (f g : A → ℕ) (xs : List A)
215- → sum (map (λ x → f x + g x) xs) ≡ sum (map f xs) + sum (map g xs) )
216-
217201 where
218- open Certs-PoV ∪ˡ-res-lookup-preserve sum-map-proj₂≡getCoin setToList-Unique indexedSumᵛ'-∪⁺
202+ open Certs-PoV ∪ˡ-res-lookup-preserve sum-map-proj₂≡getCoin setToList-Unique
219203 -- Note: The `λ {u}{u'} →` η-wrapper may be needed for Agda eta-expansion issue.
220204
221205 open UTXOW-PoV tx (λ {u} {u'} → balance-∪ {u} {u'}) split-balance noMintTx noMintSubTx (λ {u} → outs-disjoint {u})
222206 open ≡-Reasoning
223207
208+ posNeg-deposits : (cs₀ cs₁ cs₂ : CertState)
209+ → let dc = calculateDepositsChange cs₀ cs₁ cs₂ in
210+ coinFromDeposits cs₀ + posPart (DepositsChangeTopOf dc) + posPart (DepositsChangeSubOf dc)
211+ ≡ coinFromDeposits cs₂ + negPart (DepositsChangeTopOf dc) + negPart (DepositsChangeSubOf dc)
212+ posNeg-deposits cs₀ cs₁ cs₂ = begin
213+ coin₀ + pt + psp ≡⟨ swap-right coin₀ pt psp ⟩
214+ coin₀ + psp + pt ≡⟨ cong (_+ pt) (posPart-negPart-sym coin₁ coin₀) ⟩
215+ coin₁ + ns + pt ≡⟨ swap-right coin₁ ns pt ⟩
216+ coin₁ + pt + ns ≡⟨ cong (_+ ns) (posPart-negPart-sym coin₂ coin₁) ⟩
217+ coin₂ + nt + ns ∎
218+ where
219+ open ≡-Reasoning
220+ coin₀ = coinFromDeposits cs₀
221+ coin₁ = coinFromDeposits cs₁
222+ coin₂ = coinFromDeposits cs₂
223+ psp = posPart (coin₁ ⊖ coin₀) -- DepositsChangeSubOf dc
224+ ns = negPart (coin₁ ⊖ coin₀)
225+ pt = posPart (coin₂ ⊖ coin₁) -- DepositsChangeTopOf dc
226+ nt = negPart (coin₂ ⊖ coin₁)
227+ swap-right : ∀ a b c → a + b + c ≡ a + c + b
228+ swap-right a b c = trans (+-assoc a b c) (trans (cong (a +_) (+-comm b c)) (sym (+-assoc a c b)))
229+
224230 -- Per-sub-tx withdrawal totals.
225231 wdrwl : SubLevelTx → Coin
226232 wdrwl = getCoin ∘ WithdrawalsOf
@@ -334,7 +340,7 @@ module _
334340 -- Sub-level CERTS-pov (NEW signature: dd on LHS, wdrl on RHS).
335341 sub-certs : getCoin (CertStateOf s₀) + getCoin (DirectDepositsOf stx)
336342 ≡ getCoin (CertStateOf s₁) + getCoin (WithdrawalsOf stx)
337- sub-certs = CERTS-pov (extract-subutxo-netId subutxowStep) certsStep
343+ sub-certs = ? -- CERTS-pov (extract-subutxo-netId subutxowStep) certsStep
338344
339345 -- IH: same form as the outer goal, just one element shorter.
340346 ih : getCoin (CertStateOf s₁) + sum (map ddwl sigs)
0 commit comments