Skip to content

Commit 0b5bbeb

Browse files
committed
PID -> Ref
1 parent db7c476 commit 0b5bbeb

5 files changed

Lines changed: 30 additions & 195 deletions

File tree

_CoqProject

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ theories/Multifunction.v
55
theories/TokenMachine.v
66
theories/TransitionSystem.v
77
theories/Queue.v
8-
theories/Pid.v
8+
theories/Ref.v
99
theories/ListSelector.v
1010
theories/IOHandler.v
1111
theories/Handlers/Storage.v

theories/Handlers/Mailbox.v

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ From Coq Require Import
66
Require Import
77
Queue
88
Multifunction
9-
Pid
9+
Ref
1010
IOHandler.
1111

1212
From LibTx Require Import
@@ -26,37 +26,37 @@ Section defn.
2626
}.
2727

2828
(** Handler state *)
29-
Let t := Pid.FMap.M.t Mailbox.
29+
Let t := Ref.FMap.M.t Mailbox.
3030

3131
(** "Address" of the mailbox *)
3232
Record Address {mba_t : Set} :=
3333
mkAddress
3434
{
35-
mba_pid : PID
35+
mba_pid : Ref
3636
}.
3737

38-
(* Program Definition new_mailbox (pid : PID) (mb_t : Set) : MFun t t := *)
38+
(* Program Definition new_mailbox (pid : Ref) (mb_t : Set) : MFun t t := *)
3939
(* {| *)
4040
(* morphism s s' := *)
4141
(* s' = put pid {| mb_t := mb_t; mb_q := empty |} s *)
4242
(* |}. *)
4343
(* Next Obligation. *)
4444
(* unfold exists_equiv. *)
45-
(* eapply put_mor in H; try easy; try exact PIDOrd.eq_dec. *)
45+
(* eapply put_mor in H; try easy; try exact RefOrd.eq_dec. *)
4646
(* exists (put pid {| mb_t := mb_t0; mb_q := empty |} x'). *)
4747
(* split; try reflexivity. *)
4848
(* simpl in H. *)
4949
(* now erewrite H. *)
5050
(* Qed. *)
5151

52-
(* Program Definition drop_mailbox (pid : PID) : MFun t t := *)
52+
(* Program Definition drop_mailbox (pid : Ref) : MFun t t := *)
5353
(* {| *)
5454
(* morphism s s' := *)
5555
(* s' = delete pid s *)
5656
(* |}. *)
5757
(* Next Obligation. *)
5858
(* unfold exists_equiv. *)
59-
(* eapply delete_mor in H; try easy; try exact PIDOrd.eq_dec. *)
59+
(* eapply delete_mor in H; try easy; try exact RefOrd.eq_dec. *)
6060
(* exists (delete pid x'). *)
6161
(* split; try reflexivity. *)
6262
(* simpl in H. *)
@@ -72,7 +72,7 @@ Section defn.
7272
end.
7373

7474
Inductive do_send_msg : forall (Tmbox Tmsg : Set),
75-
PID -> @Queue (@Message Tmbox) -> @Message Tmsg ->
75+
Ref -> @Queue (@Message Tmbox) -> @Message Tmsg ->
7676
t -> t -> Prop :=
7777
| do_send_msg_ : forall T pid msg mbox mailboxes,
7878
do_send_msg
@@ -86,7 +86,7 @@ Section defn.
8686
Definition send_morph mboxes (x : True * t) : Prop :=
8787
let (_, mboxes') := x in
8888
let pid := mba_pid to in
89-
match @get PID Mailbox _ _ pid mboxes with
89+
match @get Ref Mailbox _ _ pid mboxes with
9090
| None =>
9191
mboxes' == mboxes
9292
| Some {| mb_t := Tmbox; mb_q := mbox |} =>

theories/IOHandler.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ From Coq Require Import
66
From SLOT Require Import
77
Setoids
88
TransitionSystem
9-
Pid.
9+
Ref.
1010

1111
From Hammer Require Import
1212
Tactics.
@@ -20,10 +20,10 @@ Section IOHandler.
2020
Class IOHandler := {
2121
h_state : Type;
2222
h_setoid : Setoid h_state;
23-
h_handler (pid : PID) (req : Request) : MFunRet (Reply req) h_state;
23+
h_handler (pid : Ref) (req : Request) : MFunRet (Reply req) h_state;
2424

25-
h_spawn (pid : PID) (mailbox_t : Set) : h_state -> h_state;
26-
h_terminate (pid : PID) : h_state -> h_state;
25+
h_spawn (pid : Ref) (mailbox_t : Set) : h_state -> h_state;
26+
h_terminate (pid : Ref) : h_state -> h_state;
2727
}.
2828
End IOHandler.
2929

theories/Pid.v

Lines changed: 0 additions & 165 deletions
This file was deleted.

theories/VM.v

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Import ListNotations.
88
From SLOT Require
99
Setoids
1010
TransitionSystem
11-
Pid
11+
Ref
1212
ListSelector
1313
IOHandler
1414
Mailbox.
1515

1616
Import Setoids TransitionSystem ListSelector Mailbox.
17-
Export Pid IOHandler.
17+
Export Ref IOHandler.
1818

1919
From Hammer Require Import
2020
Hammer.
@@ -57,7 +57,7 @@ Section VM.
5757

5858
Record Process :=
5959
mkProcess
60-
{ pid : PID;
60+
{ pid : Ref;
6161
proc_mb_t : Set;
6262
cont : @Program proc_mb_t;
6363
}.
@@ -72,10 +72,10 @@ Section VM.
7272
runq : list Process;
7373
(* Counter that gets incremented when process spawns a child.
7474
This counter is used as a suffix of the child's pid *)
75-
child_ctr : Pid.FMap.t positive;
75+
ref_ctr : Ref.FMap.t positive;
7676
}.
7777

78-
#[export] Instance etaVM : Settable _ := settable! mkVM <world; runq; child_ctr>.
78+
#[export] Instance etaVM : Settable _ := settable! mkVM <world; runq; ref_ctr>.
7979

8080
Global Program Definition vm_setoid : Setoid VM :=
8181
{| equiv a b :=
@@ -92,19 +92,19 @@ Section VM.
9292
use:Permutation_sym,Permutation_trans.
9393
Qed.
9494

95-
Definition new_child_id (parent : PID) (v : VM) : VM * positive :=
96-
let cc := child_ctr v in
95+
Definition make_ref (parent : Ref) (v : VM) : VM * positive :=
96+
let cc := ref_ctr v in
9797
let (cc, ctr) :=
98-
match Pid.FMap.find parent cc with
98+
match Ref.FMap.find parent cc with
9999
| Some ctr =>
100-
(Pid.FMap.add parent (ctr + 1) cc, ctr)
100+
(Ref.FMap.add parent (ctr + 1) cc, ctr)
101101
| None =>
102-
(Pid.FMap.add parent 2 cc, 1)
102+
(Ref.FMap.add parent 2 cc, 1)
103103
end in
104-
(v<| child_ctr := cc |>, ctr).
104+
(v<| ref_ctr := cc |>, ctr).
105105

106-
Definition do_spawn {Mailbox : Set} (parent : PID) (prog : @Program Mailbox) (v : VM) : (PID * VM) :=
107-
let (v, child_pid_suffix) := new_child_id parent v in
106+
Definition do_spawn {Mailbox : Set} (parent : Ref) (prog : @Program Mailbox) (v : VM) : (Ref * VM) :=
107+
let (v, child_pid_suffix) := make_ref parent v in
108108
let rq := runq v in
109109
let new_pid := parent ++ [child_pid_suffix] in
110110
let new_process := {|
@@ -120,14 +120,14 @@ Section VM.
120120
{|
121121
world := w;
122122
runq := [];
123-
child_ctr := Pid.FMap.empty _;
123+
ref_ctr := Ref.FMap.empty _;
124124
|} in
125125
let (_, vm) := do_spawn [] p vm in
126126
vm.
127127

128128
Definition vmte_canon_rel (a b : Process) :=
129129
(* Order of events is canonical when pid a =< pid b: *)
130-
match PIDOrd.compare_ (pid a) (pid b) with
130+
match RefOrd.compare_ (pid a) (pid b) with
131131
| Gt => False
132132
| _ => True
133133
end.
@@ -141,7 +141,7 @@ Section VM.
141141
Lemma vmte_canon_rel_total a b : vmte_canon_rel a b \/ vmte_canon_rel b a.
142142
Proof.
143143
unfold Decidable.decidable, vmte_canon_rel.
144-
sauto use:PIDOrd.compare_asymm.
144+
sauto use:RefOrd.compare_asymm.
145145
Qed.
146146

147147
Global Instance vmevCanonOrder : CanonicalOrder vmte_canon_rel :=

0 commit comments

Comments
 (0)