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

Simplify some example proofs

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