Commit 2af5dfe1 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Make `iIntros (?)` introduce ∀s/pures under ▷ and □ modalities.

I have reimplemented the tactic for introduction of ∀s/pures using type
classes, which directly made it much more modular.
parent c5045145
...@@ -24,7 +24,7 @@ Section core. ...@@ -24,7 +24,7 @@ Section core.
Implicit Types P Q : uPred M. Implicit Types P Q : uPred M.
Lemma coreP_intro P : P - coreP P. Lemma coreP_intro P : P - coreP P.
Proof. iIntros "HP". by iIntros (Q HQ ->). Qed. Proof. rewrite /coreP. iIntros "HP". by iIntros (Q HQ ->). Qed.
Global Instance coreP_persistent P : PersistentP (coreP P). Global Instance coreP_persistent P : PersistentP (coreP P).
Proof. rewrite /coreP. apply _. Qed. Proof. rewrite /coreP. apply _. Qed.
......
...@@ -721,6 +721,32 @@ Global Instance into_forall_always {A} P (Φ : A → uPred M) : ...@@ -721,6 +721,32 @@ Global Instance into_forall_always {A} P (Φ : A → uPred M) :
IntoForall P Φ IntoForall ( P) (λ a, (Φ a))%I. IntoForall P Φ IntoForall ( P) (λ a, (Φ a))%I.
Proof. rewrite /IntoForall=> HP. by rewrite HP always_forall. Qed. Proof. rewrite /IntoForall=> HP. by rewrite HP always_forall. Qed.
(* FromForall *)
Global Instance from_forall_forall {A} (Φ : A uPred M) :
FromForall ( x, Φ x) Φ.
Proof. done. Qed.
Global Instance from_forall_pure {A} (φ : A Prop) :
@FromForall M A ( a : A, φ a) (λ a, φ a )%I.
Proof. by rewrite /FromForall pure_forall. Qed.
Global Instance from_forall_impl_pure P Q φ :
IntoPureT P φ FromForall (P Q) (λ _ : φ, Q)%I.
Proof.
intros (φ'&->&?). by rewrite /FromForall -pure_impl_forall (into_pure P).
Qed.
Global Instance from_forall_wand_pure P Q φ :
IntoPureT P φ FromForall (P - Q) (λ _ : φ, Q)%I.
Proof.
intros (φ'&->&?). rewrite /FromForall -pure_impl_forall.
by rewrite always_impl_wand (into_pure P).
Qed.
Global Instance from_forall_always {A} P (Φ : A uPred M) :
FromForall P Φ FromForall ( P) (λ a, (Φ a))%I.
Proof. rewrite /FromForall=> <-. by rewrite always_forall. Qed.
Global Instance from_forall_later {A} P (Φ : A uPred M) :
FromForall P Φ FromForall ( P) (λ a, (Φ a))%I.
Proof. rewrite /FromForall=> <-. by rewrite later_forall. Qed.
(* FromModal *) (* FromModal *)
Global Instance from_modal_later P : FromModal ( P) P. Global Instance from_modal_later P : FromModal ( P) P.
Proof. apply later_intro. Qed. Proof. apply later_intro. Qed.
......
...@@ -206,6 +206,11 @@ Class IntoForall {M A} (P : uPred M) (Φ : A → uPred M) := ...@@ -206,6 +206,11 @@ Class IntoForall {M A} (P : uPred M) (Φ : A → uPred M) :=
Arguments into_forall {_ _} _ _ {_}. Arguments into_forall {_ _} _ _ {_}.
Hint Mode IntoForall + - ! - : typeclass_instances. Hint Mode IntoForall + - ! - : typeclass_instances.
Class FromForall {M A} (P : uPred M) (Φ : A uPred M) :=
from_forall : ( x, Φ x) P.
Arguments from_forall {_ _} _ _ {_}.
Hint Mode FromForall + - ! - : typeclass_instances.
Class FromModal {M} (P Q : uPred M) := from_modal : Q P. Class FromModal {M} (P Q : uPred M) := from_modal : Q P.
Arguments from_modal {_} _ _ {_}. Arguments from_modal {_} _ _ {_}.
Hint Mode FromModal + ! - : typeclass_instances. Hint Mode FromModal + ! - : typeclass_instances.
......
...@@ -512,13 +512,7 @@ Proof. ...@@ -512,13 +512,7 @@ Proof.
rewrite (_ : P = ?false P) // (into_persistentP false P). rewrite (_ : P = ?false P) // (into_persistentP false P).
by rewrite right_id always_and_sep_l wand_elim_r. by rewrite right_id always_and_sep_l wand_elim_r.
Qed. Qed.
Lemma tac_pure_impl_intro Δ (φ ψ : Prop) :
(φ Δ ⌜ψ⌝) Δ ⌜φ ψ⌝.
Proof. intros. rewrite pure_impl. by apply impl_intro_l, pure_elim_l. Qed.
Lemma tac_impl_intro_pure Δ P φ Q : IntoPure P φ (φ Δ Q) Δ P Q.
Proof.
intros. by apply impl_intro_l; rewrite (into_pure P); apply pure_elim_l.
Qed.
Lemma tac_impl_intro_drop Δ P Q : (Δ Q) Δ P Q. Lemma tac_impl_intro_drop Δ P Q : (Δ Q) Δ P Q.
Proof. intros. apply impl_intro_l. by rewrite and_elim_r. Qed. Proof. intros. apply impl_intro_l. by rewrite and_elim_r. Qed.
...@@ -863,12 +857,11 @@ Proof. ...@@ -863,12 +857,11 @@ Proof.
Qed. Qed.
(** * Forall *) (** * Forall *)
Lemma tac_forall_intro {A} Δ (Φ : A uPred M) : ( a, Δ Φ a) Δ a, Φ a. Lemma tac_forall_intro {A} Δ (Φ : A uPred M) Q :
Proof. apply forall_intro. Qed. FromForall Q Φ
( a, Δ Φ a)
Lemma tac_pure_forall_intro {A} Δ (φ : A Prop) : Δ Q.
( a, Δ ⌜φ a) Δ a, φ a. Proof. rewrite /FromForall=> <-. apply forall_intro. Qed.
Proof. intros. rewrite pure_forall. by apply forall_intro. Qed.
Lemma tac_forall_specialize {A} Δ Δ' i p P (Φ : A uPred M) Q : Lemma tac_forall_specialize {A} Δ Δ' i p P (Φ : A uPred M) Q :
envs_lookup i Δ = Some (p, P) IntoForall P Φ envs_lookup i Δ = Some (p, P) IntoForall P Φ
......
...@@ -284,21 +284,15 @@ Tactic Notation "iFrame" "(" constr(t1) constr(t2) constr(t3) constr(t4) ...@@ -284,21 +284,15 @@ Tactic Notation "iFrame" "(" constr(t1) constr(t2) constr(t3) constr(t4)
(** * Basic introduction tactics *) (** * Basic introduction tactics *)
Local Tactic Notation "iIntro" "(" simple_intropattern(x) ")" := Local Tactic Notation "iIntro" "(" simple_intropattern(x) ")" :=
try iStartProof; try iStartProof;
try first lazymatch goal with
[(* (∀ _, _) *) apply tac_forall_intro | |- _ _ =>
|(* (?P → _) *) eapply tac_impl_intro_pure; eapply tac_forall_intro;
[apply _ ||
let P := match goal with |- IntoPure ?P _ => P end in
fail "iIntro:" P "not pure"
|]
|(* (?P -∗ _) *) eapply tac_wand_intro_pure;
[apply _ || [apply _ ||
let P := match goal with |- IntoPure ?P _ => P end in let P := match goal with |- FromForall ?P _ => P end in
fail "iIntro:" P "not pure" fail "iIntro: cannot turn" P "into a universal quantifier"
|] |lazy beta; intros x]
|(* ⌜∀ _, _⌝ *) apply tac_pure_forall_intro | |- _ => intros x
|(* ⌜_ → _⌝ *) apply tac_pure_impl_intro]; end.
intros x.
Local Tactic Notation "iIntro" constr(H) := Local Tactic Notation "iIntro" constr(H) :=
iStartProof; iStartProof;
......
...@@ -221,6 +221,14 @@ Qed. ...@@ -221,6 +221,14 @@ Qed.
Lemma test_iIntros_let P : Lemma test_iIntros_let P :
Q, let R := True%I in P - R - Q - P Q. Q, let R := True%I in P - R - Q - P Q.
Proof. iIntros (Q R) "$ HR $". Qed. Proof. iIntros (Q R) "$ HR $". Qed.
Lemma test_iIntros_modalities P :
( x : nat, x = 0 - x = 0 False - P - P)%I.
Proof.
iIntros (x ??).
iIntros "* **". (* Test that fast intros do not work under modalities *)
iIntros ([]).
Qed.
End tests. End tests.
Section more_tests. Section more_tests.
......
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