Commit 4aece797 authored by Robbert Krebbers's avatar Robbert Krebbers

Split monotonicity and closedness fields of uPred.

parent 762b22c1
This diff is collapsed.
...@@ -18,7 +18,7 @@ Implicit Types m : iGst Λ Σ. ...@@ -18,7 +18,7 @@ Implicit Types m : iGst Λ Σ.
Notation wptp n := (Forall3 (λ e Φ r, uPred_holds (wp e Φ) n r)). Notation wptp n := (Forall3 (λ e Φ r, uPred_holds (wp e Φ) n r)).
Lemma wptp_le Φs es rs n n' : Lemma wptp_le Φs es rs n n' :
{n'} (big_op rs) wptp n es Φs rs n' n wptp n' es Φs rs. {n'} (big_op rs) wptp n es Φs rs n' n wptp n' es Φs rs.
Proof. induction 2; constructor; eauto using uPred_weaken. Qed. Proof. induction 2; constructor; eauto using uPred_closed. Qed.
Lemma nsteps_wptp Φs k n tσ1 tσ2 rs1 : Lemma nsteps_wptp Φs k n tσ1 tσ2 rs1 :
nsteps step k tσ1 tσ2 nsteps step k tσ1 tσ2
1 < n wptp (k + n) (tσ1.1) Φs rs1 1 < n wptp (k + n) (tσ1.1) Φs rs1
...@@ -51,7 +51,8 @@ Proof. ...@@ -51,7 +51,8 @@ Proof.
{ rewrite /option_list right_id_L. { rewrite /option_list right_id_L.
apply Forall3_app, Forall3_cons; eauto using wptp_le. apply Forall3_app, Forall3_cons; eauto using wptp_le.
rewrite wp_eq. rewrite wp_eq.
apply uPred_weaken with (k + n) r2; eauto using cmra_included_l. } apply uPred_closed with (k + n);
first apply uPred_mono with r2; eauto using cmra_included_l. }
by rewrite -Permutation_middle /= big_op_app. by rewrite -Permutation_middle /= big_op_app.
Qed. Qed.
Lemma wp_adequacy_steps P Φ k n e1 t2 σ1 σ2 r1 : Lemma wp_adequacy_steps P Φ k n e1 t2 σ1 σ2 r1 :
......
...@@ -19,11 +19,12 @@ Next Obligation. ...@@ -19,11 +19,12 @@ Next Obligation.
apply HP; auto. by rewrite (dist_le _ _ _ _ Hr); last lia. apply HP; auto. by rewrite (dist_le _ _ _ _ Hr); last lia.
Qed. Qed.
Next Obligation. Next Obligation.
intros Λ Σ E1 E2 P r1 r2 n1 n2 HP [r3 ?] Hn ? rf k Ef σ ?? Hws; setoid_subst. intros Λ Σ E1 E2 P n r1 r2 HP [r3 ?] rf k Ef σ ?? Hws; setoid_subst.
destruct (HP (r3rf) k Ef σ) as (r'&?&Hws'); rewrite ?(assoc op); auto. destruct (HP (r3 rf) k Ef σ) as (r'&?&Hws'); rewrite ?(assoc op); auto.
exists (r' r3); rewrite -assoc; split; last done. exists (r' r3); rewrite -assoc; split; last done.
apply uPred_weaken with k r'; eauto using cmra_included_l. apply uPred_mono with r'; eauto using cmra_included_l.
Qed. Qed.
Next Obligation. naive_solver. Qed.
Definition pvs_aux : { x | x = @pvs_def }. by eexists. Qed. Definition pvs_aux : { x | x = @pvs_def }. by eexists. Qed.
Definition pvs := proj1_sig pvs_aux. Definition pvs := proj1_sig pvs_aux.
...@@ -62,7 +63,7 @@ Proof. apply ne_proper, _. Qed. ...@@ -62,7 +63,7 @@ Proof. apply ne_proper, _. Qed.
Lemma pvs_intro E P : P |={E}=> P. Lemma pvs_intro E P : P |={E}=> P.
Proof. Proof.
rewrite pvs_eq. split=> n r ? HP rf k Ef σ ???; exists r; split; last done. rewrite pvs_eq. split=> n r ? HP rf k Ef σ ???; exists r; split; last done.
apply uPred_weaken with n r; eauto. apply uPred_closed with n; eauto.
Qed. Qed.
Lemma pvs_mono E1 E2 P Q : P Q (|={E1,E2}=> P) (|={E1,E2}=> Q). Lemma pvs_mono E1 E2 P Q : P Q (|={E1,E2}=> P) (|={E1,E2}=> Q).
Proof. Proof.
...@@ -75,7 +76,7 @@ Proof. ...@@ -75,7 +76,7 @@ Proof.
rewrite pvs_eq uPred.timelessP_spec=> HP. rewrite pvs_eq uPred.timelessP_spec=> HP.
uPred.unseal; split=>-[|n] r ? HP' rf k Ef σ ???; first lia. uPred.unseal; split=>-[|n] r ? HP' rf k Ef σ ???; first lia.
exists r; split; last done. exists r; split; last done.
apply HP, uPred_weaken with n r; eauto using cmra_validN_le. apply HP, uPred_closed with n; eauto using cmra_validN_le.
Qed. Qed.
Lemma pvs_trans E1 E2 E3 P : Lemma pvs_trans E1 E2 E3 P :
E2 E1 E3 (|={E1,E2}=> |={E2,E3}=> P) (|={E1,E3}=> P). E2 E1 E3 (|={E1,E2}=> |={E2,E3}=> P) (|={E1,E3}=> P).
...@@ -96,7 +97,7 @@ Proof. ...@@ -96,7 +97,7 @@ Proof.
destruct (HP (r2 rf) k Ef σ) as (r'&?&?); eauto. destruct (HP (r2 rf) k Ef σ) as (r'&?&?); eauto.
{ by rewrite assoc -(dist_le _ _ _ _ Hr); last lia. } { by rewrite assoc -(dist_le _ _ _ _ Hr); last lia. }
exists (r' r2); split; last by rewrite -assoc. exists (r' r2); split; last by rewrite -assoc.
exists r', r2; split_and?; auto; apply uPred_weaken with n r2; auto. exists r', r2; split_and?; auto. apply uPred_closed with n; auto.
Qed. Qed.
Lemma pvs_openI i P : ownI i P (|={{[i]},}=> P). Lemma pvs_openI i P : ownI i P (|={{[i]},}=> P).
Proof. Proof.
...@@ -105,17 +106,17 @@ Proof. ...@@ -105,17 +106,17 @@ Proof.
destruct (wsat_open k Ef σ (r rf) i P) as (rP&?&?); auto. destruct (wsat_open k Ef σ (r rf) i P) as (rP&?&?); auto.
{ rewrite lookup_wld_op_l ?Hinv; eauto; apply dist_le with (S n); eauto. } { rewrite lookup_wld_op_l ?Hinv; eauto; apply dist_le with (S n); eauto. }
exists (rP r); split; last by rewrite (left_id_L _ _) -assoc. exists (rP r); split; last by rewrite (left_id_L _ _) -assoc.
eapply uPred_weaken with (S k) rP; eauto using cmra_included_l. eapply uPred_mono with rP; eauto using cmra_included_l.
Qed. Qed.
Lemma pvs_closeI i P : (ownI i P P) (|={,{[i]}}=> True). Lemma pvs_closeI i P : (ownI i P P) (|={,{[i]}}=> True).
Proof. Proof.
rewrite pvs_eq. uPred.unseal; split=> -[|n] r ? [? HP] rf [|k] Ef σ ? HE ?; try lia. rewrite pvs_eq. uPred.unseal; split=> -[|n] r ? [? HP] rf [|k] Ef σ ? HE ?; try lia.
exists ; split; [done|]. exists ; split; [done|].
rewrite left_id; apply wsat_close with P r. rewrite left_id; apply wsat_close with P r.
- apply ownI_spec, uPred_weaken with (S n) r; auto. - apply ownI_spec, uPred_closed with (S n); auto.
- set_solver +HE. - set_solver +HE.
- by rewrite -(left_id_L () Ef). - by rewrite -(left_id_L () Ef).
- apply uPred_weaken with n r; auto. - apply uPred_closed with n; auto.
Qed. Qed.
Lemma pvs_ownG_updateP E m (P : iGst Λ Σ Prop) : Lemma pvs_ownG_updateP E m (P : iGst Λ Σ Prop) :
m ~~>: P ownG m (|={E}=> m', P m' ownG m'). m ~~>: P ownG m (|={E}=> m', P m' ownG m').
...@@ -131,7 +132,7 @@ Proof. ...@@ -131,7 +132,7 @@ Proof.
rewrite pvs_eq. intros ?; rewrite /ownI; uPred.unseal. rewrite pvs_eq. intros ?; rewrite /ownI; uPred.unseal.
split=> -[|n] r ? HP rf [|k] Ef σ ???; try lia. split=> -[|n] r ? HP rf [|k] Ef σ ???; try lia.
destruct (wsat_alloc k E Ef σ rf P r) as (i&?&?&?); auto. destruct (wsat_alloc k E Ef σ rf P r) as (i&?&?&?); auto.
{ apply uPred_weaken with n r; eauto. } { apply uPred_closed with n; eauto. }
exists (Res {[ i := to_agree (Next (iProp_unfold P)) ]} ). exists (Res {[ i := to_agree (Next (iProp_unfold P)) ]} ).
split; [|done]. by exists i; split; rewrite /uPred_holds /=. split; [|done]. by exists i; split; rewrite /uPred_holds /=.
Qed. Qed.
......
...@@ -38,17 +38,19 @@ Next Obligation. ...@@ -38,17 +38,19 @@ Next Obligation.
intros rf k Ef σ1 ?; rewrite -(dist_le _ _ _ _ Hr); naive_solver. intros rf k Ef σ1 ?; rewrite -(dist_le _ _ _ _ Hr); naive_solver.
Qed. Qed.
Next Obligation. Next Obligation.
intros Λ Σ E e Φ n1 n2 r1 r2; revert Φ E e n2 r1 r2. intros Λ Σ E e Φ n r1 r2; revert Φ E e r1 r2.
induction n1 as [n1 IH] using lt_wf_ind; intros Φ E e n2 r1 r1'. induction n as [n IH] using lt_wf_ind; intros Φ E e r1 r1'.
destruct 1 as [|n1 r1 e1 ? Hgo]. destruct 1 as [|n r1 e1 ? Hgo].
- constructor; eauto using uPred_weaken. - constructor; eauto using uPred_mono.
- intros [rf' Hr] ??; constructor; [done|intros rf k Ef σ1 ???]. - intros [rf' Hr]; constructor; [done|intros rf k Ef σ1 ???].
destruct (Hgo (rf' rf) k Ef σ1) as [Hsafe Hstep]; destruct (Hgo (rf' rf) k Ef σ1) as [Hsafe Hstep];
rewrite ?assoc -?Hr; auto; constructor; [done|]. rewrite ?assoc -?Hr; auto; constructor; [done|].
intros e2 σ2 ef ?; destruct (Hstep e2 σ2 ef) as (r2&r2'&?&?&?); auto. intros e2 σ2 ef ?; destruct (Hstep e2 σ2 ef) as (r2&r2'&?&?&?); auto.
exists r2, (r2' rf'); split_and?; eauto 10 using (IH k), cmra_included_l. exists r2, (r2' rf'); split_and?; eauto 10 using (IH k), cmra_included_l.
by rewrite -!assoc (assoc _ r2). by rewrite -!assoc (assoc _ r2).
Qed. Qed.
Next Obligation. destruct 1; constructor; eauto using uPred_closed. Qed.
(* Perform sealing. *) (* Perform sealing. *)
Definition wp_aux : { x | x = @wp_def }. by eexists. Qed. Definition wp_aux : { x | x = @wp_def }. by eexists. Qed.
Definition wp := proj1_sig wp_aux. Definition wp := proj1_sig wp_aux.
...@@ -194,7 +196,7 @@ Proof. ...@@ -194,7 +196,7 @@ Proof.
destruct (Hstep e2 σ2 ef) as (r2&r2'&?&?&?); auto. destruct (Hstep e2 σ2 ef) as (r2&r2'&?&?&?); auto.
exists (r2 rR), r2'; split_and?; auto. exists (r2 rR), r2'; split_and?; auto.
- by rewrite -(assoc _ r2) (comm _ rR) !assoc -(assoc _ _ rR). - by rewrite -(assoc _ r2) (comm _ rR) !assoc -(assoc _ _ rR).
- apply IH; eauto using uPred_weaken. - apply IH; eauto using uPred_closed.
Qed. Qed.
Lemma wp_frame_step_r E E1 E2 e Φ R : Lemma wp_frame_step_r E E1 E2 e Φ R :
to_val e = None E E1 E2 E1 to_val e = None E E1 E2 E1
......
...@@ -36,18 +36,19 @@ Next Obligation. ...@@ -36,18 +36,19 @@ Next Obligation.
by rewrite (dist_le _ _ _ _ Hr1); last omega. by rewrite (dist_le _ _ _ _ Hr1); last omega.
Qed. Qed.
Next Obligation. Next Obligation.
intros wp E e1 Φ n1 n2 r1 ? Hwp [r2 ?] ?? rf k Ef σ1 ???; setoid_subst. intros wp E e1 Φ n r1 ? Hwp [r2 ?] rf k Ef σ1 ???; setoid_subst.
destruct (Hwp (r2 rf) k Ef σ1) as [Hval Hstep]; rewrite ?assoc; auto. destruct (Hwp (r2 rf) k Ef σ1) as [Hval Hstep]; rewrite ?assoc; auto.
split. split.
- intros v Hv. destruct (Hval v Hv) as [r3 [??]]. - intros v Hv. destruct (Hval v Hv) as [r3 [??]].
exists (r3 r2). rewrite -assoc. eauto using uPred_weaken, cmra_included_l. exists (r3 r2). rewrite -assoc. eauto using uPred_mono, cmra_included_l.
- intros ??. destruct Hstep as [Hred Hpstep]; auto. - intros ??. destruct Hstep as [Hred Hpstep]; auto.
split; [done|]=> e2 σ2 ef ?. split; [done|]=> e2 σ2 ef ?.
edestruct Hpstep as (r3&r3'&?&?&?); eauto. edestruct Hpstep as (r3&r3'&?&?&?); eauto.
exists r3, (r3' r2); split_and?; auto. exists r3, (r3' r2); split_and?; auto.
+ by rewrite assoc -assoc. + by rewrite assoc -assoc.
+ destruct ef; simpl in *; eauto using uPred_weaken, cmra_included_l. + destruct ef; simpl in *; eauto using uPred_mono, cmra_included_l.
Qed. Qed.
Next Obligation. repeat intro; eauto. Qed.
Lemma wp_pre_contractive' n E e Φ1 Φ2 r Lemma wp_pre_contractive' n E e Φ1 Φ2 r
(wp1 wp2 : coPsetC -n> exprC Λ -n> (valC Λ -n> iProp) -n> iProp) : (wp1 wp2 : coPsetC -n> exprC Λ -n> (valC Λ -n> iProp) -n> iProp) :
......
...@@ -63,7 +63,7 @@ Proof. ...@@ -63,7 +63,7 @@ Proof.
destruct (Hwld i (iProp_fold (later_car (P' (S n))))) as (r'&?&?); auto. destruct (Hwld i (iProp_fold (later_car (P' (S n))))) as (r'&?&?); auto.
{ by rewrite HP' -HPiso. } { by rewrite HP' -HPiso. }
assert ({S n} r') by (apply (big_opM_lookup_valid _ rs i); auto). assert ({S n} r') by (apply (big_opM_lookup_valid _ rs i); auto).
exists r'; split; [done|apply HPP', uPred_weaken with n r'; auto]. exists r'; split; [done|]. apply HPP', uPred_closed with n; auto.
Qed. Qed.
Lemma wsat_valid n E σ r : n 0 wsat n E σ r {n} r. Lemma wsat_valid n E σ r : n 0 wsat n E σ r {n} r.
Proof. Proof.
......
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