Skip to content
Snippets Groups Projects
Commit b90b85b0 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Make iIntros work when the implication is hidden behind a definition.

parent 2539f335
No related branches found
No related tags found
No related merge requests found
...@@ -645,43 +645,41 @@ Tactic Notation "iNext":= ...@@ -645,43 +645,41 @@ Tactic Notation "iNext":=
apply _ || fail "iNext:" P "does not contain laters"|]. apply _ || fail "iNext:" P "does not contain laters"|].
(** * Introduction tactic *) (** * Introduction tactic *)
Local Tactic Notation "iIntro" "{" simple_intropattern(x) "}" := Local Tactic Notation "iIntro" "{" simple_intropattern(x) "}" := first
lazymatch goal with [ (* (∀ _, _) *) apply tac_forall_intro; intros x
| |- _ ( _, _) => apply tac_forall_intro; intros x | (* (?P → _) *) eapply tac_impl_intro_pure;
| |- _ (?P _) => [let P := match goal with |- ToPure ?P _ => P end in
eapply tac_impl_intro_pure; apply _ || fail "iIntro:" P "not pure"
[apply _ || fail "iIntro:" P "not pure"|]; intros x |intros x]
| |- _ (?P -★ _) => | (* (?P -★ _) *) eapply tac_wand_intro_pure;
eapply tac_wand_intro_pure; [let P := match goal with |- ToPure ?P _ => P end in
[apply _ || fail "iIntro:" P "not pure"|]; intros x apply _ || fail "iIntro:" P "not pure"
| |- _ => intros x |intros x]
end. |intros x].
Local Tactic Notation "iIntro" constr(H) := Local Tactic Notation "iIntro" constr(H) := first
lazymatch goal with [ (* (?Q → _) *)
| |- _ (?Q _) =>
eapply tac_impl_intro with _ H; (* (i:=H) *) eapply tac_impl_intro with _ H; (* (i:=H) *)
[reflexivity || fail "iIntro: introducing " H ":" Q [reflexivity || fail 1 "iIntro: introducing" H
"into non-empty spatial context" "into non-empty spatial context"
|env_cbv; reflexivity || fail "iIntro:" H "not fresh"|] |env_cbv; reflexivity || fail "iIntro:" H "not fresh"|]
| |- _ (_ -★ _) => | (* (_ -★ _) *)
eapply tac_wand_intro with _ H; (* (i:=H) *) eapply tac_wand_intro with _ H; (* (i:=H) *)
[env_cbv; reflexivity || fail "iIntro:" H "not fresh"|] [env_cbv; reflexivity || fail 1 "iIntro:" H "not fresh"|]
| _ => fail "iIntro: nothing to introduce" | fail 1 "iIntro: nothing to introduce" ].
end.
Local Tactic Notation "iIntro" "#" constr(H) := Local Tactic Notation "iIntro" "#" constr(H) := first
lazymatch goal with [ (* (?P → _) *)
| |- _ (?P _) =>
eapply tac_impl_intro_persistent with _ H _; (* (i:=H) *) eapply tac_impl_intro_persistent with _ H _; (* (i:=H) *)
[apply _ || fail "iIntro: " P " not persistent" [let P := match goal with |- ToPersistentP ?P _ => P end in
|env_cbv; reflexivity || fail "iIntro:" H "not fresh"|] apply _ || fail 1 "iIntro: " P " not persistent"
| |- _ (?P -★ _) => |env_cbv; reflexivity || fail 1 "iIntro:" H "not fresh"|]
| (* (?P -★ _) *)
eapply tac_wand_intro_persistent with _ H _; (* (i:=H) *) eapply tac_wand_intro_persistent with _ H _; (* (i:=H) *)
[apply _ || fail "iIntro: " P " not persistent" [let P := match goal with |- ToPersistentP ?P _ => P end in
|env_cbv; reflexivity || fail "iIntro:" H "not fresh"|] apply _ || fail 1 "iIntro: " P " not persistent"
| _ => fail "iIntro: nothing to introduce" |env_cbv; reflexivity || fail 1 "iIntro:" H "not fresh"|]
end. | fail 1 "iIntro: nothing to introduce" ].
Tactic Notation "iIntros" constr(pat) := Tactic Notation "iIntros" constr(pat) :=
let rec go pats := let rec go pats :=
......
...@@ -44,4 +44,10 @@ Qed. ...@@ -44,4 +44,10 @@ Qed.
Lemma demo_3 (M : cmraT) (P1 P2 P3 : uPred M) : Lemma demo_3 (M : cmraT) (P1 P2 P3 : uPred M) :
(P1 P2 P3) ( P1 (P2 x, (P3 x = 0) P3)). (P1 P2 P3) ( P1 (P2 x, (P3 x = 0) P3)).
Proof. iIntros "($ & $ & H)". iFrame "H". iNext. by iExists 0. Qed. Proof. iIntros "($ & $ & H)". iFrame "H". iNext. by iExists 0. Qed.
\ No newline at end of file
Definition foo {M} (P : uPred M) := (P P)%I.
Definition bar {M} : uPred M := ( P, foo P)%I.
Lemma demo_4 (M : cmraT) : True @bar M.
Proof. iIntros {P} "HP". done. Qed.
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