@@ -189,24 +189,24 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
189
189
failing, promise_select effectively computes the allowed_promises
190
190
set. *)
191
191
promise_select :
192
- (* fuel *) nat -> (* tid *) nat → memoryMap → pModel.(tState) →
193
- PromMemory.t pModel.(mEvent) → Exec.res string pModel.(mEvent);
192
+ (* fuel *) nat → (* tid *) nat →
193
+ (* termination condition *) (registerMap → bool) →
194
+ memoryMap → pModel.(tState) → PromMemory.t pModel.(mEvent) →
195
+ Exec.res string pModel.(mEvent);
194
196
195
197
promise_select_sound :
196
- ∀ n tid initMem ts mem,
197
- ∀ ev ∈ (promise_select n tid initMem ts mem),
198
+ ∀ fuel tid term initMem ts mem,
199
+ ∀ ev ∈ (promise_select fuel tid term initMem ts mem),
198
200
ev ∈ pModel.(allowed_promises) tid initMem ts mem;
199
201
promise_select_complete :
200
- ∀ n tid initMem ts mem,
201
- ¬ Exec.has_error (promise_select n tid initMem ts mem) →
202
+ ∀ fuel tid term initMem ts mem,
203
+ ¬ Exec.has_error (promise_select fuel tid term initMem ts mem) →
202
204
∀ ev ∈ pModel.(allowed_promises) tid initMem ts mem,
203
- ev ∈ promise_select n tid initMem ts mem
205
+ ev ∈ promise_select fuel tid term initMem ts mem
204
206
}.
205
207
Arguments BasicExecutablePM : clear implicits.
206
208
207
-
208
209
Module PState. (* namespace *)
209
-
210
210
Section PS.
211
211
Context {tState : Type}.
212
212
Context {mEvent : Type}.
@@ -226,7 +226,6 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
226
226
End PS.
227
227
Arguments t : clear implicits.
228
228
229
-
230
229
Section PSProm.
231
230
Context (isem : iMon ()).
232
231
Context (prom : PromisingModel).
@@ -345,7 +344,7 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
345
344
(** Get a list of possible promises for a thread by tid *)
346
345
Definition promise_select_tid (fuel : nat) (st : t)
347
346
(tid : fin n) : Exec.res string mEvent :=
348
- prom.(promise_select) n tid (initmem st) (tstate tid st) (events st).
347
+ prom.(promise_select) fuel tid (term tid) (initmem st) (tstate tid st) (events st).
349
348
350
349
(** Take any promising step for that tid and promise it *)
351
350
Definition cpromise_tid (fuel : nat) (tid : fin n)
@@ -361,7 +360,6 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
361
360
search but it is obviously correct. If a thread has reached termination
362
361
no progress is made in the thread (either instruction running or
363
362
promises *)
364
- (* TODO: Make if/then/else syntax only work on bool *)
365
363
Definition run_step (fuel : nat) : Exec.t t string () :=
366
364
st ← mGet;
367
365
tid ← mchoose n;
@@ -387,17 +385,14 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
387
385
388
386
(** Computational evaluate all the possible allowed final states according
389
387
to the promising model prom starting from st *)
390
- Program Fixpoint run (fuel : nat) : Exec.t t string final :=
391
- match fuel with
392
- | 0%nat => mthrow "not enough fuel"
393
- | S fuel =>
394
- st ← mGet;
395
- if dec $ terminated prom term st then mret (make_final st _)
396
- else
397
- run_step fuel;;
398
- run fuel
399
- end .
400
- Solve All Obligations with naive_solver.
388
+ Fixpoint run (fuel : nat) : Exec.t t string final :=
389
+ st ← mGet;
390
+ if decide $ terminated prom term st is left pt then mret (make_final st pt)
391
+ else
392
+ if fuel is S fuel then
393
+ run_step (S fuel);;
394
+ run fuel
395
+ else mthrow "Could not finish running within the size of the fuel".
401
396
End CPS.
402
397
Arguments to_final_MState {_ _ _}.
403
398
End CPState.
0 commit comments