diff --git a/src/Peras/Block.agda b/src/Peras/Block.agda index 04be876a..3e7ccbb9 100644 --- a/src/Peras/Block.agda +++ b/src/Peras/Block.agda @@ -5,7 +5,7 @@ open import Agda.Builtin.Nat open import Data.Bool open import Data.List open import Data.Tree.AVL.Sets renaming (⟨Set⟩ to set) -open import Relation.Binary using (StrictTotalOrder) +open import Relation.Binary using (DecidableEquality; StrictTotalOrder) open import Haskell.Prelude using (Eq) @@ -34,6 +34,8 @@ postulate paLt : Relation.Binary.Rel PartyId 0ℓ paIs : Relation.Binary.IsStrictTotalOrder paEq paLt + _≟-PartyId_ : DecidableEquality PartyId + PartyIdO : StrictTotalOrder 0ℓ 0ℓ 0ℓ PartyIdO = record { Carrier = PartyId ; diff --git a/src/Peras/SmallStep.lagda.md b/src/Peras/SmallStep.lagda.md index 472920aa..6b9fd1bd 100644 --- a/src/Peras/SmallStep.lagda.md +++ b/src/Peras/SmallStep.lagda.md @@ -9,8 +9,9 @@ module Peras.SmallStep where ```agda data _⇀_ : Stateᵍ → Stateᵍ → Set where @@ -265,13 +282,15 @@ module _ {block₀ : Block⋆} where Cons : ∀ {M p ps} {N} {O} → execution-order M ≡ p ∷ ps - → (record M { execution-order = ps }) [ honest? p ]⇀ N + → record M { execution-order = ps } [ honest? p ]⇀ N → N ⇀ O ------ → M ⇀ O ``` + # Create @@ -292,13 +313,13 @@ module _ {block₀ : Block⋆} where ------------------------------- → N [ Honest {p} ]↷ N - honest : ∀ {p N} {sₗ sₗ′ : Stateˡ} {msgs} - → (msgs , sₗ′) ≡ honestCreate (clock N) (txSelection (clock N) p) sₗ + honest : ∀ {p M N} {sₗ sₗ′ : Stateˡ} {msgs} + → (msgs , sₗ′) ≡ honestCreate (clock M) (txSelection (clock M) p) sₗ + → N ≡ honestGossip msgs M ------------------------------------------------------------------ - → N [ Honest {p} ]↷ + → M [ Honest {p} ]↷ record N { - stateMap = M.insert p sₗ′ (stateMap N); - messages = msgs ++ messages N + stateMap = M.insert p sₗ′ (stateMap N) } corrupt : ∀ {p N} @@ -319,8 +340,8 @@ module _ {block₀ : Block⋆} where → execution-order M ≡ p ∷ ps → M [ honest? p ]↷ N → N ↷ O - ------ - → (record M { execution-order = ps }) ↷ O + ------------------------------------- + → record M { execution-order = ps } ↷ O ``` @@ -329,38 +350,44 @@ module _ {block₀ : Block⋆} where ```agda data _↝_ : Stateᵍ → Stateᵍ → Set where - Deliver : ∀ {s sm ms hs ps} {N} - → let M = ⟪ s , Ready , sm , ms , hs , ps ⟫ - in M ⇀ N - --------------------------- - → M ↝ record N { - progress = Delivered - } - - Bake : ∀ {s sm ms hs ps} {N} - → let M = ⟪ s , Delivered , sm , ms , hs , ps ⟫ - in M ↷ N - ----------------------- - → M ↝ record N { - progress = Baked - } - - NextRound : ∀ {s sm ms hs ps} - -------------------------------- - → ⟪ s , Baked , sm , ms , hs , ps ⟫ ↝ - ⟪ suc s , Ready , sm , ms , hs , ps ⟫ - - PermParties : ∀ {s p sm ms hs ps ps′} - → ps ↭ ps′ - -------------------------- - → ⟪ s , p , sm , ms , hs , ps ⟫ ↝ - ⟪ s , p , sm , ms , hs , ps′ ⟫ - - PermMsgs : ∀ {s p sm ms ms′ hs ps} - → ms ↭ ms′ - -------------------------- - → ⟪ s , p , sm , ms , hs , ps ⟫ ↝ - ⟪ s , p , sm , ms′ , hs , ps ⟫ + Deliver : ∀ {M N} + → progress M ≡ Ready + → M ⇀ N + --------------------------- + → M ↝ record N { + progress = Delivered + } + + Bake : ∀ {M N} + → progress M ≡ Delivered + → M ↷ N + ----------------------- + → M ↝ record N { + progress = Baked + } + + NextRound : ∀ {M} + → progress M ≡ Baked + ------------------------------ + → M ↝ record M { + clock = suc (clock M) ; + progress = Ready + } + + PermParties : ∀ {N ps} + → execution-order N ↭ ps + --------------------------- + → N ↝ record N { + execution-order = ps + } + + PermMsgs : ∀ {N ms} + → messages N ↭ ms + -------------------- + → N ↝ record N { + messages = ms + } + ``` ## Reflexive, transitive closure (which is big-step in the paper) @@ -405,7 +432,10 @@ module _ {block₀ : Block⋆} where (cartesianProduct (history N) (history N)) → CollisionFree N -} + ``` +