-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScheduler.agda
55 lines (42 loc) · 2.18 KB
/
Scheduler.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-- Abstract definitions of schedulers
open import Lattice public
module Scheduler (𝓛 : Lattice) where
open Lattice.Lattice 𝓛
open import Data.Nat
--open import Data.Product using (∃) --TODO remove
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
data Event (l : Label) : Set where
NoStep : Event l
Step : Event l
Done : Event l
Fork : (h : Label) (n : ℕ) -> l ⊑ h -> Event l
∙ : Event l
-- Erasure of labeled events
εᴱ : ∀ {l} -> Label -> Event l -> Event l
εᴱ lₐ (Fork h n p) with h ⊑? lₐ
εᴱ lₐ (Fork h n p) | yes _ = Fork h n p
εᴱ lₐ (Fork h n p) | no ¬p = Step
εᴱ lₐ e = e
data Message : Label -> Set where
_,_,_ : (l : Label) (n : ℕ) (e : Event l) -> Message l
-- Erasure of labeled messages
εᴹ : ∀ {l lₐ} -> Dec (l ⊑ lₐ) -> Message l -> Message l
εᴹ {._} {lₐ} (yes p) (l , n , e) = l , n , εᴱ lₐ e
εᴹ (no ¬p) (l , n , e) = l , n , ∙
record Scheduler : Set₁ where
constructor Sch
field
State : Set
_⟶_↑_ : ∀ {l} -> State -> State -> Message l -> Set
εˢ : Label -> State -> State
ε-sch-dist : ∀ {s₁ s₂ l lₐ} {m : Message l} -> (x : Dec (l ⊑ lₐ)) -> s₁ ⟶ s₂ ↑ m -> (εˢ lₐ s₁) ⟶ (εˢ lₐ s₂) ↑ (εᴹ x m)
ε-sch-≡ : ∀ {s₁ s₂ l lₐ} {m : Message l} -> ¬ (l ⊑ lₐ) -> s₁ ⟶ s₂ ↑ m -> (εˢ lₐ s₁) ≡ (εˢ lₐ s₂) -- TODO use low-equivalence
deterministic-scheduler : ∀ {l n e} {s₁ s₂ s₃ : State} -> s₁ ⟶ s₂ ↑ (l , n , e) -> s₁ ⟶ s₃ ↑ (l , n , e) -> s₂ ≡ s₃
_≈ˢ-⟨_⟩_ : State -> Label -> State -> Set -- Low-equivalence data-type, TODO better name?
_≈ˢ-⟨_~_~_⟩_ : State -> ℕ -> Label -> ℕ -> State -> Set
offset₁ : {lₐ : Label} {s₁ s₂ : State} -> s₁ ≈ˢ-⟨ lₐ ⟩ s₂ -> ℕ
offset₂ : {lₐ : Label} {s₁ s₂ : State} -> s₁ ≈ˢ-⟨ lₐ ⟩ s₂ -> ℕ
align : ∀ {lₐ s₁ s₂} -> (eq : s₁ ≈ˢ-⟨ lₐ ⟩ s₂) -> s₁ ≈ˢ-⟨ offset₁ eq ~ lₐ ~ offset₂ eq ⟩ s₂
forget : ∀ {lₐ s₁ s₂ n m} -> s₁ ≈ˢ-⟨ n ~ lₐ ~ m ⟩ s₂ -> s₁ ≈ˢ-⟨ lₐ ⟩ s₂
open Scheduler