Commit 72e8f63c authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan
Browse files

Get rid of phi predicates everywhere

parent 6b5ee4fa
...@@ -29,14 +29,10 @@ Lemma wp_alloc_pst E σ e v Φ : ...@@ -29,14 +29,10 @@ Lemma wp_alloc_pst E σ e v Φ :
WP Alloc e @ E {{ Φ }}. WP Alloc e @ E {{ Φ }}.
Proof. Proof.
iIntros {?} "[HP HΦ]". iIntros {?} "[HP HΦ]".
(* TODO: This works around ssreflect bug #22. *) iApply (wp_lift_atomic_head_step (Alloc e) σ); try (by simpl; eauto).
set (φ (e' : expr []) σ' ef := l, iFrame "HP". iNext. iIntros {v2 σ2 ef} "[% HP]". inv_head_step.
ef = None e' = Lit (LitLoc l) σ' = <[l:=v]>σ σ !! l = None). match goal with H: _ = of_val v2 |- _ => apply (inj of_val (LitV _)) in H end.
iApply (wp_lift_atomic_head_step (Alloc e) φ σ); try (by simpl; eauto); subst v2. iSplit; last done. iApply "HΦ"; by iSplit.
[by intros; subst φ; inv_head_step; eauto 8|].
iFrame "HP". iNext. iIntros {v2 σ2 ef} "[Hφ HP]".
iDestruct "Hφ" as %(l & -> & [= <-]%of_to_val_flip & -> & ?); simpl.
iSplit; last done. iApply "HΦ"; by iSplit.
Qed. Qed.
Lemma wp_load_pst E σ l v Φ : Lemma wp_load_pst E σ l v Φ :
......
...@@ -31,22 +31,27 @@ Proof. ...@@ -31,22 +31,27 @@ Proof.
iApply "Hwp". by eauto. iApply "Hwp". by eauto.
Qed. Qed.
Lemma wp_lift_pure_head_step E (φ : expr option expr Prop) Φ e1 : Lemma wp_lift_pure_head_step E Φ e1 :
to_val e1 = None to_val e1 = None
( σ1, head_reducible e1 σ1) ( σ1, head_reducible e1 σ1)
( σ1 e2 σ2 ef, head_step e1 σ1 e2 σ2 ef σ1 = σ2 φ e2 ef) ( σ1 e2 σ2 ef, head_step e1 σ1 e2 σ2 ef σ1 = σ2)
( e2 ef, φ e2 ef WP e2 @ E {{ Φ }} wp_fork ef) WP e1 @ E {{ Φ }}. ( e2 ef σ, head_step e1 σ e2 σ ef WP e2 @ E {{ Φ }} wp_fork ef)
Proof. eauto using wp_lift_pure_step. Qed. WP e1 @ E {{ Φ }}.
Proof.
iIntros {???} "H". iApply wp_lift_pure_step; eauto. iNext.
iIntros {????}. iApply "H". eauto.
Qed.
Lemma wp_lift_atomic_head_step {E Φ} e1 Lemma wp_lift_atomic_head_step {E Φ} e1 σ1 :
(φ : expr state option expr Prop) σ1 :
atomic e1 atomic e1
head_reducible e1 σ1 head_reducible e1 σ1
( e2 σ2 ef, head_step e1 σ1 e2 σ2 ef φ e2 σ2 ef)
ownP σ1 ( v2 σ2 ef, ownP σ1 ( v2 σ2 ef,
φ (of_val v2) σ2 ef ownP σ2 - (|={E}=> Φ v2) wp_fork ef) head_step e1 σ1 (of_val v2) σ2 ef ownP σ2 - (|={E}=> Φ v2) wp_fork ef)
WP e1 @ E {{ Φ }}. WP e1 @ E {{ Φ }}.
Proof. eauto using wp_lift_atomic_step. Qed. Proof.
iIntros {??} "[? H]". iApply wp_lift_atomic_step; eauto. iFrame. iNext.
iIntros {???} "[% ?]". iApply "H". eauto.
Qed.
Lemma wp_lift_atomic_det_head_step {E Φ e1} σ1 v2 σ2 ef : Lemma wp_lift_atomic_det_head_step {E Φ e1} σ1 v2 σ2 ef :
atomic e1 atomic e1
......
...@@ -20,37 +20,35 @@ Implicit Types Ψ : val Λ → iProp Λ Σ. ...@@ -20,37 +20,35 @@ Implicit Types Ψ : val Λ → iProp Λ Σ.
Lemma ht_lift_step E1 E2 P Pσ1 Φ1 Φ2 Ψ e1 : Lemma ht_lift_step E1 E2 P Pσ1 Φ1 Φ2 Ψ e1 :
E2 E1 to_val e1 = None E2 E1 to_val e1 = None
(P ={E1,E2}=> σ1, reducible e1 σ1 (P ={E1,E2}=> σ1, reducible e1 σ1 ownP σ1 Pσ1 σ1)
ownP σ1 Pσ1 σ1) ( σ1 e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef ownP σ2 Pσ1 σ1
( σ1 e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef ownP σ2 Pσ1 σ1 ={E2,E1}=> Φ1 e2 σ2 ef Φ2 e2 σ2 ef)
={E2,E1}=> Φ1 e2 σ2 ef Φ2 e2 σ2 ef) ( e2 σ2 ef, {{ Φ1 e2 σ2 ef }} e2 @ E1 {{ Ψ }})
( e2 σ2 ef, {{ Φ1 e2 σ2 ef }} e2 @ E1 {{ Ψ }}) ( e2 σ2 ef, {{ Φ2 e2 σ2 ef }} ef ?@ {{ _, True }})
( e2 σ2 ef, {{ Φ2 e2 σ2 ef }} ef ?@ {{ _, True }})
{{ P }} e1 @ E1 {{ Ψ }}. {{ P }} e1 @ E1 {{ Ψ }}.
Proof. Proof.
iIntros {??} "#(#Hvs&HΦ&He2&Hef) ! HP". iIntros {??} "#(#Hvs&HΦ&He2&Hef) ! HP".
iApply (wp_lift_step E1 E2 _ e1); auto. iApply (wp_lift_step E1 E2 _ e1); auto.
iPvs ("Hvs" with "HP") as {σ1} "(%&Hσ&HP)"; first set_solver. iPvs ("Hvs" with "HP") as {σ1} "(%&Hσ&HP)"; first set_solver.
iPvsIntro. iExists σ1. repeat iSplit. by eauto. iFrame. iPvsIntro. iExists σ1. repeat iSplit. by eauto. iFrame.
iNext. iIntros {e2 σ2 ef} "[#Hφ Hown]". iNext. iIntros {e2 σ2 ef} "[#Hstep Hown]".
iSpecialize ("HΦ" $! σ1 e2 σ2 ef with "[-]"). by iFrame "Hφ HP Hown". iSpecialize ("HΦ" $! σ1 e2 σ2 ef with "[-]"). by iFrame "Hstep HP Hown".
iPvs "HΦ" as "[H1 H2]"; first by set_solver. iPvsIntro. iSplitL "H1". iPvs "HΦ" as "[H1 H2]"; first by set_solver. iPvsIntro. iSplitL "H1".
- by iApply "He2". - by iApply "He2".
- destruct ef as [e|]; last done. by iApply ("Hef" $! _ _ (Some e)). - destruct ef as [e|]; last done. by iApply ("Hef" $! _ _ (Some e)).
Qed. Qed.
Lemma ht_lift_atomic_step Lemma ht_lift_atomic_step E P e1 σ1 :
E (φ : expr Λ state Λ option (expr Λ) Prop) P e1 σ1 :
atomic e1 atomic e1
reducible e1 σ1 reducible e1 σ1
( e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef φ e2 σ2 ef) ( e2 σ2 ef, {{ prim_step e1 σ1 e2 σ2 ef P }} ef ?@ {{ _, True }})
( e2 σ2 ef, {{ φ e2 σ2 ef P }} ef ?@ {{ _, True }}) {{ ownP σ1 P }} e1 @ E {{ v, σ2 ef, ownP σ2
{{ ownP σ1 P }} e1 @ E {{ v, σ2 ef, ownP σ2 φ (of_val v) σ2 ef }}. prim_step e1 σ1 (of_val v) σ2 ef }}.
Proof. Proof.
iIntros {? Hsafe Hstep} "#Hef". iIntros {? Hsafe} "#Hef".
set (φ' (_:state Λ) e σ ef := is_Some (to_val e) φ e σ ef).
iApply (ht_lift_step E E _ (λ σ1', P σ1 = σ1')%I iApply (ht_lift_step E E _ (λ σ1', P σ1 = σ1')%I
(λ e2 σ2 ef, ownP σ2 (φ' σ1 e2 σ2 ef))%I (λ e2 σ2 ef, φ e2 σ2 ef P)%I); (λ e2 σ2 ef, ownP σ2 (is_Some (to_val e2) prim_step e1 σ1 e2 σ2 ef))%I
(λ e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef P)%I);
try by (eauto using atomic_not_val). try by (eauto using atomic_not_val).
repeat iSplit. repeat iSplit.
- iIntros "![Hσ1 HP]". iExists σ1. iPvsIntro. - iIntros "![Hσ1 HP]". iExists σ1. iPvsIntro.
...@@ -62,35 +60,32 @@ Proof. ...@@ -62,35 +60,32 @@ Proof.
- done. - done.
Qed. Qed.
Lemma ht_lift_pure_step E (φ : expr Λ option (expr Λ) Prop) P P' Ψ e1 : Lemma ht_lift_pure_step E P P' Ψ e1 :
to_val e1 = None to_val e1 = None
( σ1, reducible e1 σ1) ( σ1, reducible e1 σ1)
( σ1 e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef σ1 = σ2 φ e2 ef) ( σ1 e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef σ1 = σ2)
( e2 ef, {{ φ e2 ef P }} e2 @ E {{ Ψ }}) ( e2 ef σ, {{ prim_step e1 σ e2 σ ef P }} e2 @ E {{ Ψ }})
( e2 ef, {{ φ e2 ef P' }} ef ?@ {{ _, True }}) ( e2 ef σ, {{ prim_step e1 σ e2 σ ef P' }} ef ?@ {{ _, True }})
{{ (P P') }} e1 @ E {{ Ψ }}. {{ (P P') }} e1 @ E {{ Ψ }}.
Proof. Proof.
iIntros {? Hsafe Hstep} "[#He2 #Hef] ! HP". iIntros {? Hsafe Hpure} "[#He2 #Hef] ! HP". iApply wp_lift_pure_step; auto.
iApply (wp_lift_pure_step E φ _ e1); auto. iNext; iIntros {e2 ef σ Hstep}. iDestruct "HP" as "[HP HP']"; iSplitL "HP".
iNext; iIntros {e2 ef Hφ}. iDestruct "HP" as "[HP HP']"; iSplitL "HP".
- iApply "He2"; by iSplit. - iApply "He2"; by iSplit.
- destruct ef as [e|]; last done. - destruct ef as [e|]; last done. iApply ("Hef" $! _ (Some e)); by iSplit.
iApply ("Hef" $! _ (Some e)); by iSplit.
Qed. Qed.
Lemma ht_lift_pure_det_step Lemma ht_lift_pure_det_step E P P' Ψ e1 e2 ef :
E (φ : expr Λ option (expr Λ) Prop) P P' Ψ e1 e2 ef :
to_val e1 = None to_val e1 = None
( σ1, reducible e1 σ1) ( σ1, reducible e1 σ1)
( σ1 e2' σ2 ef', prim_step e1 σ1 e2' σ2 ef' σ1 = σ2 e2 = e2' ef = ef') ( σ1 e2' σ2 ef', prim_step e1 σ1 e2' σ2 ef' σ1 = σ2 e2 = e2' ef = ef')
{{ P }} e2 @ E {{ Ψ }} {{ P' }} ef ?@ {{ _, True }} {{ P }} e2 @ E {{ Ψ }} {{ P' }} ef ?@ {{ _, True }}
{{ (P P') }} e1 @ E {{ Ψ }}. {{ (P P') }} e1 @ E {{ Ψ }}.
Proof. Proof.
iIntros {? Hsafe Hdet} "[#He2 #Hef]". iIntros {? Hsafe Hpuredet} "[#He2 #Hef]".
iApply (ht_lift_pure_step _ (λ e2' ef', e2 = e2' ef = ef')); eauto. iApply ht_lift_pure_step; eauto. by intros; eapply Hpuredet.
iSplit; iIntros {e2' ef'}. iSplit; iIntros {e2' ef' σ}.
- iIntros "! [#He ?]"; iDestruct "He" as %[-> ->]. by iApply "He2". - iIntros "! [% ?]". edestruct Hpuredet as (_&->&->). done. by iApply "He2".
- destruct ef' as [e'|]; last done. - destruct ef' as [e'|]; last done.
iIntros "! [#He ?]"; iDestruct "He" as %[-> ->]. by iApply "Hef". iIntros "! [% ?]". edestruct Hpuredet as (_&->&->). done. by iApply "Hef".
Qed. Qed.
End lifting. End lifting.
...@@ -40,17 +40,18 @@ Proof. ...@@ -40,17 +40,18 @@ Proof.
exists r1', r2'; split_and?; try done. by uPred.unseal; intros ? ->. exists r1', r2'; split_and?; try done. by uPred.unseal; intros ? ->.
Qed. Qed.
Lemma wp_lift_pure_step E (φ : expr Λ option (expr Λ) Prop) Φ e1 : Lemma wp_lift_pure_step E Φ e1 :
to_val e1 = None to_val e1 = None
( σ1, reducible e1 σ1) ( σ1, reducible e1 σ1)
( σ1 e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef σ1 = σ2 φ e2 ef) ( σ1 e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef σ1 = σ2)
( e2 ef, φ e2 ef WP e2 @ E {{ Φ }} wp_fork ef) WP e1 @ E {{ Φ }}. ( e2 ef σ, prim_step e1 σ e2 σ ef WP e2 @ E {{ Φ }} wp_fork ef)
WP e1 @ E {{ Φ }}.
Proof. Proof.
intros He Hsafe Hstep; rewrite wp_eq; uPred.unseal. intros He Hsafe Hstep; rewrite wp_eq; uPred.unseal.
split=> n r ? Hwp; constructor; auto. split=> n r ? Hwp; constructor; auto.
intros k Ef σ1 rf ???; split; [done|]. destruct n as [|n]; first lia. intros k Ef σ1 rf ???; split; [done|]. destruct n as [|n]; first lia.
intros e2 σ2 ef ?; destruct (Hstep σ1 e2 σ2 ef); auto; subst. intros e2 σ2 ef ?; destruct (Hstep σ1 e2 σ2 ef); auto; subst.
destruct (Hwp e2 ef k r) as (r1&r2&Hr&?&?); auto. destruct (Hwp e2 ef σ1 k r) as (r1&r2&Hr&?&?); auto.
exists r1,r2; split_and?; try done. exists r1,r2; split_and?; try done.
- rewrite -Hr; eauto using wsat_le. - rewrite -Hr; eauto using wsat_le.
- uPred.unseal; by intros ? ->. - uPred.unseal; by intros ? ->.
...@@ -59,16 +60,14 @@ Qed. ...@@ -59,16 +60,14 @@ Qed.
(** Derived lifting lemmas. *) (** Derived lifting lemmas. *)
Import uPred. Import uPred.
Lemma wp_lift_atomic_step {E Φ} e1 Lemma wp_lift_atomic_step {E Φ} e1 σ1 :
(φ : expr Λ state Λ option (expr Λ) Prop) σ1 :
atomic e1 atomic e1
reducible e1 σ1 reducible e1 σ1
( e2 σ2 ef, prim_step e1 σ1 e2 σ2 ef φ e2 σ2 ef)
ownP σ1 ( v2 σ2 ef, ownP σ1 ( v2 σ2 ef,
φ (of_val v2) σ2 ef ownP σ2 - (|={E}=> Φ v2) wp_fork ef) prim_step e1 σ1 (of_val v2) σ2 ef ownP σ2 - (|={E}=> Φ v2) wp_fork ef)
WP e1 @ E {{ Φ }}. WP e1 @ E {{ Φ }}.
Proof. Proof.
iIntros {???} "[Hσ1 Hwp]". iApply (wp_lift_step E E _ e1); auto using atomic_not_val. iIntros {??} "[Hσ1 Hwp]". iApply (wp_lift_step E E _ e1); auto using atomic_not_val.
iPvsIntro. iExists σ1. repeat iSplit; eauto 10 using atomic_step. iPvsIntro. iExists σ1. repeat iSplit; eauto 10 using atomic_step.
iFrame. iNext. iIntros {e2 σ2 ef} "[% Hσ2]". iFrame. iNext. iIntros {e2 σ2 ef} "[% Hσ2]".
edestruct @atomic_step as [v2 Hv%of_to_val]; eauto. subst e2. edestruct @atomic_step as [v2 Hv%of_to_val]; eauto. subst e2.
...@@ -80,13 +79,12 @@ Lemma wp_lift_atomic_det_step {E Φ e1} σ1 v2 σ2 ef : ...@@ -80,13 +79,12 @@ Lemma wp_lift_atomic_det_step {E Φ e1} σ1 v2 σ2 ef :
atomic e1 atomic e1
reducible e1 σ1 reducible e1 σ1
( e2' σ2' ef', prim_step e1 σ1 e2' σ2' ef' ( e2' σ2' ef', prim_step e1 σ1 e2' σ2' ef'
σ2 = σ2' to_val e2' = Some v2 ef = ef') σ2 = σ2' to_val e2' = Some v2 ef = ef')
ownP σ1 (ownP σ2 - (|={E}=> Φ v2) wp_fork ef) WP e1 @ E {{ Φ }}. ownP σ1 (ownP σ2 - (|={E}=> Φ v2) wp_fork ef) WP e1 @ E {{ Φ }}.
Proof. Proof.
iIntros {???} "[Hσ1 Hσ2]". iApply (wp_lift_atomic_step _ (λ e2' σ2' ef', iIntros {?? Hdet} "[Hσ1 Hσ2]". iApply (wp_lift_atomic_step _ σ1); try done.
σ2 = σ2' to_val e2' = Some v2 ef = ef') σ1); try done. iFrame. iNext. iFrame. iNext. iIntros {v2' σ2' ef'} "[% Hσ2']".
iIntros {v2' σ2' ef'} "[#Hφ Hσ2']". rewrite to_of_val. edestruct Hdet as (->&->%of_to_val%(inj of_val)&->). done. by iApply "Hσ2".
iDestruct "Hφ" as %(->&[= ->]&->). by iApply "Hσ2".
Qed. Qed.
Lemma wp_lift_pure_det_step {E Φ} e1 e2 ef : Lemma wp_lift_pure_det_step {E Φ} e1 e2 ef :
...@@ -95,8 +93,7 @@ Lemma wp_lift_pure_det_step {E Φ} e1 e2 ef : ...@@ -95,8 +93,7 @@ Lemma wp_lift_pure_det_step {E Φ} e1 e2 ef :
( σ1 e2' σ2 ef', prim_step e1 σ1 e2' σ2 ef' σ1 = σ2 e2 = e2' ef = ef') ( σ1 e2' σ2 ef', prim_step e1 σ1 e2' σ2 ef' σ1 = σ2 e2 = e2' ef = ef')
(WP e2 @ E {{ Φ }} wp_fork ef) WP e1 @ E {{ Φ }}. (WP e2 @ E {{ Φ }} wp_fork ef) WP e1 @ E {{ Φ }}.
Proof. Proof.
iIntros {???} "?". iIntros {?? Hpuredet} "?". iApply (wp_lift_pure_step E); try done.
iApply (wp_lift_pure_step E (λ e2' ef', e2 = e2' ef = ef')); try done. by intros; eapply Hpuredet. iNext. by iIntros {e' ef' σ (_&->&->)%Hpuredet}.
iNext. by iIntros {e' ef' [-> ->] }.
Qed. Qed.
End lifting. End lifting.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment