Skip to content
Snippets Groups Projects
Commit bd80b71c authored by Ralf Jung's avatar Ralf Jung
Browse files

experiment: use coq's ability to infer more canonical structures

parent 92e6f4d4
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,8 @@ Global Arguments GFunctor _ {_}. ...@@ -32,6 +32,8 @@ Global Arguments GFunctor _ {_}.
Global Existing Instance gFunctor_map_contractive. Global Existing Instance gFunctor_map_contractive.
Add Printing Constructor gFunctor. Add Printing Constructor gFunctor.
Notation GFunctorConst F := (GFunctor (constRF F)).
(** The type [gFunctors] describes the parameters [Σ] of the Iris logic: lists (** The type [gFunctors] describes the parameters [Σ] of the Iris logic: lists
of [gFunctor]s. of [gFunctor]s.
......
...@@ -33,10 +33,10 @@ Local Definition acquire_writer : val := ...@@ -33,10 +33,10 @@ Local Definition acquire_writer : val :=
Local Definition release_writer : val := Local Definition release_writer : val :=
λ: "l", "l" <- #0. λ: "l", "l" <- #0.
Class rwlockG Σ := RwLockG { rwlock_tokG : inG Σ (authR (gmultisetUR Qp)) }. Class rwlockG Σ := RwLockG { rwlock_tokG : inG Σ (auth (gmultiset Qp)) }.
Local Existing Instance rwlock_tokG. Local Existing Instance rwlock_tokG.
Local Definition rwlockΣ : gFunctors := #[GFunctor (authR (gmultisetUR Qp)) ]. Local Definition rwlockΣ : gFunctors := #[GFunctorConst (auth (gmultiset Qp)) ].
Global Instance subG_rwlockΣ {Σ} : subG rwlockΣ Σ rwlockG Σ. Global Instance subG_rwlockΣ {Σ} : subG rwlockΣ Σ rwlockG Σ.
Proof. solve_inG. Qed. Proof. solve_inG. Qed.
......
...@@ -19,10 +19,10 @@ Definition join : val := ...@@ -19,10 +19,10 @@ Definition join : val :=
(** The CMRA & functor we need. *) (** The CMRA & functor we need. *)
(* Not bundling heapGS, as it may be shared with other users. *) (* Not bundling heapGS, as it may be shared with other users. *)
Class spawnG Σ := SpawnG { spawn_tokG : inG Σ (exclR unitO) }. Class spawnG Σ := SpawnG { spawn_tokG : inG Σ (excl ()) }.
Local Existing Instance spawn_tokG. Local Existing Instance spawn_tokG.
Definition spawnΣ : gFunctors := #[GFunctor (exclR unitO)]. Definition spawnΣ : gFunctors := #[GFunctorConst (excl ())].
Global Instance subG_spawnΣ {Σ} : subG spawnΣ Σ spawnG Σ. Global Instance subG_spawnΣ {Σ} : subG spawnΣ Σ spawnG Σ.
Proof. solve_inG. Qed. Proof. solve_inG. Qed.
......
...@@ -14,10 +14,10 @@ Definition release : val := λ: "l", "l" <- #false. ...@@ -14,10 +14,10 @@ Definition release : val := λ: "l", "l" <- #false.
(** The CMRA we need. *) (** The CMRA we need. *)
(* Not bundling heapGS, as it may be shared with other users. *) (* Not bundling heapGS, as it may be shared with other users. *)
Class lockG Σ := LockG { lock_tokG : inG Σ (exclR unitO) }. Class lockG Σ := LockG { lock_tokG : inG Σ (excl ()) }.
Local Existing Instance lock_tokG. Local Existing Instance lock_tokG.
Definition lockΣ : gFunctors := #[GFunctor (exclR unitO)]. Definition lockΣ : gFunctors := #[GFunctorConst (excl ())].
Global Instance subG_lockΣ {Σ} : subG lockΣ Σ lockG Σ. Global Instance subG_lockΣ {Σ} : subG lockΣ Σ lockG Σ.
Proof. solve_inG. Qed. Proof. solve_inG. Qed.
......
...@@ -28,11 +28,11 @@ Definition release : val := ...@@ -28,11 +28,11 @@ Definition release : val :=
(** The CMRAs we need. *) (** The CMRAs we need. *)
Class tlockG Σ := Class tlockG Σ :=
tlock_G : inG Σ (authR (prodUR (optionUR (exclR natO)) (gset_disjUR nat))). tlock_G : inG Σ (auth (excl' nat * gset_disj nat)).
Local Existing Instance tlock_G. Local Existing Instance tlock_G.
Definition tlockΣ : gFunctors := Definition tlockΣ : gFunctors :=
#[ GFunctor (authR (prodUR (optionUR (exclR natO)) (gset_disjUR nat))) ]. #[ GFunctorConst (auth (excl' nat * gset_disj nat)) ].
Global Instance subG_tlockΣ {Σ} : subG tlockΣ Σ tlockG Σ. Global Instance subG_tlockΣ {Σ} : subG tlockΣ Σ tlockG Σ.
Proof. solve_inG. Qed. Proof. solve_inG. Qed.
...@@ -45,14 +45,14 @@ Section proof. ...@@ -45,14 +45,14 @@ Section proof.
o n : nat, o n : nat,
lo #o ln #n lo #o ln #n
own γ ( (Excl' o, GSet (set_seq 0 n))) own γ ( (Excl' o, GSet (set_seq 0 n)))
((own γ ( (Excl' o, GSet )) R) own γ ( (ε, GSet {[ o ]}))). ((own γ ( (Excl' o, GSet )) R) own γ ( (ε : excl' _, GSet {[ o ]}))).
Definition is_lock (γ : gname) (lk : val) (R : iProp Σ) : iProp Σ := Definition is_lock (γ : gname) (lk : val) (R : iProp Σ) : iProp Σ :=
lo ln : loc, lo ln : loc,
lk = (#lo, #ln)%V inv N (lock_inv γ lo ln R). lk = (#lo, #ln)%V inv N (lock_inv γ lo ln R).
Definition issued (γ : gname) (x : nat) : iProp Σ := Definition issued (γ : gname) (x : nat) : iProp Σ :=
own γ ( (ε, GSet {[ x ]})). own γ ( (ε : excl' _, GSet {[ x ]})).
Definition locked (γ : gname) : iProp Σ := o, own γ ( (Excl' o, GSet )). Definition locked (γ : gname) : iProp Σ := o, own γ ( (Excl' o, GSet )).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment