Skip to content
Snippets Groups Projects
Commit c83f4824 authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan
Browse files

Better ElimAcc instances for monPred_at.

parent 066354af
No related branches found
No related tags found
No related merge requests found
From iris.proofmode Require Import tactics monpred. From iris.proofmode Require Import tactics monpred.
From iris.base_logic.lib Require Import invariants.
Set Ltac Backtrace. Set Ltac Backtrace.
Section tests. Section tests.
...@@ -168,3 +169,27 @@ Section tests. ...@@ -168,3 +169,27 @@ Section tests.
Proof. iIntros "HP". iExists _. Fail iFrame "HP". Abort. Proof. iIntros "HP". iExists _. Fail iFrame "HP". Abort.
End tests. End tests.
Section tests_iprop.
Context {I : biIndex} `{!invG Σ}.
Local Notation monPred := (monPred I (iPropI Σ)).
Implicit Types P : iProp Σ.
Lemma test_iInv_0 N P:
embed (B:=monPred) (inv N (<pers> P)) ={}=∗ ⎡▷ P⎤.
Proof.
iIntros "#H".
iInv N as "#H2". Show.
iModIntro. iSplit=>//. iModIntro. iModIntro; auto.
Qed.
Lemma test_iInv_0_with_close N P:
embed (B:=monPred) (inv N (<pers> P)) ={}=∗ ⎡▷ P⎤.
Proof.
iIntros "#H".
iInv N as "#H2" "Hclose". Show.
iMod ("Hclose" with "H2").
iModIntro. iModIntro. by iNext.
Qed.
End tests_iprop.
...@@ -557,34 +557,30 @@ Global Instance elim_modal_at_fupd_hyp `{BiFUpd PROP} φ p p' E1 E2 P 𝓟 𝓟' ...@@ -557,34 +557,30 @@ Global Instance elim_modal_at_fupd_hyp `{BiFUpd PROP} φ p p' E1 E2 P 𝓟 𝓟'
ElimModal φ p p' ((|={E1,E2}=> P) i) 𝓟' 𝓠 𝓠'. ElimModal φ p p' ((|={E1,E2}=> P) i) 𝓟' 𝓠 𝓠'.
Proof. by rewrite /MakeMonPredAt /ElimModal monPred_at_fupd=><-. Qed. Proof. by rewrite /MakeMonPredAt /ElimModal monPred_at_fupd=><-. Qed.
(* This instances are awfully specific, but that's what is needed. *) Global Instance elim_acc_at_None `{BiFUpd PROP} {X} E1 E2 E3 E4 α α' β β' P P'x V:
Global Instance elim_acc_at_fupd `{BiFUpd PROP} {X : Type} E1 E2 E ( x, MakeEmbed (α x) (α' x)) ( x, MakeEmbed (β x) (β' x))
M1 M2 α β ( : X option PROP) Q (Q' : X monPred) i : ElimAcc (X:=X) (fupd E1 E2) (fupd E3 E4) α' β' (λ _, None) P P'x
ElimAcc (X:=X) M1 M2 α β (|={E1,E}=> Q i) ElimAcc (X:=X) (fupd E1 E2) (fupd E3 E4) α β (λ _, None) (P V) (λ x, P'x x V).
(λ x, |={E2}=> β x ( x -∗? |={E1,E}=> Q' x i))%I Proof.
ElimAcc (X:=X) M1 M2 α β ((|={E1,E}=> Q) i) rewrite /ElimAcc /MakeEmbed. iIntros ( HEA) "Hinner Hacc".
(λ x, (|={E2}=> β x iApply (HEA with "[Hinner]").
(match x with Some 𝓟 => Some 𝓟 | None => None end -∗? - iIntros (x). iSpecialize ("Hinner" $! x). rewrite -. by iIntros (? <-).
|={E1,E}=> Q' x)) i)%I - iMod "Hacc". iDestruct "Hacc" as (x) "[Hα Hclose]". iModIntro. iExists x.
| 1. rewrite - -. iFrame. iIntros (? _) "Hβ". by iApply "Hclose".
Proof. Qed.
rewrite /ElimAcc monPred_at_fupd=><-. apply bi.forall_mono=>x. Global Instance elim_acc_at_Some `{BiFUpd PROP} {X} E1 E2 E3 E4 α α' β β' γ γ' P P'x V:
destruct ( x); simpl. ( x, MakeEmbed (α x) (α' x))
- rewrite monPred_at_fupd monPred_at_sep monPred_wand_force monPred_at_fupd !monPred_at_embed //. ( x, MakeEmbed (β x) (β' x))
- rewrite monPred_at_fupd monPred_at_sep monPred_at_fupd !monPred_at_embed //. ( x, MakeEmbed (γ x) (γ' x))
Qed. ElimAcc (X:=X) (fupd E1 E2) (fupd E3 E4) α' β' (λ x, Some (γ' x)) P P'x
(* A separate, higher-priority instance for unit because otherwise unification ElimAcc (X:=X) (fupd E1 E2) (fupd E3 E4) α β (λ x, Some (γ x)) (P V) (λ x, P'x x V).
fails. *) Proof.
Global Instance elim_acc_at_fupd_unit `{BiFUpd PROP} E1 E2 E rewrite /ElimAcc /MakeEmbed. iIntros ( HEA) "Hinner Hacc".
M1 M2 α β Q Q' i : iApply (HEA with "[Hinner]").
ElimAcc (X:=unit) M1 M2 α β (|={E1,E}=> Q i) - iIntros (x). iSpecialize ("Hinner" $! x). rewrite -. by iIntros (? <-).
(λ x, |={E2}=> β x ( x -∗? |={E1,E}=> Q' i))%I - iMod "Hacc". iDestruct "Hacc" as (x) "[Hα Hclose]". iModIntro. iExists x.
ElimAcc (X:=unit) M1 M2 α β ((|={E1,E}=> Q) i) rewrite - - -. iFrame. iIntros (? _) "Hβ /=". by iApply "Hclose".
(λ x, (|={E2}=> β x Qed.
(match x with Some 𝓟 => Some 𝓟 | None => None end -∗?
|={E1,E}=> Q')) i)%I
| 0.
Proof. exact: elim_acc_at_fupd. Qed.
Global Instance add_modal_at_fupd_goal `{BiFUpd PROP} E1 E2 𝓟 𝓟' Q i : Global Instance add_modal_at_fupd_goal `{BiFUpd PROP} E1 E2 𝓟 𝓟' Q i :
AddModal 𝓟 𝓟' (|={E1,E2}=> Q i) AddModal 𝓟 𝓟' ((|={E1,E2}=> Q) i). AddModal 𝓟 𝓟' (|={E1,E2}=> Q i) AddModal 𝓟 𝓟' ((|={E1,E2}=> Q) i).
...@@ -615,5 +611,4 @@ Proof. ...@@ -615,5 +611,4 @@ Proof.
setoid_rewrite <-Hout. setoid_rewrite <-Hout.
iIntros (?) "(?&?&HQ')". iApply H; [done|]. iFrame. iIntros (x) "?". by iApply "HQ'". iIntros (?) "(?&?&HQ')". iApply H; [done|]. iFrame. iIntros (x) "?". by iApply "HQ'".
Qed. Qed.
End sbi. End sbi.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment