Skip to content

Commit 01ba394

Browse files
committed
Handle WPs for primitives better
Make proofs more natural for Fork and ArbitraryInt wp_apply didn't recognize `Fork` and `ArbitraryInt`, and they also didn't have specs using new goose's to_val.
1 parent 9a69106 commit 01ba394

File tree

9 files changed

+52
-42
lines changed

9 files changed

+52
-42
lines changed

new/golang/theory.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From Perennial.goose_lang Require Export lang.
22
From New.golang Require Export defn.
33
From New.golang.theory Require Export exception list typing loop struct
4-
mem slice map interface defer typing builtin chan pkg auto globals.
4+
mem slice map interface defer typing builtin primitive chan pkg auto globals.
55

66
Export uPred. (* XXX: inherited from proof_prelude.v; not sure why it's here. *)
77
Global Set Default Proof Using "Type".

new/golang/theory/primitive.v

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From New Require Export notation.
2+
From New.golang.theory Require Export typing proofmode.
3+
From Perennial Require Import base.
4+
5+
Set Default Proof Using "Type".
6+
7+
Section wps.
8+
9+
Context `{sem: ffi_semantics} `{!ffi_interp ffi} `{!heapGS Σ}.
10+
11+
(* use new goose's to_val for the return value *)
12+
Lemma wp_fork s E e Φ :
13+
▷ WP e @ s; ⊤ {{ _, True }} -∗ ▷ Φ #() -∗ WP Fork e @ s; E {{ Φ }}.
14+
Proof.
15+
iIntros "Hwp HΦ".
16+
wp_apply (lifting.wp_fork with "[$Hwp]").
17+
replace (LitV LitUnit) with #().
18+
{ iFrame "HΦ". }
19+
rewrite to_val_unseal //.
20+
Qed.
21+
22+
(* use new goose's to_val for the return value *)
23+
Lemma wp_ArbitraryInt s E Φ :
24+
▷ (∀ (x: w64), Φ #x) -∗ WP ArbitraryInt @ s; E {{ Φ }}.
25+
Proof.
26+
iIntros "HΦ".
27+
wp_apply (lifting.wp_ArbitraryInt).
28+
iIntros (x) "_".
29+
replace (LitV x) with #x.
30+
{ iApply "HΦ". }
31+
rewrite to_val_unseal //.
32+
Qed.
33+
34+
End wps.

new/golang/theory/proofmode.v

+2
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ Ltac2 wp_bind_apply () : unit :=
524524
lazy_match! e with
525525
| App (Val _) (Val _) => ()
526526
| App ?e1 (Val _) => f e1
527+
| Fork _ => ()
528+
| ArbitraryInt => ()
527529
| _ => fail
528530
end
529531
in f e

new/golang/theory/slice.v

+5-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ From Perennial.Helpers Require Import List ListLen Fractional NamedProps.
22
From iris.algebra Require Import dfrac.
33
From Perennial.goose_lang Require Import ipersist.
44
From New.golang.defn Require Export slice.
5-
From New.golang.theory Require Export list mem exception loop typing auto.
5+
From New.golang.theory Require Export list mem exception loop typing primitive auto.
66
From Perennial Require Import base.
77

88
Set Default Proof Using "Type".
@@ -266,11 +266,8 @@ Proof.
266266
[apply bool_decide_eq_true_1 in Hlt2|apply bool_decide_eq_false_1 in Hlt2];
267267
wp_pures.
268268
{
269-
wp_bind ArbitraryInt.
270-
iApply (wp_ArbitraryInt with "[//]"). iNext.
271-
iIntros (?) "_".
272-
replace (LitV x) with (#x).
273-
2:{ rewrite to_val_unseal //. }
269+
wp_apply (wp_ArbitraryInt).
270+
iIntros (?).
274271
wp_pures.
275272
rewrite slice_val_fold.
276273
iApply "HΦ".
@@ -604,12 +601,8 @@ Proof.
604601
destruct (bool_decide_reflect P); wp_auto
605602
end.
606603
- admit. (* TODO: slice.slice reasoning, going into capacity *)
607-
- wp_bind (ArbitraryInt).
608-
iApply (wp_ArbitraryInt with "[//]").
609-
iIntros "!>" (x) "_". wp_auto.
610-
replace (LitV x) with (#x).
611-
2:{ rewrite to_val_unseal //. }
612-
wp_auto.
604+
- wp_apply (wp_ArbitraryInt).
605+
iIntros (x). wp_auto.
613606
wp_apply wp_slice_make2. iIntros (s') "[Hs_new Hnew_cap]".
614607
wp_auto.
615608
admit. (* TODO: need wp for slice.copy *)

new/proof/asyncfile.v

+1-4
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,12 @@ Proof.
652652
iNext. by iFrame "∗#".
653653
}
654654

655-
wp_bind (Fork _)%E.
656-
iApply (wp_fork with "[HpreIdx HpreData HdurIdx Hfile]").
655+
wp_apply (wp_fork with "[HpreIdx HpreData HdurIdx Hfile]").
657656
{
658-
iNext.
659657
wp_apply (wp_AsyncFile__flushThread with "[-]").
660658
{ iFrame "∗#". }
661659
done.
662660
}
663-
iNext. wp_auto.
664661
iApply "HΦ".
665662
iFrame "∗#".
666663
Qed.

new/proof/go_etcd_io/etcd/client/v3/concurrency.v

+1-5
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,9 @@ Proof.
107107
unshelve wp_apply wp_chan_make as "* Hdonec"; try tc_solve.
108108
wp_alloc s as "Hs".
109109
wp_auto.
110-
wp_bind (Fork _).
111110
iPersist "cancel donec keepAlive".
112-
iApply (wp_fork with "[Hdonec Hcancel]").
111+
wp_apply (wp_fork with "[Hdonec Hcancel]").
113112
{
114-
iNext.
115-
wp_auto.
116113
wp_apply wp_with_defer as "%defer defer".
117114
simpl subst.
118115
wp_auto.
@@ -152,7 +149,6 @@ Proof.
152149
iFrame.
153150
}
154151
}
155-
iNext.
156152
iDestruct (struct_fields_split with "Hs") as "hs".
157153
simpl. iClear "Hctx". iNamed "hs".
158154
iPersist "Hclient Hid".

new/proof/go_etcd_io/etcd/client/v3/leasing.v

+2-9
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,19 @@ Proof.
165165
replace (Z.to_nat (sint.Z (W32 2))) with (2%nat) by done.
166166
iEval (simpl) in "H".
167167
iDestruct "H" as "[Hwg_done1 Hwg_done2]".
168-
wp_bind (Fork _).
169-
iApply (wp_fork with "[Hwg_done1 session_monitor]").
168+
wp_apply (wp_fork with "[Hwg_done1 session_monitor]").
170169
{
171-
iNext. wp_auto.
172170
wp_apply wp_with_defer as "%defer defer".
173171
simpl subst.
174172
wp_auto.
175173
(* TODO: wp_monitorSession. *)
176174
admit.
177175
}
178-
iNext. wp_auto.
179-
wp_bind (Fork _).
180-
iApply (wp_fork with "[Hwg_done2]").
176+
wp_apply (wp_fork with "[Hwg_done2]").
181177
{
182-
iNext. wp_auto.
183178
(* TODO: wp_clearOldRevokes. *)
184179
admit.
185180
}
186-
iNext.
187-
wp_auto.
188181
(* TODO: wp_waitSession. *)
189182
admit.
190183
Admitted.

new/proof/std.v

+3-7
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,15 @@ Proof.
146146
wp_auto.
147147
wp_apply (wp_newJoinHandle P) as "%l #Hhandle".
148148
iPersist "f h".
149-
wp_bind (Fork _).
150-
iApply (wp_fork with "[Hwp]").
151-
- iModIntro. wp_auto.
152-
(* NOTE: it's important not to do a pure reduction here since it would
149+
wp_apply (wp_fork with "[Hwp]").
150+
- (* NOTE: it's important not to do a pure reduction here since it would
153151
produce a substitution into the lambda *)
154152
wp_apply "Hwp".
155153
iIntros "HP".
156154
wp_auto.
157155
wp_apply (wp_JoinHandle__finish with "[$Hhandle $HP]").
158156
done.
159-
- iModIntro.
160-
wp_auto.
161-
iApply "HΦ".
157+
- iApply "HΦ".
162158
iFrame "#".
163159
Qed.
164160

src/program_proof/grove_shared/urpc_proof.v

+3-4
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,11 @@ Proof.
664664
}
665665
iMod (inv_alloc urpc_clientN _ (reply_chan_inner Γ client) with "[Hr]") as "#Hchan_inv".
666666
{ iNext. iExists ∅. iFrame. rewrite big_sepS_empty //. }
667-
wp_bind (Fork _).
668-
iApply wp_fork.
669-
{ iNext. wp_pures. iApply wp_Client__replyThread. repeat iExists _.
667+
wp_apply wp_fork.
668+
{ iApply wp_Client__replyThread. repeat iExists _.
670669
iSplit. 1:iFrame "mu conn pending".
671670
iSplit; done. }
672-
iNext. wp_pures. iModIntro. iApply "HΦ".
671+
wp_pures. iModIntro. iApply "HΦ".
673672
iExists _, _, _, _. iSplit; first by iFrame "#". iSplit; done.
674673
Qed.
675674

0 commit comments

Comments
 (0)