Skip to content

Commit 0eb0552

Browse files
committed
Completeness for ValidAction
1 parent 1bea2ea commit 0eb0552

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

formal-spec/Leios/Trace/Verifier.agda

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ data Action : Type where
1414
IB-Role-Action EB-Role-Action V-Role-Action : Action
1515
No-IB-Role-Action No-EB-Role-Action No-V-Role-Action : Action
1616
Ftch-Action Slot-Action : Action
17-
-- Base₁-Action Base₂a-Action Base₂b-Action : Action
17+
Base₁-Action : Action
18+
Base₂a-Action : EndorserBlock Action
19+
Base₂b-Action : Action
1820

1921
Actions = List (Action × LeiosInput)
2022

@@ -69,27 +71,25 @@ data ValidAction : Action → LeiosState → LeiosInput → Type where
6971
Slot : let open LeiosState s renaming (FFDState to ffds; BaseState to bs)
7072
(msgs , (ffds' , _)) = fetch-total {ffds}
7173
in .(Upkeep ≡ᵉ allUpkeep)
72-
.(bs B.-⟦ B.FTCH-LDG / B.BASE-LDG [] ⟧⇀ tt) -- TODO: rbs ≠ []
74+
.(bs B.-⟦ B.FTCH-LDG / B.BASE-LDG [] ⟧⇀ tt)
7375
.(ffds FFD.-⟦ FFD.Fetch / FFD.FetchRes msgs ⟧⇀ ffds')
7476
ValidAction Slot-Action s SLOT
7577

7678
Ftch : ValidAction Ftch-Action s FTCH-LDG
7779

78-
{-
7980
Base₁ : {txs} ValidAction Base₁-Action s (SUBMIT (inj₂ txs))
8081

8182
Base₂a : {eb} let open LeiosState s renaming (BaseState to bs)
8283
in .(needsUpkeep Base)
8384
.(eb ∈ filter (λ eb isVoteCertified s eb × eb ∈ᴮ slice L slot 2) EBs)
8485
.(bs B.-⟦ B.SUBMIT (this eb) / B.EMPTY ⟧⇀ tt)
85-
ValidAction Base₂a-Action s SLOT
86+
ValidAction (Base₂a-Action eb) s SLOT
8687

8788
Base₂b : let open LeiosState s renaming (BaseState to bs)
8889
in .(needsUpkeep Base)
8990
.([] ≡ filter (λ eb isVoteCertified s eb × eb ∈ᴮ slice L slot 2) EBs)
9091
.(bs B.-⟦ B.SUBMIT (that ToPropose) / B.EMPTY ⟧⇀ tt)
9192
ValidAction Base₂b-Action s SLOT
92-
-}
9393

9494
private variable
9595
i : LeiosInput
@@ -130,9 +130,9 @@ private variable
130130
} ↑ L.filter isValid? msgs
131131
, EMPTY)
132132
⟦ Ftch {s} ⟧ = s , FTCH-LDG (LeiosState.Ledger s)
133-
-- ⟦ Base₁ {s} {txs} ⟧ = record s { ToPropose = txs } , EMPTY
134-
-- ⟦ Base₂a {s} x x₁ x₂ ⟧ = addUpkeep record s { BaseState = tt } Base , EMPTY
135-
-- ⟦ Base₂b {s} x x₁ x₂ ⟧ = addUpkeep record s { BaseState = tt } Base , EMPTY
133+
⟦ Base₁ {s} {txs} ⟧ = record s { ToPropose = txs } , EMPTY
134+
⟦ Base₂a {s} x x₁ x₂ ⟧ = addUpkeep record s { BaseState = tt } Base , EMPTY
135+
⟦ Base₂b {s} x x₁ x₂ ⟧ = addUpkeep record s { BaseState = tt } Base , EMPTY
136136

137137
instance
138138
Dec-ValidAction : ValidAction ⁇³
@@ -200,31 +200,29 @@ instance
200200
Dec-ValidAction {Ftch-Action} {s} {SLOT} .dec = no λ ()
201201
Dec-ValidAction {Ftch-Action} {s} {INIT _} .dec = no λ ()
202202
Dec-ValidAction {Ftch-Action} {s} {SUBMIT _} .dec = no λ ()
203-
{-
204203
Dec-ValidAction {Base₁-Action} {s} {SUBMIT (inj₁ ebs)} .dec = no λ ()
205204
Dec-ValidAction {Base₁-Action} {s} {SUBMIT (inj₂ txs)} .dec = yes (Base₁ {s} {txs})
206205
Dec-ValidAction {Base₁-Action} {s} {SLOT} .dec = no λ ()
207206
Dec-ValidAction {Base₁-Action} {s} {FTCH-LDG} .dec = no λ ()
208207
Dec-ValidAction {Base₁-Action} {s} {INIT _} .dec = no λ ()
209-
Dec-ValidAction {Base₂a-Action} {s} {SLOT} .dec
208+
Dec-ValidAction {Base₂a-Action eb} {s} {SLOT} .dec
210209
with dec | dec | dec
211210
... | yes x | yes y | yes z = yes (Base₂a x y z)
212211
... | no ¬p | _ | _ = no λ where (Base₂a p _ _) ⊥-elim (¬p (recompute dec p))
213-
... | _ | no ¬p | _ = no λ where (Base₂a _ p _) → ⊥-elim (¬p {!!}) -- (recompute dec p))
212+
... | _ | no ¬p | _ = no λ where (Base₂a {s} {eb} _ p _) ⊥-elim (¬p (recompute dec p))
214213
... | _ | _ | no ¬p = no λ where (Base₂a _ _ p) ⊥-elim (¬p (recompute dec p))
215-
Dec-ValidAction {Base₂a-Action} {s} {SUBMIT _} .dec = no λ ()
216-
Dec-ValidAction {Base₂a-Action} {s} {FTCH-LDG} .dec = no λ ()
217-
Dec-ValidAction {Base₂a-Action} {s} {INIT _} .dec = no λ ()
214+
Dec-ValidAction {Base₂a-Action _} {s} {SUBMIT _} .dec = no λ ()
215+
Dec-ValidAction {Base₂a-Action _} {s} {FTCH-LDG} .dec = no λ ()
216+
Dec-ValidAction {Base₂a-Action _} {s} {INIT _} .dec = no λ ()
218217
Dec-ValidAction {Base₂b-Action} {s} {SLOT} .dec
219218
with dec | dec | dec
220219
... | yes x | yes y | yes z = yes (Base₂b x y z)
221220
... | no ¬p | _ | _ = no λ where (Base₂b p _ _) ⊥-elim (¬p (recompute dec p))
222-
... | _ | no ¬p | _ = no λ where (Base₂b _ p _) → ⊥-elim (¬p {!!}) -- (recompute dec p))
221+
... | _ | no ¬p | _ = no λ where (Base₂b _ p _) ⊥-elim (¬p (recompute dec p))
223222
... | _ | _ | no ¬p = no λ where (Base₂b _ _ p) ⊥-elim (¬p (recompute dec p))
224223
Dec-ValidAction {Base₂b-Action} {s} {SUBMIT _} .dec = no λ ()
225224
Dec-ValidAction {Base₂b-Action} {s} {FTCH-LDG} .dec = no λ ()
226225
Dec-ValidAction {Base₂b-Action} {s} {INIT _} .dec = no λ ()
227-
-}
228226

229227
mutual
230228
data ValidTrace : Actions Type where
@@ -251,9 +249,9 @@ Irr-ValidAction (No-EB-Role x x₁) (No-EB-Role x₂ x₃) = refl
251249
Irr-ValidAction (No-V-Role _ _) (No-V-Role _ _) = refl
252250
Irr-ValidAction (Slot x x₁ x₂) (Slot x₃ x₄ x₅) = refl
253251
Irr-ValidAction Ftch Ftch = refl
254-
-- Irr-ValidAction Base₁ Base₁ = refl
255-
-- Irr-ValidAction (Base₂a x x₁ x₂) (Base₂a x₃ x₄ x₅) = {!refl!}
256-
-- Irr-ValidAction (Base₂b x x₁ x₂) (Base₂b x₃ x₄ x₅) = refl
252+
Irr-ValidAction Base₁ Base₁ = refl
253+
Irr-ValidAction (Base₂a x x₁ x₂) (Base₂a x₃ x₄ x₅) = refl
254+
Irr-ValidAction (Base₂b x x₁ x₂) (Base₂b x₃ x₄ x₅) = refl
257255

258256
Irr-ValidTrace : {αs} Irrelevant (ValidTrace αs)
259257
Irr-ValidTrace [] [] = refl
@@ -275,35 +273,32 @@ instance
275273
$ subst (λ x ValidAction α x i) (cong (proj₁ ∘ ⟦_⟧∗) $ Irr-ValidTrace tr vαs) vα
276274
... | yes vα = yes $ _ / _ ∷ vαs ⊣ vα
277275

278-
{-
279276
getLabel : just s -⟦ i / o ⟧⇀ s′ Action
280277
getLabel (Slot _ _ _) = Slot-Action
281278
getLabel Ftch = Ftch-Action
282279
getLabel Base₁ = Base₁-Action
283-
getLabel (Base₂a _ _ _) = Base₂a-Action
280+
getLabel (Base₂a {s} {eb} _ _ _) = Base₂a-Action eb
284281
getLabel (Base₂b _ _ _) = Base₂b-Action
285282
getLabel (Roles (IB-Role _ _ _)) = IB-Role-Action
286283
getLabel (Roles (EB-Role _ _ _)) = EB-Role-Action
287284
getLabel (Roles (V-Role _ _ _)) = V-Role-Action
288285
getLabel (Roles (No-IB-Role _ _)) = No-IB-Role-Action
289286
getLabel (Roles (No-EB-Role _ _)) = No-EB-Role-Action
290287
getLabel (Roles (No-V-Role _ _)) = No-V-Role-Action
291-
-}
292288

293289
ValidAction-sound : (va : ValidAction α s i) let (s′ , o) = ⟦ va ⟧ in just s -⟦ i / o ⟧⇀ s′
294290
ValidAction-sound (Slot {s} x x₁ x₂) = Slot {s} {rbs = []} (recompute dec x) (recompute dec x₁) (recompute dec x₂)
295291
ValidAction-sound Ftch = Ftch
296-
-- ValidAction-sound (Base₁ {s} {txs}) = Base₁ {s} {txs}
297-
-- ValidAction-sound (Base₂a {s} x x₁ x₂) = Base₂a {s} (recompute dec x) (recompute dec x₁) (recompute dec x₂)
298-
-- ValidAction-sound (Base₂b {s} x x₁ x₂) = Base₂b {s} (recompute dec x) (recompute dec x₁) (recompute dec x₂)
292+
ValidAction-sound (Base₁ {s} {txs}) = Base₁ {s} {txs}
293+
ValidAction-sound (Base₂a {s} x x₁ x₂) = Base₂a {s} (recompute dec x) (recompute dec x₁) (recompute dec x₂)
294+
ValidAction-sound (Base₂b {s} x x₁ x₂) = Base₂b {s} (recompute dec x) (recompute dec x₁) (recompute dec x₂)
299295
ValidAction-sound (IB-Role {s} x x₁ x₂) = Roles (IB-Role {s} (recompute dec x) (recompute dec x₁) (recompute dec x₂))
300296
ValidAction-sound (EB-Role {s} x x₁ x₂) = Roles (EB-Role {s} (recompute dec x) (recompute dec x₁) (recompute dec x₂))
301297
ValidAction-sound (V-Role {s} x x₁ x₂) = Roles (V-Role {s} (recompute dec x) (recompute dec x₁) (recompute dec x₂))
302298
ValidAction-sound (No-IB-Role {s} x x₁) = Roles (No-IB-Role {s} x x₁)
303299
ValidAction-sound (No-EB-Role {s} x x₁) = Roles (No-EB-Role {s} x x₁)
304300
ValidAction-sound (No-V-Role {s} x x₁) = Roles (No-V-Role {s} x x₁)
305301

306-
{-
307302
ValidAction-complete : (st : just s -⟦ i / o ⟧⇀ s′) ValidAction (getLabel st) s i
308303
ValidAction-complete {s} {s′} (Roles (IB-Role {s} {π} {ffds'} x x₁ x₂)) =
309304
let open LeiosState s renaming (FFDState to ffds)
@@ -327,8 +322,10 @@ ValidAction-complete {s} (Roles (No-IB-Role x x₁)) = No-IB-Role {s} x x₁
327322
ValidAction-complete {s} (Roles (No-EB-Role x x₁)) = No-EB-Role {s} x x₁
328323
ValidAction-complete {s} (Roles (No-V-Role x x₁)) = No-V-Role {s} x x₁
329324
ValidAction-complete {s} Ftch = Ftch {s}
330-
-- ValidAction-complete {s} Base₁ = Base₁ {s}
331-
-- ValidAction-complete {s} (Base₂a x x₁ x₂) = Base₂a {s} x x₁ x₂
332-
-- ValidAction-complete {s} (Base₂b x x₁ x₂) = Base₂b {s} x x₁ x₂
333-
ValidAction-complete {s} (Slot x x₁ x₂) = Slot {s} x x₁ {!!}
334-
-}
325+
ValidAction-complete {s} Base₁ = Base₁ {s}
326+
ValidAction-complete {s} (Base₂a x x₁ x₂) = Base₂a {s} x x₁ x₂
327+
ValidAction-complete {s} (Base₂b x x₁ x₂) = Base₂b {s} x x₁ x₂
328+
ValidAction-complete {s} (Slot {s} x x₁ x₂) =
329+
let open LeiosState s renaming (FFDState to ffds)
330+
(_ , (_ , pr)) = fetch-total {ffds}
331+
in Slot {s} x x₁ pr

0 commit comments

Comments
 (0)