Commit 3447371d authored by Dan Frumin's avatar Dan Frumin

Simplify some example proofs

parent 752493b6
...@@ -122,7 +122,6 @@ Section CG_Counter. ...@@ -122,7 +122,6 @@ Section CG_Counter.
(* A logically atomic specification for (* A logically atomic specification for
a fine-grained increment with a baked in frame. *) a fine-grained increment with a baked in frame. *)
(* Unfortunately, the precondition is not baked in the rule so you can only use it when your spatial context is empty *)
Lemma bin_log_FG_increment_logatomic R P Γ E K x t τ : Lemma bin_log_FG_increment_logatomic R P Γ E K x t τ :
P - P -
(|={,E}=> n : nat, x ↦ᵢ #n R n (|={,E}=> n : nat, x ↦ᵢ #n R n
......
...@@ -7,6 +7,9 @@ From iris_logrel Require Import logrel examples.counter examples.lock prelude.bi ...@@ -7,6 +7,9 @@ From iris_logrel Require Import logrel examples.counter examples.lock prelude.bi
(** * 5.2 References for name generation *) (** * 5.2 References for name generation *)
(* α. (1 α) × (α α 2) *)
(* ^ new name ^ *)
(* | compare names for equality *)
Definition nameGenTy : type := TExists (TProd (TArrow TUnit (TVar 0)) Definition nameGenTy : type := TExists (TProd (TArrow TUnit (TVar 0))
(TArrow (TVar 0) (TArrow (TVar 0) TBool))). (TArrow (TVar 0) (TArrow (TVar 0) TBool))).
......
...@@ -99,7 +99,7 @@ Section contents. ...@@ -99,7 +99,7 @@ Section contents.
Definition or_inv x : iProp Σ := Definition or_inv x : iProp Σ :=
(x ↦ᵢ #0 x ↦ᵢ #1)%I. (x ↦ᵢ #0 x ↦ᵢ #1)%I.
Definition orN := nroot .@ "orN". Definition orN := nroot .@ "orN".
Ltac close_shoot := iNext; (iLeft + iRight); by iFrame. Ltac close_inv := iNext; (iLeft + iRight); by iFrame.
Lemma assign_safe x : Lemma assign_safe x :
inv orN (or_inv x) inv orN (or_inv x)
...@@ -107,7 +107,7 @@ Section contents. ...@@ -107,7 +107,7 @@ Section contents.
Proof. Proof.
iIntros "#Hinv". iIntros "#Hinv".
iNext. iInv orN as ">[Hx | Hx]" "Hcl"; wp_store; iNext. iInv orN as ">[Hx | Hx]" "Hcl"; wp_store;
(iMod ("Hcl" with "[-]"); first close_shoot); eauto. (iMod ("Hcl" with "[-]"); first close_inv); eauto.
Qed. Qed.
Lemma bin_log_or_commute Δ Γ (v1 v1' v2 v2' : val) : Lemma bin_log_or_commute Δ Γ (v1 v1' v2 v2' : val) :
...@@ -116,13 +116,13 @@ Section contents. ...@@ -116,13 +116,13 @@ Section contents.
{Δ;Γ} or v2 v1 log or v1' v2' : TUnit. {Δ;Γ} or v2 v1 log or v1' v2' : TUnit.
Proof. Proof.
iIntros "Hv1 Hv2". iIntros "Hv1 Hv2".
unlock or. repeat rel_rec_r. repeat rel_rec_l. unlock or; simpl. repeat rel_rec_r. repeat rel_rec_l.
rel_alloc_l as x "Hx". rel_alloc_l as x "Hx".
rel_alloc_r as y "Hy". rel_alloc_r as y "Hy".
repeat rel_let_l. repeat rel_let_r. repeat rel_let_l. repeat rel_let_r.
rel_fork_r as j "Hj". rel_seq_r. rel_fork_r as j "Hj". rel_seq_r.
iMod (inv_alloc orN _ (or_inv x) with "[Hx]") as "#Hinv". iMod (inv_alloc orN _ (or_inv x) with "[Hx]") as "#Hinv";
{ close_shoot. } first close_inv.
rel_fork_l. rel_fork_l.
iModIntro. iSplitR; [ by iApply assign_safe | ]. iModIntro. iSplitR; [ by iApply assign_safe | ].
rel_seq_l. rel_seq_l.
...@@ -130,18 +130,17 @@ Section contents. ...@@ -130,18 +130,17 @@ Section contents.
iInv orN as ">[Hx|Hx]" "Hcl"; iInv orN as ">[Hx|Hx]" "Hcl";
iExists _; iFrame; iModIntro; iNext; iIntros "Hx"; iExists _; iFrame; iModIntro; iNext; iIntros "Hx";
rel_op_l; rel_if_l. rel_op_l; rel_if_l.
+ apply bin_log_related_spec_ctx. + apply bin_log_related_spec_ctx; iDestruct 1 as (ρ1) "#Hρ1".
iDestruct 1 as (ρ1) "#Hρ1". (* TODO: tp tactics should be aware of spec_ctx *)
(* TODO: tp tactics should be aware of that ^ *)
tp_store j. tp_store j.
rel_load_r. rel_load_r.
repeat (rel_pure_r _). repeat (rel_pure_r _).
iMod ("Hcl" with "[-Hv1 Hv2]"); first close_shoot. iMod ("Hcl" with "[-Hv1 Hv2]"); first close_inv.
iApply (bin_log_related_app with "Hv2"). iApply (bin_log_related_app with "Hv2").
iApply bin_log_related_unit. iApply bin_log_related_unit.
+ rel_load_r. + rel_load_r.
repeat (rel_pure_r _). repeat (rel_pure_r _).
iMod ("Hcl" with "[-Hv1 Hv2]"); first close_shoot. iMod ("Hcl" with "[-Hv1 Hv2]"); first close_inv.
iApply (bin_log_related_app with "Hv1"). iApply (bin_log_related_app with "Hv1").
iApply bin_log_related_unit. iApply bin_log_related_unit.
Qed. Qed.
...@@ -173,7 +172,7 @@ Section contents. ...@@ -173,7 +172,7 @@ Section contents.
rel_alloc_l as x "Hx". rel_alloc_l as x "Hx".
repeat rel_let_l. repeat rel_let_l.
iMod (inv_alloc orN _ (or_inv x)%I with "[Hx]") as "#Hinv". iMod (inv_alloc orN _ (or_inv x)%I with "[Hx]") as "#Hinv".
{ close_shoot. } { close_inv. }
rel_fork_l. rel_fork_l.
iModIntro. iSplitR; [ by iApply assign_safe | ]. iModIntro. iSplitR; [ by iApply assign_safe | ].
rel_seq_l. rel_seq_l.
...@@ -181,10 +180,10 @@ Section contents. ...@@ -181,10 +180,10 @@ Section contents.
iInv orN as ">[Hx|Hx]" "Hcl"; iInv orN as ">[Hx|Hx]" "Hcl";
iExists _; iFrame; iModIntro; iNext; iIntros "Hx"; iExists _; iFrame; iModIntro; iNext; iIntros "Hx";
rel_op_l; rel_if_l. rel_op_l; rel_if_l.
+ iMod ("Hcl" with "[-Hlog]"); first close_shoot. + iMod ("Hcl" with "[-Hlog]"); first close_inv.
iApply (bin_log_related_app with "Hlog"). iApply (bin_log_related_app with "Hlog").
iApply bin_log_related_unit. iApply bin_log_related_unit.
+ iMod ("Hcl" with "[-Hlog]"); first close_shoot. + iMod ("Hcl" with "[-Hlog]"); first close_inv.
iApply (bin_log_related_app with "Hlog"). iApply (bin_log_related_app with "Hlog").
iApply bin_log_related_unit. iApply bin_log_related_unit.
Qed. Qed.
...@@ -198,7 +197,7 @@ Section contents. ...@@ -198,7 +197,7 @@ Section contents.
rel_alloc_l as x "Hx". rel_alloc_l as x "Hx".
repeat rel_let_l. repeat rel_let_l.
iMod (inv_alloc orN _ (or_inv x)%I with "[Hx]") as "#Hinv". iMod (inv_alloc orN _ (or_inv x)%I with "[Hx]") as "#Hinv".
{ close_shoot. } { close_inv. }
rel_fork_l. rel_fork_l.
iModIntro. iSplitR; [ by iApply assign_safe | ]. iModIntro. iSplitR; [ by iApply assign_safe | ].
rel_seq_l. rel_seq_l.
...@@ -206,10 +205,10 @@ Section contents. ...@@ -206,10 +205,10 @@ Section contents.
iInv orN as ">[Hx|Hx]" "Hcl"; iInv orN as ">[Hx|Hx]" "Hcl";
iExists _; iFrame; iModIntro; iNext; iIntros "Hx"; iExists _; iFrame; iModIntro; iNext; iIntros "Hx";
rel_op_l; rel_if_l. rel_op_l; rel_if_l.
+ iMod ("Hcl" with "[-Hlog]"); first close_shoot. + iMod ("Hcl" with "[-Hlog]"); first close_inv.
iApply (bin_log_related_app with "Hlog"). iApply (bin_log_related_app with "Hlog").
iApply bin_log_related_unit. iApply bin_log_related_unit.
+ iMod ("Hcl" with "[-Hlog]"); first close_shoot. + iMod ("Hcl" with "[-Hlog]"); first close_inv.
rel_apply_l bot_l. rel_apply_l bot_l.
Qed. Qed.
...@@ -236,7 +235,7 @@ Section contents. ...@@ -236,7 +235,7 @@ Section contents.
repeat rel_let_l. repeat rel_let_r. repeat rel_let_l. repeat rel_let_r.
rel_fork_r as j "Hj". rel_seq_r. rel_fork_r as j "Hj". rel_seq_r.
iMod (inv_alloc orN _ (or_inv x) with "[Hx]") as "#Hinv". iMod (inv_alloc orN _ (or_inv x) with "[Hx]") as "#Hinv".
{ close_shoot. } { close_inv. }
rel_fork_l. rel_fork_l.
iModIntro. iSplitR; [ by iApply assign_safe | ]. iModIntro. iSplitR; [ by iApply assign_safe | ].
rel_seq_l. rel_seq_l.
...@@ -250,14 +249,14 @@ Section contents. ...@@ -250,14 +249,14 @@ Section contents.
rel_let_r. rel_fork_r as k "Hk". rel_let_r. rel_fork_r as k "Hk".
rel_seq_r. rel_load_r. rel_seq_r. rel_load_r.
repeat (rel_pure_r _). repeat (rel_pure_r _).
iMod ("Hcl" with "[-Hv1 Hv2 Hv3]") as "_"; first close_shoot. iMod ("Hcl" with "[-Hv1 Hv2 Hv3]") as "_"; first close_inv.
iApply (bin_log_related_app with "Hv1"). iApply (bin_log_related_app with "Hv1").
iApply bin_log_related_unit. iApply bin_log_related_unit.
- iMod ("Hcl" with "[-Hv1 Hv2 Hv3 Hy Hj]") as "_"; first close_shoot. - iMod ("Hcl" with "[-Hv1 Hv2 Hv3 Hy Hj]") as "_"; first close_inv.
rel_alloc_l as x' "Hx'". rel_let_l. rel_alloc_l as x' "Hx'". rel_let_l.
iClear "Hinv". iClear "Hinv".
iMod (inv_alloc orN _ (or_inv x') with "[Hx']") as "#Hinv". iMod (inv_alloc orN _ (or_inv x') with "[Hx']") as "#Hinv".
{ close_shoot. } { close_inv. }
rel_fork_l. rel_fork_l.
iModIntro. iSplitR; [ by iApply assign_safe | ]. iModIntro. iSplitR; [ by iApply assign_safe | ].
apply bin_log_related_spec_ctx. apply bin_log_related_spec_ctx.
...@@ -274,12 +273,12 @@ Section contents. ...@@ -274,12 +273,12 @@ Section contents.
tp_store k. tp_store k.
rel_load_r. rel_load_r.
repeat (rel_pure_r _). repeat (rel_pure_r _).
iMod ("Hcl" with "[-Hv1 Hv2 Hv3]") as "_"; first close_shoot. iMod ("Hcl" with "[-Hv1 Hv2 Hv3]") as "_"; first close_inv.
iApply (bin_log_related_app with "Hv2"). iApply (bin_log_related_app with "Hv2").
iApply bin_log_related_unit. iApply bin_log_related_unit.
+ tp_store j. + tp_store j.
rel_load_r; repeat (rel_pure_r _). rel_load_r; repeat (rel_pure_r _).
iMod ("Hcl" with "[-Hv1 Hv2 Hv3]") as "_"; first close_shoot. iMod ("Hcl" with "[-Hv1 Hv2 Hv3]") as "_"; first close_inv.
iApply (bin_log_related_app with "Hv3"). iApply (bin_log_related_app with "Hv3").
iApply bin_log_related_unit. iApply bin_log_related_unit.
Qed. Qed.
......
This diff is collapsed.
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