- *Informally*. Let , : `EpochState`{.AgdaRecord} be two epoch states
and let : `Epoch`{.AgdaDatatype} be an epoch. Recall,
`.ls`{.AgdaField} denotes the ledger state of . If `⇀⦇`{.AgdaDatatype}
`,EPOCH⦈`{.AgdaDatatype} , then (under a certain special condition)
`govDepsMatch`{.AgdaFunction} ( `.ls`{.AgdaField}) implies
`govDepsMatch`{.AgdaFunction} ( `.ls`{.AgdaField}). The special
condition under which the property holds is the same as the one in
*'thm:ChainGovDepsMatch' (unresolved reference)*: let
`removed’`{.AgdaFunction} be the union of the governance actions in
the `removed`{.AgdaField} field of the ratify state of and the
orphaned governance actions in the `GovState`{.AgdaFunction} of . Let
$\mathcal{G}$ be the set
$\{\mbox{\texttt{@@AgdaTerm@@basename=GovActionDeposit@@class=AgdaInductiveConstructor@@} \ab{id}} : \mbox{\ab{id}} ∈ \mbox{proj}₁ \mbox{\texttt{@@AgdaTerm@@basename=removed'@@class=AgdaFunction@@}}\}$.
Assume: $\mathcal{G}$ is a subset of the set of deposits of (the
governance state of) .
- *Formally*.
EPOCH-govDepsMatch : {eps' : EpochState} {e : Epoch}
→ map (GovActionDeposit ∘ proj₁) removed' ⊆ dom (DepositsOf eps)
→ _ ⊢ eps ⇀⦇ e ,EPOCH⦈ eps'
→ govDepsMatch (eps .ls) → govDepsMatch (eps' .ls)
- *Proof*. See the module in the [formal ledger repository](\repourl).
EPOCH-govDepsMatch ratify-removed (EPOCH x _) =
≡ᵉ.trans (filter-pres-≡ᵉ $ dom-cong (res-comp-cong $ ≡ᵉ.sym ΔΠ'≡ΔΠ))
∘ from ≡ᵉ⇔≡ᵉ' ∘ main-invariance-lemma ∘ to ≡ᵉ⇔≡ᵉ'
where
ΔΠ : ℙ DepositPurpose
ΔΠ = map (proj₁ ∘ proj₂) removedGovActions
ΔΠ' : ℙ DepositPurpose
ΔΠ' = map (GovActionDeposit ∘ proj₁) removed'
P : GovActionID × GovActionState → Type
P = λ u → proj₁ u ∉ map proj₁ removed'
P? : Decidable P
P? = λ u → ¿ P u ¿
utxoDeps : Deposits
utxoDeps = UTxOState.deposits (LState.utxoSt epsLState)
utxoDeps' : Deposits
utxoDeps' = utxoDeps ∣ ΔΠ' ᶜ
ΔΠ'≡ΔΠ : ΔΠ' ≡ᵉ ΔΠ
ΔΠ'≡ΔΠ = ΔΠ'⊆ΔΠ , ΔΠ⊆ΔΠ'
where
ΔΠ'⊆ΔΠ : ΔΠ' ⊆ ΔΠ
ΔΠ'⊆ΔΠ {a} x with from ∈-map x
... | (gaid , gast) , refl , gaidgast∈rem with from ∈-map (ratify-removed x)
... | (dp , c) , refl , dpc∈utxoDeps = let gadc = (GovActionDeposit gaid , c) in
to ∈-map ((returnAddr {txs} gast , gadc)
, refl
, to ∈-concatMapˢ ((gaid , gast)
, gaidgast∈rem
, to ∈-map (gadc , refl , res-singleton⁺ {m = utxoDeps} dpc∈utxoDeps)))
ΔΠ⊆ΔΠ' : ΔΠ ⊆ ΔΠ'
ΔΠ⊆ΔΠ' {a} x with from ∈-map x
... | (rwa , dp , c) , refl , rwa-dp-c∈ with (from ∈-concatMapˢ rwa-dp-c∈)
... | (gaid , gast) , gaid-gast-∈-removed , rwa-dp-c-∈-map with (from ∈-map rwa-dp-c-∈-map)
... | (_ , _) , refl , q∈ =
to ∈-map ((gaid , gast)
, proj₁ (×-≡,≡←≡ (proj₂ (res-singleton'' {m = utxoDeps} q∈)))
, gaid-gast-∈-removed)
map-filter-decomp : ∀ a → (a ∉ ΔΠ' × a ∈ˡ map' (GovActionDeposit ∘ proj₁) govSt)
⇔ (a ∈ˡ map' (GovActionDeposit ∘ proj₁)(filter P? govSt))
map-filter-decomp a = mk⇔ i (λ h → ii h , iii h)
where
i : ((a ∉ ΔΠ') × (a ∈ˡ map' (GovActionDeposit ∘ proj₁) govSt))
→ a ∈ˡ map' (GovActionDeposit ∘ proj₁) (filter P? govSt)
i (a∉ΔΠ' , a∈) with Inverse.from (map-∈↔ (GovActionDeposit ∘ proj₁)) a∈
... | b , b∈ , refl = Inverse.to (map-∈↔ (GovActionDeposit ∘ proj₁))
(b , ∈-filter⁺ P? b∈ (a∉ΔΠ' ∘ ∈-map⁺-∘) , refl)
ii : a ∈ˡ map' (GovActionDeposit ∘ proj₁) (filter P? govSt) → a ∉ ΔΠ'
ii a∈ a∈ΔΠ' with from (∈ˡ-map-filter {l = govSt} {P? = P?}) a∈
... | _ , _ , refl , Pb with ∈-map⁻' a∈ΔΠ'
... | q , refl , q∈rem = Pb (to ∈-map (q , refl , q∈rem))
iii : a ∈ˡ map' (GovActionDeposit ∘ proj₁) (filter P? govSt)
→ a ∈ˡ map' (GovActionDeposit ∘ proj₁) govSt
iii a∈ with from (∈ˡ-map-filter {l = govSt} {P? = P?}) a∈
... | b , b∈ , refl , Pb = Inverse.to (map-∈↔ (GovActionDeposit ∘ proj₁)) (b , (b∈ , refl))
main-invariance-lemma :
filterˢ isGADeposit (dom utxoDeps) ≡ᵉ' fromList (map' (GovActionDeposit ∘ proj₁) govSt)
→ filterˢ isGADeposit (dom utxoDeps') ≡ᵉ' fromList (map' (GovActionDeposit ∘ proj₁) (filter P? govSt))
main-invariance-lemma HYP a = let open R.EquationalReasoning in
a ∈ filterˢ isGADeposit (dom utxoDeps') ∼⟨ R.SK-sym ∈-filter ⟩
(isGADeposit a × a ∈ dom utxoDeps') ∼⟨ R.K-refl ×-cong ∈-resᶜ-dom ⟩
(isGADeposit a × a ∉ ΔΠ' × ∃[ q ] (a , q) ∈ utxoDeps) ∼⟨ ×-⇔-swap ⟩
(a ∉ ΔΠ' × isGADeposit a × ∃[ q ] (a , q) ∈ utxoDeps) ∼⟨ R.K-refl ×-cong (R.K-refl ×-cong dom∈)⟩
(a ∉ ΔΠ' × isGADeposit a × a ∈ dom utxoDeps) ∼⟨ R.K-refl ×-cong ∈-filter ⟩
(a ∉ ΔΠ' × a ∈ filterˢ isGADeposit (dom utxoDeps)) ∼⟨ R.K-refl ×-cong (HYP a) ⟩
(a ∉ ΔΠ' × a ∈ fromList (map' (GovActionDeposit ∘ proj₁) govSt)) ∼⟨ R.K-refl ×-cong (R.SK-sym ∈-fromList)⟩
(a ∉ ΔΠ' × a ∈ˡ map' (GovActionDeposit ∘ proj₁) govSt) ∼⟨ map-filter-decomp a ⟩
a ∈ˡ map' (GovActionDeposit ∘ proj₁) (filter P? govSt) ∼⟨ ∈-fromList ⟩
a ∈ fromList (map' (GovActionDeposit ∘ proj₁) (filter P? govSt)) ∎