@bramas/simulant-lean 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Simulant/Exec.lean +3 -3
- package/Simulant/NonVacuity.lean +6 -1
- package/Simulant/Round.lean +3 -2
- package/package.json +1 -1
package/Simulant/Exec.lean
CHANGED
|
@@ -4,7 +4,7 @@ import Simulant.Round
|
|
|
4
4
|
# Executions, tasks and non-vacuity (plan, Sections 3.9, 3.10 and 5.2)
|
|
5
5
|
|
|
6
6
|
Every execution permitted by the round is considered (no fairness on the
|
|
7
|
-
adversary's choices), except that
|
|
7
|
+
adversary's choices), except that semi-synchronous and sequential rounds only admit
|
|
8
8
|
scheduler-fair executions: every agent that acts forever is activated
|
|
9
9
|
infinitely often.
|
|
10
10
|
-/
|
|
@@ -48,7 +48,7 @@ def Fair (e : Execution σ) : Prop :=
|
|
|
48
48
|
∀ n, ∃ j, n ≤ j ∧ a ∈ e.active j
|
|
49
49
|
|
|
50
50
|
def Admissible (e : Execution σ) : Prop :=
|
|
51
|
-
m.Valid act0 init e ∧ (m.round
|
|
51
|
+
m.Valid act0 init e ∧ (m.round ≠ .fsync → Fair e)
|
|
52
52
|
|
|
53
53
|
/-- The correctness statement: every admissible execution satisfies the goal. -/
|
|
54
54
|
def Correct (verdict : Config σ → Verdict) (goal : Goal) : Prop :=
|
|
@@ -144,7 +144,7 @@ theorem toExecution_valid (m : Model σ) (act0 : σ.A) (init : ND (Config σ)) (
|
|
|
144
144
|
theorem hasExecution (m : Model σ) (act0 : σ.A) (init : ND (Config σ)) (l : Lasso σ)
|
|
145
145
|
(hround : m.round = .fsync) (hv : l.Valid m act0) (hinit : ND.Can init l.start) :
|
|
146
146
|
m.HasExecution act0 init :=
|
|
147
|
-
⟨l.toExecution hv.1, toExecution_valid m act0 init l hv hinit, fun h =>
|
|
147
|
+
⟨l.toExecution hv.1, toExecution_valid m act0 init l hv hinit, fun h => False.elim (h hround)⟩
|
|
148
148
|
|
|
149
149
|
end Lasso
|
|
150
150
|
end Simulant
|
package/Simulant/NonVacuity.lean
CHANGED
|
@@ -65,6 +65,11 @@ theorem activate_total (C : Config σ) : ∃ a, ND.Can (m.activate C) a := by
|
|
|
65
65
|
refine ⟨[x], ND.can_choose.2 ?_⟩
|
|
66
66
|
simp only [nonemptySubsets, List.mem_flatMap, List.mem_range]
|
|
67
67
|
exact ⟨0, List.length_pos_of_mem hx, by rw [combos_one]; exact List.mem_map_of_mem hx⟩
|
|
68
|
+
· split
|
|
69
|
+
· exact ⟨_, ND.can_pure.2 rfl⟩
|
|
70
|
+
· rename_i h
|
|
71
|
+
obtain ⟨x, hx⟩ := List.exists_mem_of_ne_nil _ (fun he => h (List.isEmpty_iff.2 he))
|
|
72
|
+
exact ⟨[x], ND.can_choose.2 (List.mem_map_of_mem hx)⟩
|
|
68
73
|
|
|
69
74
|
omit [FlagSet σ.F] in
|
|
70
75
|
theorem frames_ne_nil (a : Agent σ) : m.frames a ≠ [] := by
|
|
@@ -127,7 +132,7 @@ theorem hasExecution (init : ND (Config σ)) (hround : m.round = .fsync) (hinit
|
|
|
127
132
|
refine ⟨⟨config, fun n => (next (config n)).1, fun n => (next (config n)).2.1⟩, ⟨?_, fun n => ?_⟩, ?_⟩
|
|
128
133
|
· exact Classical.choose_spec hinit
|
|
129
134
|
· exact Classical.choose_spec (Classical.choose_spec (Classical.choose_spec (htot (config n))))
|
|
130
|
-
· intro h;
|
|
135
|
+
· intro h; exact False.elim (h hround)
|
|
131
136
|
|
|
132
137
|
end Model
|
|
133
138
|
end Simulant
|
package/Simulant/Round.lean
CHANGED
|
@@ -140,7 +140,7 @@ inductive FrameModel (σ : Sig) where
|
|
|
140
140
|
| persistent (get : σ.X → Bool)
|
|
141
141
|
|
|
142
142
|
inductive RoundKind where
|
|
143
|
-
| fsync | ssync
|
|
143
|
+
| fsync | ssync | sequential
|
|
144
144
|
deriving DecidableEq, Repr
|
|
145
145
|
|
|
146
146
|
structure Model (σ : Sig) where
|
|
@@ -196,12 +196,13 @@ namespace Model
|
|
|
196
196
|
|
|
197
197
|
variable [FlagSet σ.F] (m : Model σ)
|
|
198
198
|
|
|
199
|
-
/-- FSYNC
|
|
199
|
+
/-- FSYNC: all eligible agents; SSYNC: a nonempty subset; sequential: a singleton. -/
|
|
200
200
|
def activate (C : Config σ) : ND (List (Fin σ.k)) :=
|
|
201
201
|
let eligible := (List.finRange σ.k).filter fun i => FlagSet.acts C.agents[i].flags != .never
|
|
202
202
|
match m.round with
|
|
203
203
|
| .fsync => pure eligible
|
|
204
204
|
| .ssync => if eligible.isEmpty then pure eligible else ND.choose "activation" (nonemptySubsets eligible)
|
|
205
|
+
| .sequential => if eligible.isEmpty then pure eligible else ND.choose "activation" (eligible.map ([·]))
|
|
205
206
|
|
|
206
207
|
def frames (a : Agent σ) : List Bool :=
|
|
207
208
|
match m.frame with
|