Commit f6b1bf4b authored by Robbert Krebbers's avatar Robbert Krebbers

New class `SetUnfoldElemOf` that specializes `SetUnfold` to improve performance.

parent a8e9b673
Pipeline #16227 passed with stage
in 8 minutes and 5 seconds
......@@ -60,8 +60,8 @@ Defined.
(** * The [elements] operation *)
Global Instance set_unfold_elements X x P :
SetUnfold (x X) P SetUnfold (x elements X) P.
Proof. constructor. by rewrite elem_of_elements, (set_unfold (x X) P). Qed.
SetUnfoldElemOf x X P SetUnfoldElemOf x (elements X) P.
Proof. constructor. by rewrite elem_of_elements, (set_unfold_elem_of x X P). Qed.
Global Instance elements_proper: Proper (() ==> ()) (elements (C:=C)).
......@@ -278,9 +278,9 @@ Section filter.
by rewrite elem_of_list_to_set, elem_of_list_filter, elem_of_elements.
Global Instance set_unfold_filter X Q :
SetUnfold (x X) Q SetUnfold (x filter P X) (P x Q).
SetUnfoldElemOf x X Q SetUnfoldElemOf x (filter P X) (P x Q).
intros ??; constructor. by rewrite elem_of_filter, (set_unfold (x X) Q).
intros ??; constructor. by rewrite elem_of_filter, (set_unfold_elem_of x X Q).
Lemma filter_empty : filter P (:C) .
......@@ -316,8 +316,8 @@ Section map.
by setoid_rewrite elem_of_elements.
Global Instance set_unfold_map (f : A B) (X : C) (P : A Prop) :
( y, SetUnfold (y X) (P y))
SetUnfold (x set_map (D:=D) f X) ( y, x = f y P y).
( y, SetUnfoldElemOf y X (P y))
SetUnfoldElemOf x (set_map (D:=D) f X) ( y, x = f y P y).
Proof. constructor. rewrite elem_of_map; naive_solver. Qed.
Global Instance set_map_proper :
......@@ -136,10 +136,11 @@ Lemma gmultiset_elem_of_disj_union X Y x : x ∈ X ⊎ Y ↔ x ∈ X ∨ x ∈ Y
Proof. rewrite !elem_of_multiplicity, multiplicity_disj_union. lia. Qed.
Global Instance set_unfold_gmultiset_disj_union x X Y P Q :
SetUnfold (x X) P SetUnfold (x Y) Q SetUnfold (x X Y) (P Q).
SetUnfoldElemOf x X P SetUnfoldElemOf x Y Q
SetUnfoldElemOf x (X Y) (P Q).
intros ??; constructor. rewrite gmultiset_elem_of_disj_union.
by rewrite <-(set_unfold (x X) P), <-(set_unfold (x Y) Q).
by rewrite <-(set_unfold_elem_of x X P), <-(set_unfold_elem_of x Y Q).
(* Algebraic laws *)
......@@ -44,10 +44,10 @@ Instance propset_join : MJoin propset := λ A (XX : propset (propset A)),
Instance propset_monad_set : MonadSet propset.
Proof. by split; try apply _. Qed.
Instance set_unfold_propset_top {A} (x : A) : SetUnfold (x ( : propset A)) True.
Instance set_unfold_propset_top {A} (x : A) : SetUnfoldElemOf x ( : propset A) True.
Proof. by constructor. Qed.
Instance set_unfold_PropSet {A} (P : A Prop) x Q :
SetUnfoldSimpl (P x) Q SetUnfold (x PropSet P) Q.
SetUnfoldSimpl (P x) Q SetUnfoldElemOf x (PropSet P) Q.
Proof. intros HPQ. constructor. apply HPQ. Qed.
Global Opaque propset_elem_of propset_top propset_empty propset_singleton.
This diff is collapsed.
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