Commit c7390af8 authored by Ralf Jung's avatar Ralf Jung

new (hopefully final) notation for wp: the keyword WP

parent 462cc285
...@@ -16,7 +16,7 @@ Section client. ...@@ -16,7 +16,7 @@ Section client.
Local Notation iProp := (iPropG heap_lang Σ). Local Notation iProp := (iPropG heap_lang Σ).
Definition y_inv q y : iProp := Definition y_inv q y : iProp :=
( f : val, y {q} f n : Z, #> f §n {{ λ v, v = §(n + 42) }})%I. ( f : val, y {q} f n : Z, WP f §n {{ λ v, v = §(n + 42) }})%I.
Lemma y_inv_split q y : Lemma y_inv_split q y :
y_inv q y (y_inv (q/2) y y_inv (q/2) y). y_inv q y (y_inv (q/2) y y_inv (q/2) y).
...@@ -28,7 +28,7 @@ Section client. ...@@ -28,7 +28,7 @@ Section client.
Lemma worker_safe q (n : Z) (b y : loc) : Lemma worker_safe q (n : Z) (b y : loc) :
(heap_ctx heapN recv heapN N b (y_inv q y)) (heap_ctx heapN recv heapN N b (y_inv q y))
#> worker n (%b) (%y) {{ λ _, True }}. WP worker n (%b) (%y) {{ λ _, True }}.
Proof. Proof.
rewrite /worker. wp_lam. wp_let. ewp apply wait_spec. rewrite /worker. wp_lam. wp_let. ewp apply wait_spec.
rewrite comm. apply sep_mono_r. apply wand_intro_l. rewrite comm. apply sep_mono_r. apply wand_intro_l.
...@@ -42,7 +42,7 @@ Section client. ...@@ -42,7 +42,7 @@ Section client.
Qed. Qed.
Lemma client_safe : Lemma client_safe :
heapN N heap_ctx heapN #> client {{ λ _, True }}. heapN N heap_ctx heapN WP client {{ λ _, True }}.
Proof. Proof.
intros ?. rewrite /client. intros ?. rewrite /client.
(ewp eapply wp_alloc); eauto with I. strip_later. apply forall_intro=>y. (ewp eapply wp_alloc); eauto with I. strip_later. apply forall_intro=>y.
......
...@@ -112,7 +112,7 @@ Qed. ...@@ -112,7 +112,7 @@ Qed.
Lemma newbarrier_spec (P : iProp) (Φ : val iProp) : Lemma newbarrier_spec (P : iProp) (Φ : val iProp) :
heapN N heapN N
(heap_ctx heapN l, recv l P send l P - Φ (%l)) (heap_ctx heapN l, recv l P send l P - Φ (%l))
#> newbarrier §() {{ Φ }}. WP newbarrier §() {{ Φ }}.
Proof. Proof.
intros HN. rewrite /newbarrier. wp_seq. intros HN. rewrite /newbarrier. wp_seq.
rewrite -wp_pvs. wp eapply wp_alloc; eauto with I ndisj. rewrite -wp_pvs. wp eapply wp_alloc; eauto with I ndisj.
...@@ -151,7 +151,7 @@ Proof. ...@@ -151,7 +151,7 @@ Proof.
Qed. Qed.
Lemma signal_spec l P (Φ : val iProp) : Lemma signal_spec l P (Φ : val iProp) :
(send l P P Φ §()) #> signal (%l) {{ Φ }}. (send l P P Φ §()) WP signal (%l) {{ Φ }}.
Proof. Proof.
rewrite /signal /send /barrier_ctx. rewrite sep_exist_r. rewrite /signal /send /barrier_ctx. rewrite sep_exist_r.
apply exist_elim=>γ. rewrite -!assoc. apply const_elim_sep_l=>?. wp_let. apply exist_elim=>γ. rewrite -!assoc. apply const_elim_sep_l=>?. wp_let.
...@@ -176,7 +176,7 @@ Proof. ...@@ -176,7 +176,7 @@ Proof.
Qed. Qed.
Lemma wait_spec l P (Φ : val iProp) : Lemma wait_spec l P (Φ : val iProp) :
(recv l P (P - Φ §())) #> wait (%l) {{ Φ }}. (recv l P (P - Φ §())) WP wait (%l) {{ Φ }}.
Proof. Proof.
rename P into R. wp_rec. rename P into R. wp_rec.
rewrite {1}/recv /barrier_ctx. rewrite !sep_exist_r. rewrite {1}/recv /barrier_ctx. rewrite !sep_exist_r.
......
...@@ -19,36 +19,36 @@ Implicit Types Φ : val → iProp heap_lang Σ. ...@@ -19,36 +19,36 @@ Implicit Types Φ : val → iProp heap_lang Σ.
(** Proof rules for the sugar *) (** Proof rules for the sugar *)
Lemma wp_lam E x ef e v Φ : Lemma wp_lam E x ef e v Φ :
to_val e = Some v to_val e = Some v
#> subst' x e ef @ E {{ Φ }} #> App (Lam x ef) e @ E {{ Φ }}. WP subst' x e ef @ E {{ Φ }} WP App (Lam x ef) e @ E {{ Φ }}.
Proof. intros. by rewrite -wp_rec. Qed. Proof. intros. by rewrite -wp_rec. Qed.
Lemma wp_let E x e1 e2 v Φ : Lemma wp_let E x e1 e2 v Φ :
to_val e1 = Some v to_val e1 = Some v
#> subst' x e1 e2 @ E {{ Φ }} #> Let x e1 e2 @ E {{ Φ }}. WP subst' x e1 e2 @ E {{ Φ }} WP Let x e1 e2 @ E {{ Φ }}.
Proof. apply wp_lam. Qed. Proof. apply wp_lam. Qed.
Lemma wp_seq E e1 e2 v Φ : Lemma wp_seq E e1 e2 v Φ :
to_val e1 = Some v to_val e1 = Some v
#> e2 @ E {{ Φ }} #> Seq e1 e2 @ E {{ Φ }}. WP e2 @ E {{ Φ }} WP Seq e1 e2 @ E {{ Φ }}.
Proof. intros ?. by rewrite -wp_let. Qed. Proof. intros ?. by rewrite -wp_let. Qed.
Lemma wp_skip E Φ : Φ (LitV LitUnit) #> Skip @ E {{ Φ }}. Lemma wp_skip E Φ : Φ (LitV LitUnit) WP Skip @ E {{ Φ }}.
Proof. rewrite -wp_seq // -wp_value //. Qed. Proof. rewrite -wp_seq // -wp_value //. Qed.
Lemma wp_match_inl E e0 v0 x1 e1 x2 e2 Φ : Lemma wp_match_inl E e0 v0 x1 e1 x2 e2 Φ :
to_val e0 = Some v0 to_val e0 = Some v0
#> subst' x1 e0 e1 @ E {{ Φ }} #> Match (InjL e0) x1 e1 x2 e2 @ E {{ Φ }}. WP subst' x1 e0 e1 @ E {{ Φ }} WP Match (InjL e0) x1 e1 x2 e2 @ E {{ Φ }}.
Proof. intros. by rewrite -wp_case_inl // -[X in _ X]later_intro -wp_let. Qed. Proof. intros. by rewrite -wp_case_inl // -[X in _ X]later_intro -wp_let. Qed.
Lemma wp_match_inr E e0 v0 x1 e1 x2 e2 Φ : Lemma wp_match_inr E e0 v0 x1 e1 x2 e2 Φ :
to_val e0 = Some v0 to_val e0 = Some v0
#> subst' x2 e0 e2 @ E {{ Φ }} #> Match (InjR e0) x1 e1 x2 e2 @ E {{ Φ }}. WP subst' x2 e0 e2 @ E {{ Φ }} WP Match (InjR e0) x1 e1 x2 e2 @ E {{ Φ }}.
Proof. intros. by rewrite -wp_case_inr // -[X in _ X]later_intro -wp_let. Qed. Proof. intros. by rewrite -wp_case_inr // -[X in _ X]later_intro -wp_let. Qed.
Lemma wp_le E (n1 n2 : Z) P Φ : Lemma wp_le E (n1 n2 : Z) P Φ :
(n1 n2 P Φ (LitV (LitBool true))) (n1 n2 P Φ (LitV (LitBool true)))
(n2 < n1 P Φ (LitV (LitBool false))) (n2 < n1 P Φ (LitV (LitBool false)))
P #> BinOp LeOp (Lit (LitInt n1)) (Lit (LitInt n2)) @ E {{ Φ }}. P WP BinOp LeOp (Lit (LitInt n1)) (Lit (LitInt n2)) @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -wp_bin_op //; []. intros. rewrite -wp_bin_op //; [].
destruct (bool_decide_reflect (n1 n2)); by eauto with omega. destruct (bool_decide_reflect (n1 n2)); by eauto with omega.
...@@ -57,7 +57,7 @@ Qed. ...@@ -57,7 +57,7 @@ Qed.
Lemma wp_lt E (n1 n2 : Z) P Φ : Lemma wp_lt E (n1 n2 : Z) P Φ :
(n1 < n2 P Φ (LitV (LitBool true))) (n1 < n2 P Φ (LitV (LitBool true)))
(n2 n1 P Φ (LitV (LitBool false))) (n2 n1 P Φ (LitV (LitBool false)))
P #> BinOp LtOp (Lit (LitInt n1)) (Lit (LitInt n2)) @ E {{ Φ }}. P WP BinOp LtOp (Lit (LitInt n1)) (Lit (LitInt n2)) @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -wp_bin_op //; []. intros. rewrite -wp_bin_op //; [].
destruct (bool_decide_reflect (n1 < n2)); by eauto with omega. destruct (bool_decide_reflect (n1 < n2)); by eauto with omega.
...@@ -66,7 +66,7 @@ Qed. ...@@ -66,7 +66,7 @@ Qed.
Lemma wp_eq E (n1 n2 : Z) P Φ : Lemma wp_eq E (n1 n2 : Z) P Φ :
(n1 = n2 P Φ (LitV (LitBool true))) (n1 = n2 P Φ (LitV (LitBool true)))
(n1 n2 P Φ (LitV (LitBool false))) (n1 n2 P Φ (LitV (LitBool false)))
P #> BinOp EqOp (Lit (LitInt n1)) (Lit (LitInt n2)) @ E {{ Φ }}. P WP BinOp EqOp (Lit (LitInt n1)) (Lit (LitInt n2)) @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -wp_bin_op //; []. intros. rewrite -wp_bin_op //; [].
destruct (bool_decide_reflect (n1 = n2)); by eauto with omega. destruct (bool_decide_reflect (n1 = n2)); by eauto with omega.
......
...@@ -142,7 +142,7 @@ Section heap. ...@@ -142,7 +142,7 @@ Section heap.
to_val e = Some v to_val e = Some v
P heap_ctx N nclose N E P heap_ctx N nclose N E
P ( l, l v - Φ (LocV l)) P ( l, l v - Φ (LocV l))
P #> Alloc e @ E {{ Φ }}. P WP Alloc e @ E {{ Φ }}.
Proof. Proof.
rewrite /heap_ctx /heap_inv=> ??? HP. rewrite /heap_ctx /heap_inv=> ??? HP.
trans (|={E}=> auth_own heap_name P)%I. trans (|={E}=> auth_own heap_name P)%I.
...@@ -167,7 +167,7 @@ Section heap. ...@@ -167,7 +167,7 @@ Section heap.
Lemma wp_load N E l q v P Φ : Lemma wp_load N E l q v P Φ :
P heap_ctx N nclose N E P heap_ctx N nclose N E
P ( l {q} v (l {q} v - Φ v)) P ( l {q} v (l {q} v - Φ v))
P #> Load (Loc l) @ E {{ Φ }}. P WP Load (Loc l) @ E {{ Φ }}.
Proof. Proof.
rewrite /heap_ctx /heap_inv=> ?? HPΦ. rewrite /heap_ctx /heap_inv=> ?? HPΦ.
apply (auth_fsa' heap_inv (wp_fsa _) id) apply (auth_fsa' heap_inv (wp_fsa _) id)
...@@ -184,7 +184,7 @@ Section heap. ...@@ -184,7 +184,7 @@ Section heap.
to_val e = Some v to_val e = Some v
P heap_ctx N nclose N E P heap_ctx N nclose N E
P ( l v' (l v - Φ (LitV LitUnit))) P ( l v' (l v - Φ (LitV LitUnit)))
P #> Store (Loc l) e @ E {{ Φ }}. P WP Store (Loc l) e @ E {{ Φ }}.
Proof. Proof.
rewrite /heap_ctx /heap_inv=> ??? HPΦ. rewrite /heap_ctx /heap_inv=> ??? HPΦ.
apply (auth_fsa' heap_inv (wp_fsa _) (alter (λ _, Frac 1 (DecAgree v)) l)) apply (auth_fsa' heap_inv (wp_fsa _) (alter (λ _, Frac 1 (DecAgree v)) l))
...@@ -201,7 +201,7 @@ Section heap. ...@@ -201,7 +201,7 @@ Section heap.
to_val e1 = Some v1 to_val e2 = Some v2 v' v1 to_val e1 = Some v1 to_val e2 = Some v2 v' v1
P heap_ctx N nclose N E P heap_ctx N nclose N E
P ( l {q} v' (l {q} v' - Φ (LitV (LitBool false)))) P ( l {q} v' (l {q} v' - Φ (LitV (LitBool false))))
P #> CAS (Loc l) e1 e2 @ E {{ Φ }}. P WP CAS (Loc l) e1 e2 @ E {{ Φ }}.
Proof. Proof.
rewrite /heap_ctx /heap_inv=>????? HPΦ. rewrite /heap_ctx /heap_inv=>????? HPΦ.
apply (auth_fsa' heap_inv (wp_fsa _) id) apply (auth_fsa' heap_inv (wp_fsa _) id)
...@@ -218,7 +218,7 @@ Section heap. ...@@ -218,7 +218,7 @@ Section heap.
to_val e1 = Some v1 to_val e2 = Some v2 to_val e1 = Some v1 to_val e2 = Some v2
P heap_ctx N nclose N E P heap_ctx N nclose N E
P ( l v1 (l v2 - Φ (LitV (LitBool true)))) P ( l v1 (l v2 - Φ (LitV (LitBool true))))
P #> CAS (Loc l) e1 e2 @ E {{ Φ }}. P WP CAS (Loc l) e1 e2 @ E {{ Φ }}.
Proof. Proof.
rewrite /heap_ctx /heap_inv=> ???? HPΦ. rewrite /heap_ctx /heap_inv=> ???? HPΦ.
apply (auth_fsa' heap_inv (wp_fsa _) (alter (λ _, Frac 1 (DecAgree v2)) l)) apply (auth_fsa' heap_inv (wp_fsa _) (alter (λ _, Frac 1 (DecAgree v2)) l))
......
...@@ -15,14 +15,14 @@ Implicit Types ef : option (expr []). ...@@ -15,14 +15,14 @@ Implicit Types ef : option (expr []).
(** Bind. *) (** Bind. *)
Lemma wp_bind {E e} K Φ : Lemma wp_bind {E e} K Φ :
#> e @ E {{ λ v, #> fill K (of_val v) @ E {{ Φ }}}} #> fill K e @ E {{ Φ }}. WP e @ E {{ λ v, WP fill K (of_val v) @ E {{ Φ }}}} WP fill K e @ E {{ Φ }}.
Proof. apply weakestpre.wp_bind. Qed. Proof. apply weakestpre.wp_bind. Qed.
(** Base axioms for core primitives of the language: Stateful reductions. *) (** Base axioms for core primitives of the language: Stateful reductions. *)
Lemma wp_alloc_pst E σ e v Φ : Lemma wp_alloc_pst E σ e v Φ :
to_val e = Some v to_val e = Some v
( ownP σ ( l, σ !! l = None ownP (<[l:=v]>σ) - Φ (LocV l))) ( ownP σ ( l, σ !! l = None ownP (<[l:=v]>σ) - Φ (LocV l)))
#> Alloc e @ E {{ Φ }}. WP Alloc e @ E {{ Φ }}.
Proof. Proof.
(* TODO RJ: This works around ssreflect bug #22. *) (* TODO RJ: This works around ssreflect bug #22. *)
intros. set (φ v' σ' ef := l, intros. set (φ v' σ' ef := l,
...@@ -39,7 +39,7 @@ Qed. ...@@ -39,7 +39,7 @@ Qed.
Lemma wp_load_pst E σ l v Φ : Lemma wp_load_pst E σ l v Φ :
σ !! l = Some v σ !! l = Some v
( ownP σ (ownP σ - Φ v)) #> Load (Loc l) @ E {{ Φ }}. ( ownP σ (ownP σ - Φ v)) WP Load (Loc l) @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_atomic_det_step σ v σ None) ?right_id //; intros. rewrite -(wp_lift_atomic_det_step σ v σ None) ?right_id //;
last by intros; inv_step; eauto using to_of_val. last by intros; inv_step; eauto using to_of_val.
...@@ -48,7 +48,7 @@ Qed. ...@@ -48,7 +48,7 @@ Qed.
Lemma wp_store_pst E σ l e v v' Φ : Lemma wp_store_pst E σ l e v v' Φ :
to_val e = Some v σ !! l = Some v' to_val e = Some v σ !! l = Some v'
( ownP σ (ownP (<[l:=v]>σ) - Φ (LitV LitUnit))) ( ownP σ (ownP (<[l:=v]>σ) - Φ (LitV LitUnit)))
#> Store (Loc l) e @ E {{ Φ }}. WP Store (Loc l) e @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_atomic_det_step σ (LitV LitUnit) (<[l:=v]>σ) None) intros. rewrite -(wp_lift_atomic_det_step σ (LitV LitUnit) (<[l:=v]>σ) None)
?right_id //; last by intros; inv_step; eauto. ?right_id //; last by intros; inv_step; eauto.
...@@ -57,7 +57,7 @@ Qed. ...@@ -57,7 +57,7 @@ Qed.
Lemma wp_cas_fail_pst E σ l e1 v1 e2 v2 v' Φ : Lemma wp_cas_fail_pst E σ l e1 v1 e2 v2 v' Φ :
to_val e1 = Some v1 to_val e2 = Some v2 σ !! l = Some v' v' v1 to_val e1 = Some v1 to_val e2 = Some v2 σ !! l = Some v' v' v1
( ownP σ (ownP σ - Φ (LitV $ LitBool false))) ( ownP σ (ownP σ - Φ (LitV $ LitBool false)))
#> CAS (Loc l) e1 e2 @ E {{ Φ }}. WP CAS (Loc l) e1 e2 @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_atomic_det_step σ (LitV $ LitBool false) σ None) intros. rewrite -(wp_lift_atomic_det_step σ (LitV $ LitBool false) σ None)
?right_id //; last by intros; inv_step; eauto. ?right_id //; last by intros; inv_step; eauto.
...@@ -66,7 +66,7 @@ Qed. ...@@ -66,7 +66,7 @@ Qed.
Lemma wp_cas_suc_pst E σ l e1 v1 e2 v2 Φ : Lemma wp_cas_suc_pst E σ l e1 v1 e2 v2 Φ :
to_val e1 = Some v1 to_val e2 = Some v2 σ !! l = Some v1 to_val e1 = Some v1 to_val e2 = Some v2 σ !! l = Some v1
( ownP σ (ownP (<[l:=v2]>σ) - Φ (LitV $ LitBool true))) ( ownP σ (ownP (<[l:=v2]>σ) - Φ (LitV $ LitBool true)))
#> CAS (Loc l) e1 e2 @ E {{ Φ }}. WP CAS (Loc l) e1 e2 @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_atomic_det_step σ (LitV $ LitBool true) intros. rewrite -(wp_lift_atomic_det_step σ (LitV $ LitBool true)
(<[l:=v2]>σ) None) ?right_id //; last by intros; inv_step; eauto. (<[l:=v2]>σ) None) ?right_id //; last by intros; inv_step; eauto.
...@@ -74,7 +74,7 @@ Qed. ...@@ -74,7 +74,7 @@ Qed.
(** Base axioms for core primitives of the language: Stateless reductions *) (** Base axioms for core primitives of the language: Stateless reductions *)
Lemma wp_fork E e Φ : Lemma wp_fork E e Φ :
( Φ (LitV LitUnit) #> e {{ λ _, True }}) #> Fork e @ E {{ Φ }}. ( Φ (LitV LitUnit) WP e {{ λ _, True }}) WP Fork e @ E {{ Φ }}.
Proof. Proof.
rewrite -(wp_lift_pure_det_step (Fork e) (Lit LitUnit) (Some e)) //=; rewrite -(wp_lift_pure_det_step (Fork e) (Lit LitUnit) (Some e)) //=;
last by intros; inv_step; eauto. last by intros; inv_step; eauto.
...@@ -83,8 +83,8 @@ Qed. ...@@ -83,8 +83,8 @@ Qed.
Lemma wp_rec E f x e1 e2 v Φ : Lemma wp_rec E f x e1 e2 v Φ :
to_val e2 = Some v to_val e2 = Some v
#> subst' x e2 (subst' f (Rec f x e1) e1) @ E {{ Φ }} WP subst' x e2 (subst' f (Rec f x e1) e1) @ E {{ Φ }}
#> App (Rec f x e1) e2 @ E {{ Φ }}. WP App (Rec f x e1) e2 @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_pure_det_step (App _ _) intros. rewrite -(wp_lift_pure_det_step (App _ _)
(subst' x e2 (subst' f (Rec f x e1) e1)) None) //= ?right_id; (subst' x e2 (subst' f (Rec f x e1) e1)) None) //= ?right_id;
...@@ -94,13 +94,13 @@ Qed. ...@@ -94,13 +94,13 @@ Qed.
Lemma wp_rec' E f x erec e1 e2 v2 Φ : Lemma wp_rec' E f x erec e1 e2 v2 Φ :
e1 = Rec f x erec e1 = Rec f x erec
to_val e2 = Some v2 to_val e2 = Some v2
#> subst' x e2 (subst' f e1 erec) @ E {{ Φ }} WP subst' x e2 (subst' f e1 erec) @ E {{ Φ }}
#> App e1 e2 @ E {{ Φ }}. WP App e1 e2 @ E {{ Φ }}.
Proof. intros ->. apply wp_rec. Qed. Proof. intros ->. apply wp_rec. Qed.
Lemma wp_un_op E op l l' Φ : Lemma wp_un_op E op l l' Φ :
un_op_eval op l = Some l' un_op_eval op l = Some l'
Φ (LitV l') #> UnOp op (Lit l) @ E {{ Φ }}. Φ (LitV l') WP UnOp op (Lit l) @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_pure_det_step (UnOp op _) (Lit l') None) intros. rewrite -(wp_lift_pure_det_step (UnOp op _) (Lit l') None)
?right_id -?wp_value //; intros; inv_step; eauto. ?right_id -?wp_value //; intros; inv_step; eauto.
...@@ -108,21 +108,21 @@ Qed. ...@@ -108,21 +108,21 @@ Qed.
Lemma wp_bin_op E op l1 l2 l' Φ : Lemma wp_bin_op E op l1 l2 l' Φ :
bin_op_eval op l1 l2 = Some l' bin_op_eval op l1 l2 = Some l'
Φ (LitV l') #> BinOp op (Lit l1) (Lit l2) @ E {{ Φ }}. Φ (LitV l') WP BinOp op (Lit l1) (Lit l2) @ E {{ Φ }}.
Proof. Proof.
intros Heval. rewrite -(wp_lift_pure_det_step (BinOp op _ _) (Lit l') None) intros Heval. rewrite -(wp_lift_pure_det_step (BinOp op _ _) (Lit l') None)
?right_id -?wp_value //; intros; inv_step; eauto. ?right_id -?wp_value //; intros; inv_step; eauto.
Qed. Qed.
Lemma wp_if_true E e1 e2 Φ : Lemma wp_if_true E e1 e2 Φ :
#> e1 @ E {{ Φ }} #> If (Lit (LitBool true)) e1 e2 @ E {{ Φ }}. WP e1 @ E {{ Φ }} WP If (Lit (LitBool true)) e1 e2 @ E {{ Φ }}.
Proof. Proof.
rewrite -(wp_lift_pure_det_step (If _ _ _) e1 None) rewrite -(wp_lift_pure_det_step (If _ _ _) e1 None)
?right_id //; intros; inv_step; eauto. ?right_id //; intros; inv_step; eauto.
Qed. Qed.
Lemma wp_if_false E e1 e2 Φ : Lemma wp_if_false E e1 e2 Φ :
#> e2 @ E {{ Φ }} #> If (Lit (LitBool false)) e1 e2 @ E {{ Φ }}. WP e2 @ E {{ Φ }} WP If (Lit (LitBool false)) e1 e2 @ E {{ Φ }}.
Proof. Proof.
rewrite -(wp_lift_pure_det_step (If _ _ _) e2 None) rewrite -(wp_lift_pure_det_step (If _ _ _) e2 None)
?right_id //; intros; inv_step; eauto. ?right_id //; intros; inv_step; eauto.
...@@ -130,7 +130,7 @@ Qed. ...@@ -130,7 +130,7 @@ Qed.
Lemma wp_fst E e1 v1 e2 v2 Φ : Lemma wp_fst E e1 v1 e2 v2 Φ :
to_val e1 = Some v1 to_val e2 = Some v2 to_val e1 = Some v1 to_val e2 = Some v2
Φ v1 #> Fst (Pair e1 e2) @ E {{ Φ }}. Φ v1 WP Fst (Pair e1 e2) @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_pure_det_step (Fst _) e1 None) intros. rewrite -(wp_lift_pure_det_step (Fst _) e1 None)
?right_id -?wp_value //; intros; inv_step; eauto. ?right_id -?wp_value //; intros; inv_step; eauto.
...@@ -138,7 +138,7 @@ Qed. ...@@ -138,7 +138,7 @@ Qed.
Lemma wp_snd E e1 v1 e2 v2 Φ : Lemma wp_snd E e1 v1 e2 v2 Φ :
to_val e1 = Some v1 to_val e2 = Some v2 to_val e1 = Some v1 to_val e2 = Some v2
Φ v2 #> Snd (Pair e1 e2) @ E {{ Φ }}. Φ v2 WP Snd (Pair e1 e2) @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_pure_det_step (Snd _) e2 None) intros. rewrite -(wp_lift_pure_det_step (Snd _) e2 None)
?right_id -?wp_value //; intros; inv_step; eauto. ?right_id -?wp_value //; intros; inv_step; eauto.
...@@ -146,7 +146,7 @@ Qed. ...@@ -146,7 +146,7 @@ Qed.
Lemma wp_case_inl E e0 v0 e1 e2 Φ : Lemma wp_case_inl E e0 v0 e1 e2 Φ :
to_val e0 = Some v0 to_val e0 = Some v0
#> App e1 e0 @ E {{ Φ }} #> Case (InjL e0) e1 e2 @ E {{ Φ }}. WP App e1 e0 @ E {{ Φ }} WP Case (InjL e0) e1 e2 @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_pure_det_step (Case _ _ _) intros. rewrite -(wp_lift_pure_det_step (Case _ _ _)
(App e1 e0) None) ?right_id //; intros; inv_step; eauto. (App e1 e0) None) ?right_id //; intros; inv_step; eauto.
...@@ -154,7 +154,7 @@ Qed. ...@@ -154,7 +154,7 @@ Qed.
Lemma wp_case_inr E e0 v0 e1 e2 Φ : Lemma wp_case_inr E e0 v0 e1 e2 Φ :
to_val e0 = Some v0 to_val e0 = Some v0
#> App e2 e0 @ E {{ Φ }} #> Case (InjR e0) e1 e2 @ E {{ Φ }}. WP App e2 e0 @ E {{ Φ }} WP Case (InjR e0) e1 e2 @ E {{ Φ }}.
Proof. Proof.
intros. rewrite -(wp_lift_pure_det_step (Case _ _ _) intros. rewrite -(wp_lift_pure_det_step (Case _ _ _)
(App e2 e0) None) ?right_id //; intros; inv_step; eauto. (App e2 e0) None) ?right_id //; intros; inv_step; eauto.
......
...@@ -2,12 +2,12 @@ From iris.heap_lang Require Export derived. ...@@ -2,12 +2,12 @@ From iris.heap_lang Require Export derived.
Export heap_lang. Export heap_lang.
Arguments wp {_ _} _ _%E _. Arguments wp {_ _} _ _%E _.
Notation "#> e @ E {{ Φ } }" := (wp E e%E Φ) Notation "'WP' e @ E {{ Φ } }" := (wp E e%E Φ)
(at level 20, e, Φ at level 200, (at level 20, e, Φ at level 200,
format "#> e @ E {{ Φ } }") : uPred_scope. format "'WP' e @ E {{ Φ } }") : uPred_scope.
Notation "#> e {{ Φ } }" := (wp e%E Φ) Notation "'WP' e {{ Φ } }" := (wp e%E Φ)
(at level 20, e, Φ at level 200, (at level 20, e, Φ at level 200,
format "#> e {{ Φ } }") : uPred_scope. format "'WP' e {{ Φ } }") : uPred_scope.
Coercion LitInt : Z >-> base_lit. Coercion LitInt : Z >-> base_lit.
Coercion LitBool : bool >-> base_lit. Coercion LitBool : bool >-> base_lit.
......
...@@ -21,9 +21,9 @@ Local Notation iProp := (iPropG heap_lang Σ). ...@@ -21,9 +21,9 @@ Local Notation iProp := (iPropG heap_lang Σ).
Lemma par_spec (Ψ1 Ψ2 : val iProp) e (f1 f2 : val) (Φ : val iProp) : Lemma par_spec (Ψ1 Ψ2 : val iProp) e (f1 f2 : val) (Φ : val iProp) :
heapN N to_val e = Some (f1,f2)%V heapN N to_val e = Some (f1,f2)%V
(heap_ctx heapN #> f1 §() {{ Ψ1 }} #> f2 §() {{ Ψ2 }} (heap_ctx heapN WP f1 §() {{ Ψ1 }} WP f2 §() {{ Ψ2 }}
v1 v2, Ψ1 v1 Ψ2 v2 - Φ (v1,v2)%V) v1 v2, Ψ1 v1 Ψ2 v2 - Φ (v1,v2)%V)
#> par e {{ Φ }}. WP par e {{ Φ }}.
Proof. Proof.
intros. rewrite /par. ewp (by eapply wp_value). wp_let. wp_proj. intros. rewrite /par. ewp (by eapply wp_value). wp_let. wp_proj.
ewp (eapply spawn_spec; wp_done). ewp (eapply spawn_spec; wp_done).
...@@ -38,9 +38,9 @@ Qed. ...@@ -38,9 +38,9 @@ Qed.
Lemma wp_par (Ψ1 Ψ2 : val iProp) (e1 e2 : expr []) (Φ : val iProp) : Lemma wp_par (Ψ1 Ψ2 : val iProp) (e1 e2 : expr []) (Φ : val iProp) :
heapN N heapN N
(heap_ctx heapN #> e1 {{ Ψ1 }} #> e2 {{ Ψ2 }} (heap_ctx heapN WP e1 {{ Ψ1 }} WP e2 {{ Ψ2 }}
v1 v2, Ψ1 v1 Ψ2 v2 - Φ (v1,v2)%V) v1 v2, Ψ1 v1 Ψ2 v2 - Φ (v1,v2)%V)
#> ParV e1 e2 {{ Φ }}. WP ParV e1 e2 {{ Φ }}.
Proof. Proof.
intros. rewrite -par_spec //. repeat apply sep_mono; done || by wp_seq. intros. rewrite -par_spec //. repeat apply sep_mono; done || by wp_seq.