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

Split `iSpecializeCore` into two parts to improve reuse.

parent 7b1face0
No related branches found
No related tags found
1 merge request!66Generalized proofmode
...@@ -559,48 +559,54 @@ introduction pattern, which will be coerced into [true] when it solely contains ...@@ -559,48 +559,54 @@ introduction pattern, which will be coerced into [true] when it solely contains
In case the specialization pattern in [t] states that the modality of the goal In case the specialization pattern in [t] states that the modality of the goal
should be kept for one of the premises (i.e. [>[H1 .. Hn]] is used) then [p] should be kept for one of the premises (i.e. [>[H1 .. Hn]] is used) then [p]
defaults to [false] (i.e. spatial hypotheses are not preserved). *) defaults to [false] (i.e. spatial hypotheses are not preserved). *)
Tactic Notation "iSpecializeCore" open_constr(t) "as" constr(p) := Tactic Notation "iSpecializeCore" open_constr(H)
"with" open_constr(xs) open_constr(pat) "as" constr(p) :=
let p := intro_pat_persistent p in let p := intro_pat_persistent p in
let t := let pat := spec_pat.parse pat in
match type of t with let H :=
| string => constr:(ITrm (INamed t) hnil "") lazymatch type of H with
| ident => constr:(ITrm t hnil "") | string => constr:(INamed H)
| _ => t | _ => H
end in end in
lazymatch t with iSpecializeArgs H xs;
| ITrm ?H ?xs ?pat => lazymatch type of H with
| ident =>
(* The lemma [tac_specialize_persistent_helper] allows one to use all
spatial hypotheses for both proving the premises of the lemma we
specialize as well as those of the remaining goal. We can only use it when
the result of the specialization is persistent, and no modality is
eliminated. As an optimization, we do not use this when only universal
quantifiers are instantiated. *)
let pat := spec_pat.parse pat in let pat := spec_pat.parse pat in
let H := lazymatch type of H with string => constr:(INamed H) | _ => H end in lazymatch eval compute in
iSpecializeArgs H xs; (p && bool_decide (pat []) && negb (existsb spec_pat_modal pat)) with
lazymatch type of H with | true =>
| ident => (* FIXME: do something reasonable when the BI is not affine *)
(* The lemma [tac_specialize_persistent_helper] allows one to use all eapply tac_specialize_persistent_helper with _ H _ _ _ _;
spatial hypotheses for both proving the premises of the lemma we [env_reflexivity || fail "iSpecialize:" H "not found"
specialize as well as those of the remaining goal. We can only use it when |iSpecializePat H pat; last (iExact H)
the result of the specialization is persistent, and no modality is |apply _ ||
eliminated. As an optimization, we do not use this when only universal let Q := match goal with |- IntoPersistent _ ?Q _ => Q end in
quantifiers are instantiated. *) fail "iSpecialize:" Q "not persistent"
let pat := spec_pat.parse pat in |env_cbv; apply _ ||
lazymatch eval compute in let Q := match goal with |- TCAnd _ (Affine ?Q) => Q end in
(p && bool_decide (pat []) && negb (existsb spec_pat_modal pat)) with fail "iSpecialize:" Q "not affine"
| true => |env_reflexivity
(* FIXME: do something reasonable when the BI is not affine *) |(* goal *)]
eapply tac_specialize_persistent_helper with _ H _ _ _ _; | false => iSpecializePat H pat
[env_reflexivity || fail "iSpecialize:" H "not found" end
|iSpecializePat H pat; last (iExact H) | _ => fail "iSpecialize:" H "should be a hypothesis, use iPoseProof instead"
|apply _ || end.
let Q := match goal with |- IntoPersistent _ ?Q _ => Q end in
fail "iSpecialize:" Q "not persistent" Tactic Notation "iSpecializeCore" open_constr(t) "as" constr(p) :=
|env_cbv; apply _ || lazymatch type of t with
let Q := match goal with |- TCAnd _ (Affine ?Q) => Q end in | string => iSpecializeCore t with hnil "" as p
fail "iSpecialize:" Q "not affine" | ident => iSpecializeCore t with hnil "" as p
|env_reflexivity | _ =>
|(* goal *)] lazymatch t with
| false => iSpecializePat H pat | ITrm ?H ?xs ?pat => iSpecializeCore H with xs pat as p
end | _ => fail "iSpecialize:" t "should be a proof mode term"
| _ => fail "iSpecialize:" H "should be a hypothesis, use iPoseProof instead"
end end
| _ => fail "iSpecialize:" t "should be a proof mode term"
end. end.
Tactic Notation "iSpecialize" open_constr(t) := Tactic Notation "iSpecialize" open_constr(t) :=
......
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