@@ -40,35 +40,7 @@ private variable
4040instance
4141 _ = +-0-monoid
4242
43- getCoin-singleton : ⦃ _ : DecEq A ⦄ {(a , c) : A × Coin} → indexedSumᵛ' id ❴ (a , c) ❵ ≡ c
44- getCoin-singleton = indexedSum-singleton' {M = Coin} (finiteness _)
45-
46- ∪ˡsingleton∈dom : ⦃ _ : DecEq A ⦄ (m : A ⇀ Coin) {(a , c) : A × Coin}
47- → a ∈ dom m → getCoin (m ∪ˡ ❴ (a , c) ❵ᵐ) ≡ getCoin m
48- ∪ˡsingleton∈dom m {(a , c)} a∈dom = ≡ᵉ-getCoin (m ∪ˡ ❴ (a , c) ❵) m (singleton-∈-∪ˡ {m = m} a∈dom)
49-
50- module _ ( indexedSumᵛ'-∪ : {A : Type} ⦃ _ : DecEq A ⦄ (m m' : A ⇀ Coin)
51- → disjoint (dom m) (dom m')
52- → getCoin (m ∪ˡ m') ≡ getCoin m + getCoin m' )
53- where
54- open ≡-Reasoning
55- open Equivalence
56-
57- ∪ˡsingleton∉dom : ⦃ _ : DecEq A ⦄ (m : A ⇀ Coin) {(a , c) : A × Coin}
58- → a ∉ dom m → getCoin (m ∪ˡ ❴ (a , c) ❵ᵐ) ≡ getCoin m + c
59- ∪ˡsingleton∉dom m {(a , c)} a∉dom = begin
60- getCoin (m ∪ˡ ❴ a , c ❵ᵐ)
61- ≡⟨ indexedSumᵛ'-∪ m ❴ a , c ❵ᵐ
62- ( λ x y → a∉dom (subst (_∈ dom m) (from ∈-dom-singleton-pair y) x) ) ⟩
63- getCoin m + getCoin ❴ a , c ❵ᵐ
64- ≡⟨ cong (getCoin m +_) getCoin-singleton ⟩
65- getCoin m + c
66- ∎
67-
68- ∪ˡsingleton0≡ : ⦃ _ : DecEq A ⦄ → (m : A ⇀ Coin) {a : A} → getCoin (m ∪ˡ ❴ (a , 0) ❵ᵐ) ≡ getCoin m
69- ∪ˡsingleton0≡ m {a} with a ∈? dom m
70- ... | yes a∈dom = ∪ˡsingleton∈dom m a∈dom
71- ... | no a∉dom = trans (∪ˡsingleton∉dom m a∉dom) (+-identityʳ (getCoin m))
43+ open ≡-Reasoning
7244```
7345-->
7446
@@ -83,61 +55,59 @@ some `dcert`{.AgdaBound} : `DCert`{.AgdaDatatype}. Then,
8355* Formally* .
8456
8557``` agda
86- CERT-pov : {Γ : CertEnv} {s s' : CertState}
87- → Γ ⊢ s ⇀⦇ dCert ,CERT⦈ s'
88- → getCoin s ≡ getCoin s'
58+ CERT-pov : {Γ : CertEnv} {s s' : CertState}
59+ → Γ ⊢ s ⇀⦇ dCert ,CERT⦈ s' → getCoin s ≡ getCoin s'
8960```
9061
9162* Proof* . (Click the "Show more Agda" button to reveal the proof.)
9263
9364<!--
9465```agda
95- CERT-pov (CERT-deleg (DELEG-delegate {rwds = rwds} _)) = sym (∪ˡsingleton0≡ rwds)
96- CERT-pov (CERT-deleg (DELEG-reg {rwds = rwds} _)) = sym (∪ˡsingleton0≡ rwds)
97- CERT-pov {s = ⟦ _ , stᵖ , stᵍ ⟧ᶜˢ}{⟦ _ , stᵖ' , stᵍ' ⟧ᶜˢ}
98- (CERT-deleg (DELEG-dereg {c = c} {rwds} {vDelegs = vDelegs}{sDelegs} x)) = begin
99- getCoin ⟦ ⟦ vDelegs , sDelegs , rwds ⟧ , stᵖ , stᵍ ⟧
100- ≡˘⟨ ≡ᵉ-getCoin rwds-∪ˡ-decomp rwds
101- ( ≡ᵉ.trans rwds-∪ˡ-∪ (≡ᵉ.trans ∪-sym (res-ex-∪ Dec-∈-singleton)) ) ⟩
102- getCoin rwds-∪ˡ-decomp
103- ≡⟨ ≡ᵉ-getCoin rwds-∪ˡ-decomp ((rwds ∣ ❴ c ❵ ᶜ) ∪ˡ ❴ (c , 0) ❵ᵐ) rwds-∪ˡ≡sing-∪ˡ ⟩
104- getCoin ((rwds ∣ ❴ c ❵ ᶜ) ∪ˡ ❴ (c , 0) ❵ᵐ )
105- ≡⟨ ∪ˡsingleton0≡ (rwds ∣ ❴ c ❵ ᶜ) ⟩
106- getCoin ⟦ ⟦ vDelegs ∣ ❴ c ❵ ᶜ , sDelegs ∣ ❴ c ❵ ᶜ , rwds ∣ ❴ c ❵ ᶜ ⟧ , stᵖ' , stᵍ' ⟧
107- ∎
108- where
109- module ≡ᵉ = IsEquivalence (≡ᵉ-isEquivalence {Credential × Coin})
110- rwds-∪ˡ-decomp = (rwds ∣ ❴ c ❵ ᶜ) ∪ˡ (rwds ∣ ❴ c ❵ )
111-
112- rwds-∪ˡ-∪ : rwds-∪ˡ-decomp ˢ ≡ᵉ (rwds ∣ ❴ c ❵ ᶜ)ˢ ∪ (rwds ∣ ❴ c ❵)ˢ
113- rwds-∪ˡ-∪ = disjoint-∪ˡ-∪ (disjoint-sym res-ex-disjoint)
114-
115- disj : disjoint (dom ((rwds ∣ ❴ c ❵ˢ ᶜ) ˢ)) (dom (❴ c , 0 ❵ᵐ ˢ))
116- disj {a} a∈res a∈dom = res-comp-dom a∈res (dom-single→single a∈dom)
117-
118- rwds-∪ˡ≡sing-∪ˡ : rwds-∪ˡ-decomp ˢ ≡ᵉ ((rwds ∣ ❴ c ❵ ᶜ) ∪ˡ ❴ (c , 0) ❵ᵐ )ˢ
119- rwds-∪ˡ≡sing-∪ˡ = ≡ᵉ.trans rwds-∪ˡ-∪
120- ( ≡ᵉ.trans (∪-cong ≡ᵉ.refl (res-singleton'{m = rwds} x))
121- (≡ᵉ.sym $ disjoint-∪ˡ-∪ disj) )
122- CERT-pov (CERT-pool x) = refl
123- CERT-pov (CERT-vdel x) = refl
124-
125- injOn : (wdls : Withdrawals)
126- → ∀[ a ∈ dom (wdls ˢ) ] NetworkIdOf a ≡ NetworkId
127- → InjectiveOn (dom (wdls ˢ)) RewardAddress.stake
128- injOn _ h {record { stake = stakex }} {record { stake = stakey }} x∈ y∈ refl =
129- cong (λ u → record { net = u ; stake = stakex }) (trans (h x∈) (sym (h y∈)))
130-
131- module Certs-Pov-lemmas
132- -- TODO: prove some or all of the following assumptions, used in roof of `CERTBASE-pov`.
133- ( sumConstZero : {A : Type} ⦃ _ : DecEq A ⦄ {X : ℙ A} → getCoin (constMap X 0) ≡ 0 )
134- ( res-decomp : {A : Type} ⦃ _ : DecEq A ⦄ (m m' : A ⇀ Coin)
135- → (m ∪ˡ m')ˢ ≡ᵉ (m ∪ˡ (m' ∣ dom (m ˢ) ᶜ))ˢ )
136- ( getCoin-cong : {A : Type} ⦃ _ : DecEq A ⦄ (s : A ⇀ Coin) (s' : ℙ (A × Coin)) → s ˢ ≡ᵉ s'
137- → indexedSum' proj₂ (s ˢ) ≡ indexedSum' proj₂ s' )
138- ( ≡ᵉ-getCoinˢ : {A A' : Type} ⦃ _ : DecEq A ⦄ ⦃ _ : DecEq A' ⦄ (s : ℙ (A × Coin)) {f : A → A'}
139- → InjectiveOn (dom s) f → getCoin (mapˢ (map₁ f) s) ≡ getCoin s )
140- where
66+ CERT-pov (CERT-deleg (DELEG-delegate {rwds = rwds} _)) = sym (∪ˡsingleton0≡ rwds)
67+ CERT-pov (CERT-deleg (DELEG-reg {rwds = rwds} _)) = sym (∪ˡsingleton0≡ rwds)
68+ CERT-pov {s = ⟦ _ , stᵖ , stᵍ ⟧ᶜˢ}{⟦ _ , stᵖ' , stᵍ' ⟧ᶜˢ}
69+ (CERT-deleg (DELEG-dereg {c = c} {rwds} {vDelegs = vDelegs}{sDelegs} x)) = begin
70+ getCoin ⟦ ⟦ vDelegs , sDelegs , rwds ⟧ , stᵖ , stᵍ ⟧
71+ ≡˘⟨ ≡ᵉ-getCoin rwds-∪ˡ-decomp rwds
72+ ( ≡ᵉ.trans rwds-∪ˡ-∪ (≡ᵉ.trans ∪-sym (res-ex-∪ Dec-∈-singleton)) ) ⟩
73+ getCoin rwds-∪ˡ-decomp
74+ ≡⟨ ≡ᵉ-getCoin rwds-∪ˡ-decomp ((rwds ∣ ❴ c ❵ ᶜ) ∪ˡ ❴ (c , 0) ❵ᵐ) rwds-∪ˡ≡sing-∪ˡ ⟩
75+ getCoin ((rwds ∣ ❴ c ❵ ᶜ) ∪ˡ ❴ (c , 0) ❵ᵐ )
76+ ≡⟨ ∪ˡsingleton0≡ (rwds ∣ ❴ c ❵ ᶜ) ⟩
77+ getCoin ⟦ ⟦ vDelegs ∣ ❴ c ❵ ᶜ , sDelegs ∣ ❴ c ❵ ᶜ , rwds ∣ ❴ c ❵ ᶜ ⟧ , stᵖ' , stᵍ' ⟧
78+ ∎
79+ where
80+ module ≡ᵉ = IsEquivalence (≡ᵉ-isEquivalence {Credential × Coin})
81+ rwds-∪ˡ-decomp = (rwds ∣ ❴ c ❵ ᶜ) ∪ˡ (rwds ∣ ❴ c ❵ )
82+
83+ rwds-∪ˡ-∪ : rwds-∪ˡ-decomp ˢ ≡ᵉ (rwds ∣ ❴ c ❵ ᶜ)ˢ ∪ (rwds ∣ ❴ c ❵)ˢ
84+ rwds-∪ˡ-∪ = disjoint-∪ˡ-∪ (disjoint-sym res-ex-disjoint)
85+
86+ disj : disjoint (dom ((rwds ∣ ❴ c ❵ˢ ᶜ) ˢ)) (dom (❴ c , 0 ❵ᵐ ˢ))
87+ disj {a} a∈res a∈dom = res-comp-dom a∈res (dom-single→single a∈dom)
88+
89+ rwds-∪ˡ≡sing-∪ˡ : rwds-∪ˡ-decomp ˢ ≡ᵉ ((rwds ∣ ❴ c ❵ ᶜ) ∪ˡ ❴ (c , 0) ❵ᵐ )ˢ
90+ rwds-∪ˡ≡sing-∪ˡ = ≡ᵉ.trans rwds-∪ˡ-∪
91+ ( ≡ᵉ.trans (∪-cong ≡ᵉ.refl (res-singleton'{m = rwds} x))
92+ (≡ᵉ.sym $ disjoint-∪ˡ-∪ disj) )
93+ CERT-pov (CERT-pool x) = refl
94+ CERT-pov (CERT-vdel x) = refl
95+
96+ injOn : (wdls : Withdrawals)
97+ → ∀[ a ∈ dom (wdls ˢ) ] NetworkIdOf a ≡ NetworkId
98+ → InjectiveOn (dom (wdls ˢ)) RewardAddress.stake
99+ injOn _ h {record { stake = stakex }} {record { stake = stakey }} x∈ y∈ refl =
100+ cong (λ u → record { net = u ; stake = stakex }) (trans (h x∈) (sym (h y∈)))
101+
102+ module Certs-Pov-lemmas
103+ -- TODO: prove some or all of the following assumptions, used in roof of `CERTBASE-pov`.
104+ ( res-decomp : {A : Type} ⦃ _ : DecEq A ⦄ (m m' : A ⇀ Coin)
105+ → (m ∪ˡ m')ˢ ≡ᵉ (m ∪ˡ (m' ∣ dom (m ˢ) ᶜ))ˢ )
106+ ( getCoin-cong : {A : Type} ⦃ _ : DecEq A ⦄ (s : A ⇀ Coin) (s' : ℙ (A × Coin)) → s ˢ ≡ᵉ s'
107+ → indexedSum' proj₂ (s ˢ) ≡ indexedSum' proj₂ s' )
108+ ( ≡ᵉ-getCoinˢ : {A A' : Type} ⦃ _ : DecEq A ⦄ ⦃ _ : DecEq A' ⦄ (s : ℙ (A × Coin)) {f : A → A'}
109+ → InjectiveOn (dom s) f → getCoin (mapˢ (map₁ f) s) ≡ getCoin s )
110+ where
141111```
142112-->
143113
0 commit comments