Skip to content

Commit 6869078

Browse files
committed
Update for hp-revisited.
* Iris 4.3.0 * Bunch of improvements * Proof of lock-free, robust version of HP + Harris.
1 parent eba45f6 commit 6869078

113 files changed

Lines changed: 4471 additions & 3655 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository contains the proofs of the following paper, mechanized in Coq wi
88

99
## Build
1010
This version is known to compile with
11-
Coq 8.17.1 and
11+
Coq 8.19.0 and
1212
development versions of [Iris](https://gitlab.mpi-sws.org/iris/iris) and [Diaframe][]
1313
as specified in [smr-verification.opam](smr-verification.opam).
1414

@@ -20,7 +20,7 @@ opam switch create \
2020
--no-install \
2121
--repositories=default,coq-released=https://coq.inria.fr/opam/released,iris-dev=git+https://gitlab.mpi-sws.org/iris/opam.git \
2222
. ocaml-base-compiler.4.14.1
23-
opam pin add -n -y coq 8.17.1
23+
opam pin add -n -y coq 8.19.0
2424

2525
make builddep
2626
# hit "y" for all prompts, if any
@@ -34,7 +34,7 @@ Some proofs in theories/diaframe/examples may raise warning like this:
3434
Too many intro patterns were supplied!
3535
Dropping the following intro patterns: γ_h1 n1
3636
Too many IPM names were supplied!
37-
Please remove "Info_h1", "M_h1", "Nodes",
37+
Please remove "Info_h1", "M_h1", "Nodes",
3838
Subgoal 2 naming problems:
3939
Too little intro patterns were supplied! Please supply a name for:
4040
x0 : bool
@@ -67,7 +67,7 @@ and statistics will be saved in [`line_count.tsv`](line_count.tsv) (tab separate
6767
* [`spec_hazptr.v`](theories/hazptr/spec_hazptr.v): specifications of hazard pointers. (Fig. 5,10, and Appendix A).
6868

6969
| Paper | Coq |
70-
|---------------------------------|------------------------------|
70+
| ------------------------------- | ---------------------------- |
7171
| HPInv | `IsHazardDomainT` |
7272
| Managed | `ManagedT` |
7373
| HPSlot & Protected | `ShieldT` |

_CoqProject

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# Cannot use non-canonical projections as it causes massive unification failures
55
# (https://github.com/coq/coq/issues/6294).
66
-arg -w -arg -redundant-canonical-projection
7-
# Disabling warnings about future coercion syntax that requires Coq 8.17
8-
# (https://github.com/coq/coq/pull/16230)
9-
-arg -w -arg -future-coercion-class-field
107

118

129
# Modified version of heap_lang, with block memory model, tagging, and integers extended with infinity
@@ -110,6 +107,7 @@ theories/hazptr/code_rdcss.v
110107
theories/hazptr/code_cldeque.v
111108
theories/hazptr/code_harris_operations.v
112109
theories/hazptr/code_harris_michael_find.v
110+
theories/hazptr/code_harris_find.v
113111

114112
## Specs
115113
theories/hazptr/spec_hazptr.v
@@ -133,6 +131,7 @@ theories/hazptr/proof_rdcss.v
133131
theories/hazptr/proof_cldeque.v
134132
theories/hazptr/proof_harris_operations.v
135133
theories/hazptr/proof_harris_michael_find.v
134+
theories/hazptr/proof_harris_find.v
136135

137136
theories/hazptr/closed_proofs.v
138137
theories/hazptr/client.v
@@ -186,22 +185,22 @@ theories/ebr/client.v
186185

187186

188187
## Diaframe Basis
189-
theories/diaframe/lang/specs.v
190-
theories/diaframe/lang/proof_automation.v
191-
theories/diaframe/lang/base_hints.v
192-
theories/diaframe/lang/wp_auto_lob.v
193-
theories/diaframe/lang/atomic_specs.v
194-
theories/diaframe/lang/smr_weakestpre.v
195-
theories/diaframe/lang/smr_weakestpre_logatom.v
196-
theories/diaframe/lang/atom_spec_notation.v
188+
# theories/diaframe/lang/specs.v
189+
# theories/diaframe/lang/proof_automation.v
190+
# theories/diaframe/lang/base_hints.v
191+
# theories/diaframe/lang/wp_auto_lob.v
192+
# theories/diaframe/lang/atomic_specs.v
193+
# theories/diaframe/lang/smr_weakestpre.v
194+
# theories/diaframe/lang/smr_weakestpre_logatom.v
195+
# theories/diaframe/lang/atom_spec_notation.v
197196

198197
## Diaframe Hints
199-
theories/diaframe/hints/ghost_var_hints.v
200-
theories/diaframe/hints/array_hints.v
201-
theories/diaframe/hints/hazptr_hints.v
202-
theories/diaframe/hints/rcu_hints.v
198+
# theories/diaframe/hints/ghost_var_hints.v
199+
# theories/diaframe/hints/array_hints.v
200+
# theories/diaframe/hints/hazptr_hints.v
201+
# theories/diaframe/hints/rcu_hints.v
203202

204203
## Example: treiber stack on HP and RCU
205-
theories/diaframe/examples/proof_treiber_no_recl.v
206-
theories/diaframe/examples/proof_treiber_hazptr.v
207-
theories/diaframe/examples/proof_treiber_rcu.v
204+
# theories/diaframe/examples/proof_treiber_no_recl.v
205+
# theories/diaframe/examples/proof_treiber_hazptr.v
206+
# theories/diaframe/examples/proof_treiber_rcu.v

count_lines.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ def count_coqwc_lines(ds_file):
1717
res_proof = []
1818

1919
for recl in ["no_recl", "hazptr", "ebr"]:
20-
if ds_file["name"] == "Harris Set" and recl == "hazptr":
21-
res_code += [0]
22-
res_proof += [0]
23-
continue
24-
2520
code_count = 0
2621
for code in ds_file["code"]:
2722
lines = subprocess.check_output(
@@ -131,19 +126,12 @@ def count_coqwc_lines(ds_file):
131126
with open("line_count.tsv", "a") as f:
132127
f.write(ds_file["name"] + "\t" + "\t".join(res) + "\n")
133128

134-
(harris_code, harris_proof) = count_coqwc_lines(harris_files)
135129
total_code_str = list(map(format_com, total_code))
136130
total_proof_str = list(map(format_com, total_proof))
137131

138132
total_code_str[2] += str_ratio(2, total_code)
139133
total_proof_str[2] += str_ratio(2, total_proof)
140134

141-
total_code[0] -= harris_code[0]
142-
total_proof[0] -= harris_proof[0]
143-
144-
total_code_str[0] = f"{total_code[0]:,}" + " " + total_code_str[0]
145-
total_proof_str[0] = f"{total_proof[0]:,}" + " " + total_proof_str[0]
146-
147135
total_code_str[1] += str_ratio(1, total_code)
148136
total_proof_str[1] += str_ratio(1, total_proof)
149137

line_count.tsv

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Data Structure NR Code HP Code RCU Code NR Proof HP Proof RCU Proof
2-
Counter 23 30 (30.4%) 30 (30.4%) 140 175 (25.0%) 168 (20.0%)
3-
Treiber Stack 38 52 (36.8%) 51 (34.2%) 199 248 (24.6%) 233 (17.1%)
4-
Elimination Stack 54 71 (31.5%) 70 (29.6%) 297 404 (36.0%) 384 (29.3%)
5-
Michael-Scott Queue 55 76 (38.2%) 68 (23.6%) 464 620 (33.6%) 578 (24.6%)
6-
DGLM Queue 55 76 (38.2%) 68 (23.6%) 463 775 (67.4%) 731 (57.9%)
7-
Harris Set 113 0 (-100.0%) 144 (27.4%) 1,389 0 (-100.0%) 1,805 (29.9%)
8-
Harris-Michael Set 96 146 (52.1%) 119 (24.0%) 1,171 1,278 (9.1%) 1,473 (25.8%)
9-
Chase-Lev Deque 82 90 (9.8%) 89 (8.5%) 1,113 1,293 (16.2%) 1,284 (15.4%)
10-
RDCSS 52 75 (44.2%) 68 (30.8%) 400 530 (32.5%) 467 (16.8%)
11-
total 455 568 616 (35.4%) 707 (24.5%) 4,247 5,636 5,323 (25.3%) 7,123 (26.4%)
2+
Counter 23 30 (30.4%) 30 (30.4%) 138 175 (26.8%) 168 (21.7%)
3+
Treiber Stack 38 52 (36.8%) 51 (34.2%) 198 248 (25.3%) 233 (17.7%)
4+
Elimination Stack 54 71 (31.5%) 70 (29.6%) 283 399 (41.0%) 381 (34.6%)
5+
Michael-Scott Queue 55 72 (30.9%) 68 (23.6%) 463 604 (30.5%) 578 (24.8%)
6+
DGLM Queue 55 76 (38.2%) 68 (23.6%) 462 775 (67.7%) 731 (58.2%)
7+
Harris Set 106 206 (94.3%) 138 (30.2%) 1,339 1,927 (43.9%) 1,762 (31.6%)
8+
Harris-Michael Set 93 144 (54.8%) 116 (24.7%) 1,137 1,260 (10.8%) 1,452 (27.7%)
9+
Chase-Lev Deque 82 90 (9.8%) 89 (8.5%) 1,111 1,289 (16.0%) 1,279 (15.1%)
10+
RDCSS 52 75 (44.2%) 68 (30.8%) 398 528 (32.7%) 466 (17.1%)
11+
total 558 816 (46.2%) 698 (25.1%) 5,529 7,205 (30.3%) 7,050 (27.5%)

smr-verification.opam

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ bug-reports: "https://cp-git.kaist.ac.kr/verification/smr/issues"
1515
dev-repo: "git+https://cp-git.kaist.ac.kr/verification/smr.git"
1616

1717
depends: [
18-
"coq-iris" { = "dev.2023-06-14.0.f0e415b6" }
19-
"coq-diaframe" { = "dev.2023-06-15.0.1c3b5549" }
18+
"coq-iris" { = "4.3.0" }
2019
]
2120

2221
build: [make "-j%{jobs}%" ]

theories/algebra/gset.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Section gneset_disj.
197197
(* GNESetDisj X ~~>: Q. *)
198198
(* Proof. *)
199199
(* intros Hfresh HQ. *)
200-
(* apply cmra_discrete_updateP=> ? /gneset_disj_valid_inv_l [Y [->?]]. *)
200+
(* apply cmra_discrete_total_updateP=> ? /gneset_disj_valid_inv_l [Y [->?]]. *)
201201
(* destruct (Hfresh (X ∪ Y)) as (i&?&?); first set_solver. *)
202202
(* exists (GNESetDisj ({[ i ]} ∪ X)); split. *)
203203
(* - apply HQ; set_solver by eauto. *)

theories/base_logic/lib/coP_cancellable_invariants.v

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ From iris.base_logic.lib Require Export invariants.
44
From iris.prelude Require Import options.
55
Import uPred.
66

7-
Class coP_cinvG Σ := coP_cinv_inG :> inG Σ coPneset_disjR.
7+
Class coP_cinvG Σ := { #[local] coP_cinv_inG :: inG Σ coPneset_disjR }.
8+
89
Definition coP_cinvΣ : gFunctors := #[GFunctor coPneset_disjR].
910

1011
Global Instance subG_coP_cinvΣ {Σ} : subG coP_cinvΣ Σ → coP_cinvG Σ.
1112
Proof. solve_inG. Qed.
1213

1314
Section defs.
14-
Context `{!invGS Σ, !coP_cinvG Σ}.
15+
Context `{!invGS_gen hlc Σ, !coP_cinvG Σ}.
1516

1617
Definition coP_cinv_own (γ : gname) (t : coPneset) : iProp Σ :=
1718
own γ (CoPNESetDisj t).
@@ -23,7 +24,7 @@ End defs.
2324
Global Instance: Params (@coP_cinv) 5 := {}.
2425

2526
Section proofs.
26-
Context `{!invGS Σ, !coP_cinvG Σ}.
27+
Context `{!invGS_gen hlc Σ, !coP_cinvG Σ}.
2728

2829
Global Instance coP_cinv_own_timeless γ p : Timeless (coP_cinv_own γ p).
2930
Proof. rewrite /coP_cinv_own; apply _. Qed.

theories/base_logic/lib/coP_ghost_map.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ From iris.prelude Require Import options.
88
(** like ghost_map, but using coP_gmap_view instead of gmap_view *)
99

1010
Class coP_ghost_mapG Σ (K V : Type) `{Countable K} := CoPGhostMapG {
11-
coP_ghost_map_inG :> inG Σ (coP_gmap_viewR K (leibnizO V));
11+
#[local] coP_ghost_map_inG :: inG Σ (coP_gmap_viewR K (leibnizO V));
1212
}.
13+
1314
Definition coP_ghost_mapΣ (K V : Type) `{Countable K} : gFunctors :=
1415
#[ GFunctor (coP_gmap_viewR K (leibnizO V)) ].
1516

Lines changed: 22 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,11 @@
11
(* Modified version supporting persistent ghost vars. *)
22

3-
(** A simple "ghost variable" of arbitrary type with fractional ownership.
4-
Can be mutated when fully owned. *)
5-
From iris.algebra Require Import dfrac dfrac_agree.
6-
From iris.bi.lib Require Import fractional.
3+
From iris.algebra Require Import dfrac_agree.
74
From iris.proofmode Require Import proofmode.
8-
From iris.base_logic.lib Require Export own.
5+
From iris.base_logic.lib Require Export own ghost_var.
96
From iris.prelude Require Import options.
107

11-
(** The CMRA we need. *)
12-
Class ghost_varG Σ (A : Type) := GhostVarG {
13-
ghost_var_inG : inG Σ (dfrac_agreeR $ leibnizO A);
14-
}.
158
Local Existing Instance ghost_var_inG.
16-
Global Hint Mode ghost_varG - ! : typeclass_instances.
17-
18-
Definition ghost_varΣ (A : Type) : gFunctors :=
19-
#[ GFunctor (dfrac_agreeR $ leibnizO A) ].
20-
21-
Global Instance subG_ghost_varΣ Σ A : subG (ghost_varΣ A) Σ → ghost_varG Σ A.
22-
Proof. solve_inG. Qed.
23-
24-
Local Definition ghost_var_def `{!ghost_varG Σ A}
25-
(γ : gname) (q : Qp) (a : A) : iProp Σ :=
26-
own γ (to_frac_agree (A:=leibnizO A) q a).
27-
Local Definition ghost_var_aux : seal (@ghost_var_def). Proof. by eexists. Qed.
28-
Definition ghost_var := ghost_var_aux.(unseal).
29-
Local Definition ghost_var_unseal :
30-
@ghost_var = @ghost_var_def := ghost_var_aux.(seal_eq).
31-
Global Arguments ghost_var {Σ A _} γ q a.
329

3310
Local Definition persistent_ghost_var_def `{!ghost_varG Σ A}
3411
(γ : gname) (a : A) : iProp Σ :=
@@ -39,88 +16,46 @@ Local Definition persistent_ghost_var_unseal :
3916
@persistent_ghost_var = @persistent_ghost_var_def := persistent_ghost_var_aux.(seal_eq).
4017
Global Arguments persistent_ghost_var {Σ A _} γ a.
4118

42-
Local Ltac unseal := rewrite ?ghost_var_unseal /ghost_var_def ?persistent_ghost_var_unseal /persistent_ghost_var_def.
19+
Local Ltac unseal := rewrite
20+
?ghost_var.ghost_var_unseal /ghost_var.ghost_var_def
21+
?persistent_ghost_var_unseal /persistent_ghost_var_def.
4322

4423
Section lemmas.
4524
Context `{!ghost_varG Σ A}.
4625
Implicit Types (a b : A) (q : Qp).
4726

48-
Global Instance ghost_var_timeless γ q a : Timeless (ghost_var γ q a).
49-
Proof. unseal. apply _. Qed.
50-
51-
Global Instance ghost_var_fractional γ a : Fractional (λ q, ghost_var γ q a).
52-
Proof. intros q1 q2. unseal. rewrite -own_op -frac_agree_op //. Qed.
53-
Global Instance ghost_var_as_fractional γ a q :
54-
AsFractional (ghost_var γ q a) (λ q, ghost_var γ q a) q.
55-
Proof. split; [done|]. apply _. Qed.
56-
5727
Global Instance persistent_ghost_var_timeless γ a : Timeless (persistent_ghost_var γ a).
5828
Proof. unseal. apply _. Qed.
5929
Global Instance persistent_ghost_var_persistent γ a : Persistent (persistent_ghost_var γ a).
6030
Proof. unseal. apply _. Qed.
6131

62-
Lemma ghost_var_alloc_strong a (P : gname → Prop) :
63-
pred_infinite P →
64-
⊢ |==> ∃ γ, ⌜P γ⌝ ∗ ghost_var γ 1 a.
65-
Proof. unseal. intros. iApply own_alloc_strong; done. Qed.
66-
Lemma ghost_var_alloc a :
67-
⊢ |==> ∃ γ, ghost_var γ 1 a.
68-
Proof. unseal. iApply own_alloc. done. Qed.
32+
(** Persistent ghost var rules *)
33+
Lemma ghost_var_persist γ q a :
34+
ghost_var γ q a ==∗ persistent_ghost_var γ a.
35+
Proof. unseal. iApply own_update. apply dfrac_agree_persist. Qed.
6936

70-
Lemma ghost_var_valid_2 γ a1 q1 a2 q2 :
71-
ghost_var γ q1 a1 -∗ ghost_var γ q2 a2 -∗ ⌜(q1 + q2 1)%Qp ∧ a1 = a2⌝.
37+
Lemma persistent_ghost_var_valid_2 γ a1 a2 q2 :
38+
persistent_ghost_var γ a1 -∗ ghost_var γ q2 a2 -∗ ⌜(q2 < 1)%Qp ∧ a1 = a2⌝.
7239
Proof.
7340
unseal. iIntros "Hvar1 Hvar2".
74-
by iCombine "Hvar1 Hvar2" gives %?%frac_agree_op_valid.
41+
iCombine "Hvar1 Hvar2" gives %[Hq Ha]%dfrac_agree_op_valid_L.
42+
done.
7543
Qed.
7644
(** Almost all the time, this is all you really need. *)
77-
Lemma ghost_var_agree γ a1 q1 a2 q2 :
78-
ghost_var γ q1 a1 -∗ ghost_var γ q2 a2 -∗ ⌜a1 = a2⌝.
45+
Lemma persistent_ghost_var_agree γ a1 a2 q2 :
46+
persistent_ghost_var γ a1 -∗ ghost_var γ q2 a2 -∗ ⌜a1 = a2⌝.
7947
Proof.
8048
iIntros "Hvar1 Hvar2".
81-
iDestruct (ghost_var_valid_2 with "Hvar1 Hvar2") as %[_ ?]. done.
49+
iDestruct (persistent_ghost_var_valid_2 with "Hvar1 Hvar2") as %[_ ?]. done.
8250
Qed.
8351

84-
(** This is just an instance of fractionality above, but that can be hard to find. *)
85-
Lemma ghost_var_split γ a q1 q2 :
86-
ghost_var γ (q1 + q2) a -∗ ghost_var γ q1 a ∗ ghost_var γ q2 a.
87-
Proof. iIntros "[$$]". Qed.
88-
89-
(** Update the ghost variable to new value [b]. *)
90-
Lemma ghost_var_update b γ a :
91-
ghost_var γ 1 a ==∗ ghost_var γ 1 b.
52+
Global Instance ghost_var_combine_gives γ a1 a2 q2 :
53+
CombineSepGives (persistent_ghost_var γ a1) (ghost_var γ q2 a2)
54+
⌜(q2 < 1)%Qp ∧ a1 = a2⌝.
9255
Proof.
93-
unseal. iApply own_update. apply cmra_update_exclusive. done.
56+
rewrite /CombineSepGives. iIntros "[H1 H2]".
57+
iDestruct (persistent_ghost_var_valid_2 with "H1 H2") as %[H1 H2].
58+
eauto.
9459
Qed.
95-
Lemma ghost_var_update_2 b γ a1 q1 a2 q2 :
96-
(q1 + q2 = 1)%Qp →
97-
ghost_var γ q1 a1 -∗ ghost_var γ q2 a2 ==∗ ghost_var γ q1 b ∗ ghost_var γ q2 b.
98-
Proof.
99-
intros Hq. unseal. rewrite -own_op. iApply own_update_2.
100-
apply frac_agree_update_2. done.
101-
Qed.
102-
Lemma ghost_var_update_halves b γ a1 a2 :
103-
ghost_var γ (1/2) a1 -∗
104-
ghost_var γ (1/2) a2 ==∗
105-
ghost_var γ (1/2) b ∗ ghost_var γ (1/2) b.
106-
Proof. iApply ghost_var_update_2. apply Qp.half_half. Qed.
107-
108-
(** Framing support *)
109-
Global Instance frame_ghost_var p γ a q1 q2 q :
110-
FrameFractionalQp q1 q2 q →
111-
Frame p (ghost_var γ q1 a) (ghost_var γ q2 a) (ghost_var γ q a) | 5.
112-
Proof. apply: frame_fractional. Qed.
113-
114-
(** Persistent ghost var rules *)
115-
Lemma ghost_var_persist γ q a :
116-
ghost_var γ q a ==∗ persistent_ghost_var γ a.
117-
Proof. unseal. iApply own_update. apply dfrac_agree_persist. Qed.
11860

119-
Lemma persistent_ghost_var_agree γ a1 a2 q2 :
120-
persistent_ghost_var γ a1 -∗ ghost_var γ q2 a2 -∗ ⌜a1 = a2⌝.
121-
Proof.
122-
unseal. iIntros "Hvar1 Hvar2".
123-
by iCombine "Hvar1 Hvar2" gives %[? ?]%dfrac_agree_op_valid_L.
124-
Qed.
12561
End lemmas.
126-

0 commit comments

Comments
 (0)