1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
From iris.bi.lib Require Import fractional.
From iris.proofmode Require Import tactics monpred.
From iris.base_logic.lib Require Import invariants ghost_var.
From iris.prelude Require Import options.
Unset Mangle Names.
Section tests.
Context {I : biIndex} {PROP : bi}.
Local Notation monPred := (monPred I PROP).
Local Notation monPredI := (monPredI I PROP).
Implicit Types P Q R : monPred.
Implicit Types π π π‘ : PROP.
Implicit Types i j : I.
Lemma test0 P : P -β P.
Proof. iIntros "$". Qed.
Lemma test_iStartProof_1 P : P -β P.
Proof. iStartProof. iStartProof. iIntros "$". Qed.
Lemma test_iStartProof_2 P : P -β P.
Proof. iStartProof monPred. iStartProof monPredI. iIntros "$". Qed.
Lemma test_iStartProof_3 P : P -β P.
Proof. iStartProof monPredI. iStartProof monPredI. iIntros "$". Qed.
Lemma test_iStartProof_4 P : P -β P.
Proof. iStartProof monPredI. iStartProof monPred. iIntros "$". Qed.
Lemma test_iStartProof_5 P : P -β P.
Proof. iStartProof PROP. iIntros (i) "$". Qed.
Lemma test_iStartProof_6 P : P β£β’ P.
Proof. iStartProof PROP. iIntros (i). iSplit; iIntros "$". Qed.
Lemma test_iStartProof_7 `{!BiInternalEq PROP} P : β’@{monPredI} P β‘ P.
Proof. iStartProof PROP. done. Qed.
Lemma test_intowand_1 P Q : (P -β Q) -β P -β Q.
Proof.
iStartProof PROP. iIntros (i) "HW". Show.
iIntros (j ->) "HP". Show. by iApply "HW".
Qed.
Lemma test_intowand_2 P Q : (P -β Q) -β P -β Q.
Proof.
iStartProof PROP. iIntros (i) "HW". iIntros (j ->) "HP".
iSpecialize ("HW" with "[HP //]"). done.
Qed.
Lemma test_intowand_3 P Q : (P -β Q) -β P -β Q.
Proof.
iStartProof PROP. iIntros (i) "HW". iIntros (j ->) "HP".
iSpecialize ("HW" with "HP"). done.
Qed.
Lemma test_intowand_4 P Q : (P -β Q) -β β· P -β β· Q.
Proof.
iStartProof PROP. iIntros (i) "HW". iIntros (j ->) "HP". by iApply "HW".
Qed.
Lemma test_intowand_5 P Q : (P -β Q) -β β· P -β β· Q.
Proof.
iStartProof PROP. iIntros (i) "HW". iIntros (j ->) "HP".
iSpecialize ("HW" with "HP"). done.
Qed.
Lemma test_apply_in_elim (P : monPredI) (i : I) : monPred_in i -β β‘ P i β€ β P.
Proof. iIntros. by iApply monPred_in_elim. Qed.
Lemma test_iStartProof_forall_1 (Ξ¦ : nat β monPredI) : β n, Ξ¦ n -β Ξ¦ n.
Proof.
iStartProof PROP. iIntros (n i) "$".
Qed.
Lemma test_iStartProof_forall_2 (Ξ¦ : nat β monPredI) : β n, Ξ¦ n -β Ξ¦ n.
Proof.
iStartProof. iIntros (n) "$".
Qed.
Lemma test_embed_wand (P Q : PROP) : (β‘Pβ€ -β β‘Qβ€) β’@{monPredI} β‘P -β Qβ€.
Proof.
iIntros "H HP". by iApply "H".
Qed.
Lemma test_objectively `{!BiPersistentlyForall PROP} P Q :
<obj> emp -β <obj> P -β <obj> Q -β <obj> (P β Q).
Proof. iIntros "#? HP HQ". iModIntro. by iSplitL "HP". Qed.
Lemma test_objectively_absorbing `{!BiPersistentlyForall PROP} P Q R `{!Absorbing P} :
<obj> emp -β <obj> P -β <obj> Q -β R -β <obj> (P β Q).
Proof. iIntros "#? HP HQ HR". iModIntro. by iSplitL "HP". Qed.
Lemma test_objectively_affine `{!BiPersistentlyForall PROP} P Q R `{!Affine R} :
<obj> emp -β <obj> P -β <obj> Q -β R -β <obj> (P β Q).
Proof. iIntros "#? HP HQ HR". iModIntro. by iSplitL "HP". Qed.
Lemma test_iModIntro_embed P `{!Affine Q} π π :
β‘ P -β Q -β β‘πβ€ -β β‘π β€ -β β‘ π β π β€.
Proof. iIntros "#H1 _ H2 H3". iModIntro. iFrame. Qed.
Lemma test_iModIntro_embed_objective P `{!Objective Q} π π :
β‘ P -β Q -β β‘πβ€ -β β‘π β€ -β β‘ β i, π β π β Q i β€.
Proof. iIntros "#H1 H2 H3 H4". iModIntro. Show. iFrame. Qed.
Lemma test_iModIntro_embed_nested P π π :
β‘ P -β β‘β πβ€ -β β‘β π β€ -β β‘ β (π β π ) β€.
Proof. iIntros "#H1 H2 H3". iModIntro β‘ _ β€%I. by iSplitL "H2". Qed.
Lemma test_into_wand_embed π π :
(π -β β π ) β
β‘πβ€ β’@{monPredI} β β‘π β€.
Proof.
iIntros (HPQ) "HP".
iMod (HPQ with "[-]") as "$"; last by auto.
iAssumption.
Qed.
Lemma test_monPred_at_and_pure P i j :
(monPred_in j β§ P) i β’ β j β i β β§ P i.
Proof.
iDestruct 1 as "[% $]". done.
Qed.
Lemma test_monPred_at_sep_pure P i j :
(monPred_in j β <absorb> P) i β’ β j β i β β§ <absorb> P i.
Proof.
iDestruct 1 as "[% ?]". auto.
Qed.
Context (FU : BiFUpd PROP).
Lemma test_apply_fupd_intro_mask_subseteq E1 E2 P :
E2 β E1 β P -β |={E1,E2}=> |={E2,E1}=> P.
Proof. iIntros. by iApply @fupd_mask_intro_subseteq. Qed.
Lemma test_apply_fupd_mask_subseteq E1 E2 P :
E2 β E1 β P -β |={E1,E2}=> |={E2,E1}=> P.
Proof. iIntros. iFrame. by iApply @fupd_mask_subseteq. Qed.
Lemma test_iFrame_embed_persistent (P : PROP) (Q: monPred) :
Q β β‘ β‘Pβ€ β’ Q β β‘P β Pβ€.
Proof.
iIntros "[$ #HP]". iFrame "HP".
Qed.
Lemma test_iNext_Bi P :
β· P β’@{monPredI} β· P.
Proof. iIntros "H". by iNext. Qed.
(** Test monPred_at framing *)
Lemma test_iFrame_monPred_at_wand (P Q : monPred) i :
P i -β (Q -β P) i.
Proof. iIntros "$". Show. Abort.
Program Definition monPred_id (R : monPred) : monPred :=
MonPred (Ξ» V, R V) _.
Next Obligation. intros ? ???. eauto. Qed.
Lemma test_iFrame_monPred_id (Q R : monPred) i :
Q i β R i -β (Q β monPred_id R) i.
Proof.
iIntros "(HQ & HR)". iFrame "HR". iAssumption.
Qed.
Lemma test_iFrame_rel P i j ij :
IsBiIndexRel i ij β IsBiIndexRel j ij β
P i -β P j -β P ij β P ij.
Proof. iIntros (??) "HPi HPj". iFrame. Qed.
Lemma test_iFrame_later_rel `{!BiAffine PROP} P i j :
IsBiIndexRel i j β
β· (P i) -β (β· P) j.
Proof. iIntros (?) "?". iFrame. Qed.
Lemma test_iFrame_laterN n P i :
β·^n (P i) -β (β·^n P) i.
Proof. iIntros "?". iFrame. Qed.
Lemma test_iFrame_quantifiers P i :
P i -β (β _:(), β _:(), P) i.
Proof. iIntros "?". iFrame. Show. iIntros ([]). iExists (). iEmpIntro. Qed.
Lemma test_iFrame_embed (P : PROP) i :
P -β (embed (B:=monPredI) P) i.
Proof. iIntros "$". Qed.
(* Make sure search doesn't diverge on an evar *)
Lemma test_iFrame_monPred_at_evar (P : monPred) i j :
P i -β β Q, (Q j).
Proof. iIntros "HP". iExists _. Fail iFrame "HP". Abort.
End tests.
Section tests_iprop.
Context {I : biIndex} `{!invGS_gen hlc Ξ£}.
Local Notation monPred := (monPred I (iPropI Ξ£)).
Local Notation monPredI := (monPredI I (iPropI Ξ£)).
Implicit Types P Q R : monPred.
Implicit Types π π π‘ : iProp Ξ£.
Lemma test_iInv_0 N π :
embed (B:=monPred) (inv N (<pers> π)) ={β€}=β β‘β· πβ€.
Proof.
iIntros "#H".
iInv N as "#H2". Show.
iModIntro. iSplit=>//. iModIntro. iModIntro; auto.
Qed.
Lemma test_iInv_0_with_close N π :
embed (B:=monPred) (inv N (<pers> π)) ={β€}=β β‘β· πβ€.
Proof.
iIntros "#H".
iInv N as "#H2" "Hclose". Show.
iMod ("Hclose" with "H2").
iModIntro. iModIntro. by iNext.
Qed.
Lemma test_iPoseProof `{inG Ξ£ A} P Ξ³ (x y : A) :
x ~~> y β P β β‘own Ξ³ xβ€ ==β β‘own Ξ³ yβ€.
Proof.
iIntros (?) "[_ HΞ³]".
iPoseProof (own_update with "HΞ³") as "H"; first done.
by iMod "H".
Qed.
Lemma test_embed_fractional `{!ghost_varG Ξ£ A} Ξ³ q (a : A) :
β‘ghost_var Ξ³ q aβ€ β’@{monPredI} β‘ghost_var Ξ³ (q/2) aβ€ β β‘ghost_var Ξ³ (q/2) aβ€.
Proof. iIntros "[$ $]". Qed.
Lemma test_embed_combine `{!ghost_varG Ξ£ A} Ξ³ q (a1 a2 : A) :
β· β‘ghost_var Ξ³ (q/2) a1β€ β β· β‘ghost_var Ξ³ (q/2) a2β€ β’@{monPredI}
β·β‘ghost_var Ξ³ q a1β€ β β· βa1 = a2β.
Proof.
iIntros "[H1 H2]".
iCombine "H1 H2" as "$" gives "#H". iNext.
by iDestruct "H" as %[_ ->].
Qed.
End tests_iprop.
|