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

Implement `iRewrite` using type classes.

parent f8ba3a6b
No related branches found
No related tags found
No related merge requests found
...@@ -142,6 +142,14 @@ Proof. ...@@ -142,6 +142,14 @@ Proof.
rewrite -Hx. apply pure_intro. done. rewrite -Hx. apply pure_intro. done.
Qed. Qed.
(* IntoInternalEq *)
Global Instance into_internal_eq_internal_eq {A : ofeT} (x y : A) :
@IntoInternalEq PROP A (x y) x y.
Proof. by rewrite /IntoInternalEq. Qed.
Global Instance into_internal_eq_persistently {A : ofeT} (x y : A) P :
IntoInternalEq P x y IntoInternalEq ( P) x y.
Proof. rewrite /IntoInternalEq=> ->. by rewrite persistently_elim. Qed.
(* IntoPersistent *) (* IntoPersistent *)
Global Instance into_persistent_persistently_trans p P Q : Global Instance into_persistent_persistently_trans p P Q :
IntoPersistent true P Q IntoPersistent p ( P) Q | 0. IntoPersistent true P Q IntoPersistent p ( P) Q | 0.
......
...@@ -54,6 +54,11 @@ Class FromPure {M} (P : uPred M) (φ : Prop) := from_pure : ⌜φ⌝ ⊢ P. ...@@ -54,6 +54,11 @@ Class FromPure {M} (P : uPred M) (φ : Prop) := from_pure : ⌜φ⌝ ⊢ P.
Arguments from_pure {_} _ _ {_}. Arguments from_pure {_} _ _ {_}.
Hint Mode FromPure + ! - : typeclass_instances. Hint Mode FromPure + ! - : typeclass_instances.
Class IntoInternalEq {M} {A : ofeT} (P : uPred M) (x y : A) :=
into_internal_eq : P x y.
Arguments into_internal_eq {_ _} _ _ _ {_}.
Hint Mode IntoInternalEq + - ! - - : typeclass_instances.
Class IntoPersistent {M} (p : bool) (P Q : uPred M) := Class IntoPersistent {M} (p : bool) (P Q : uPred M) :=
into_persistent : ?p P Q. into_persistent : ?p P Q.
Arguments into_persistent {_} _ _ _ {_}. Arguments into_persistent {_} _ _ _ {_}.
......
...@@ -768,7 +768,7 @@ Qed. ...@@ -768,7 +768,7 @@ Qed.
Lemma tac_rewrite Δ i p Pxy d Q : Lemma tac_rewrite Δ i p Pxy d Q :
envs_lookup i Δ = Some (p, Pxy) envs_lookup i Δ = Some (p, Pxy)
{A : ofeT} (x y : A) (Φ : A uPred M), {A : ofeT} (x y : A) (Φ : A uPred M),
(Pxy x y) IntoInternalEq Pxy x y
(Q ⊣⊢ Φ (if d is Left then y else x)) (Q ⊣⊢ Φ (if d is Left then y else x))
NonExpansive Φ NonExpansive Φ
(Δ Φ (if d is Left then x else y)) Δ Q. (Δ Φ (if d is Left then x else y)) Δ Q.
...@@ -784,7 +784,7 @@ Lemma tac_rewrite_in Δ i p Pxy j q P d Q : ...@@ -784,7 +784,7 @@ Lemma tac_rewrite_in Δ i p Pxy j q P d Q :
envs_lookup i Δ = Some (p, Pxy) envs_lookup i Δ = Some (p, Pxy)
envs_lookup j Δ = Some (q, P) envs_lookup j Δ = Some (q, P)
{A : ofeT} Δ' x y (Φ : A uPred M), {A : ofeT} Δ' x y (Φ : A uPred M),
(Pxy x y) IntoInternalEq Pxy x y
(P ⊣⊢ Φ (if d is Left then y else x)) (P ⊣⊢ Φ (if d is Left then y else x))
NonExpansive Φ NonExpansive Φ
envs_simple_replace j q (Esnoc Enil j (Φ (if d is Left then x else y))) Δ = Some Δ' envs_simple_replace j q (Esnoc Enil j (Φ (if d is Left then x else y))) Δ = Some Δ'
......
...@@ -1628,11 +1628,9 @@ Local Tactic Notation "iRewriteCore" constr(lr) open_constr(lem) := ...@@ -1628,11 +1628,9 @@ Local Tactic Notation "iRewriteCore" constr(lr) open_constr(lem) :=
iPoseProofCore lem as true true (fun Heq => iPoseProofCore lem as true true (fun Heq =>
eapply (tac_rewrite _ Heq _ _ lr); eapply (tac_rewrite _ Heq _ _ lr);
[env_reflexivity || fail "iRewrite:" Heq "not found" [env_reflexivity || fail "iRewrite:" Heq "not found"
|let P := match goal with |- ?P _ => P end in |apply _ ||
(* use ssreflect apply: which is better at dealing with unification let P := match goal with |- IntoInternalEq ?P _ _ _ => P end in
involving canonical structures. This is useful for the COFE canonical fail "iRewrite:" P "not an equality"
structure in uPred_eq that it may have to infer. *)
apply: reflexivity || fail "iRewrite:" P "not an equality"
|iRewriteFindPred |iRewriteFindPred
|intros ??? ->; reflexivity|lazy beta; iClear Heq]). |intros ??? ->; reflexivity|lazy beta; iClear Heq]).
...@@ -1644,8 +1642,8 @@ Local Tactic Notation "iRewriteCore" constr(lr) open_constr(lem) "in" constr(H) ...@@ -1644,8 +1642,8 @@ Local Tactic Notation "iRewriteCore" constr(lr) open_constr(lem) "in" constr(H)
eapply (tac_rewrite_in _ Heq _ _ H _ _ lr); eapply (tac_rewrite_in _ Heq _ _ H _ _ lr);
[env_reflexivity || fail "iRewrite:" Heq "not found" [env_reflexivity || fail "iRewrite:" Heq "not found"
|env_reflexivity || fail "iRewrite:" H "not found" |env_reflexivity || fail "iRewrite:" H "not found"
|apply: reflexivity || |apply _ ||
let P := match goal with |- ?P _ => P end in let P := match goal with |- IntoInternalEq ?P _ _ _ => P end in
fail "iRewrite:" P "not an equality" fail "iRewrite:" P "not an equality"
|iRewriteFindPred |iRewriteFindPred
|intros ??? ->; reflexivity |intros ??? ->; reflexivity
......
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