Commit 37e95231 authored by Robbert Krebbers's avatar Robbert Krebbers

Rename solve_elem_of into set_solver.

It is doing much more than just dealing with ∈, it solves all kinds
of goals involving set operations (including ≡ and ⊆).
parent 20690605
This diff is collapsed.
...@@ -41,7 +41,7 @@ Qed. ...@@ -41,7 +41,7 @@ Qed.
Lemma elements_singleton x : elements {[ x ]} = [x]. Lemma elements_singleton x : elements {[ x ]} = [x].
Proof. Proof.
apply Permutation_singleton. by rewrite <-(right_id () {[x]}), apply Permutation_singleton. by rewrite <-(right_id () {[x]}),
elements_union_singleton, elements_empty by solve_elem_of. elements_union_singleton, elements_empty by set_solver.
Qed. Qed.
Lemma elements_contains X Y : X Y elements X `contains` elements Y. Lemma elements_contains X Y : X Y elements X `contains` elements Y.
Proof. Proof.
...@@ -90,7 +90,7 @@ Proof. ...@@ -90,7 +90,7 @@ Proof.
intros E. destruct (size_pos_elem_of X); auto with lia. intros E. destruct (size_pos_elem_of X); auto with lia.
exists x. apply elem_of_equiv. split. exists x. apply elem_of_equiv. split.
- rewrite elem_of_singleton. eauto using size_singleton_inv. - rewrite elem_of_singleton. eauto using size_singleton_inv.
- solve_elem_of. - set_solver.
Qed. Qed.
Lemma size_union X Y : X Y size (X Y) = size X + size Y. Lemma size_union X Y : X Y size (X Y) = size X + size Y.
Proof. Proof.
...@@ -98,7 +98,7 @@ Proof. ...@@ -98,7 +98,7 @@ Proof.
apply Permutation_length, NoDup_Permutation. apply Permutation_length, NoDup_Permutation.
- apply NoDup_elements. - apply NoDup_elements.
- apply NoDup_app; repeat split; try apply NoDup_elements. - apply NoDup_app; repeat split; try apply NoDup_elements.
intros x; rewrite !elem_of_elements; solve_elem_of. intros x; rewrite !elem_of_elements; set_solver.
- intros. by rewrite elem_of_app, !elem_of_elements, elem_of_union. - intros. by rewrite elem_of_app, !elem_of_elements, elem_of_union.
Qed. Qed.
Instance elem_of_dec_slow (x : A) (X : C) : Decision (x X) | 100. Instance elem_of_dec_slow (x : A) (X : C) : Decision (x X) | 100.
...@@ -121,15 +121,15 @@ Next Obligation. ...@@ -121,15 +121,15 @@ Next Obligation.
Qed. Qed.
Lemma size_union_alt X Y : size (X Y) = size X + size (Y X). Lemma size_union_alt X Y : size (X Y) = size X + size (Y X).
Proof. Proof.
rewrite <-size_union by solve_elem_of. rewrite <-size_union by set_solver.
setoid_replace (Y X) with ((Y X) X) by solve_elem_of. setoid_replace (Y X) with ((Y X) X) by set_solver.
rewrite <-union_difference, (comm ()); solve_elem_of. rewrite <-union_difference, (comm ()); set_solver.
Qed. Qed.
Lemma subseteq_size X Y : X Y size X size Y. Lemma subseteq_size X Y : X Y size X size Y.
Proof. intros. rewrite (union_difference X Y), size_union_alt by done. lia. Qed. Proof. intros. rewrite (union_difference X Y), size_union_alt by done. lia. Qed.
Lemma subset_size X Y : X Y size X < size Y. Lemma subset_size X Y : X Y size X < size Y.
Proof. Proof.
intros. rewrite (union_difference X Y) by solve_elem_of. intros. rewrite (union_difference X Y) by set_solver.
rewrite size_union_alt, difference_twice. rewrite size_union_alt, difference_twice.
cut (size (Y X) 0); [lia |]. cut (size (Y X) 0); [lia |].
by apply size_non_empty_iff, non_empty_difference. by apply size_non_empty_iff, non_empty_difference.
...@@ -143,8 +143,8 @@ Proof. ...@@ -143,8 +143,8 @@ Proof.
intros ? Hemp Hadd. apply well_founded_induction with (). intros ? Hemp Hadd. apply well_founded_induction with ().
{ apply collection_wf. } { apply collection_wf. }
intros X IH. destruct (collection_choose_or_empty X) as [[x ?]|HX]. intros X IH. destruct (collection_choose_or_empty X) as [[x ?]|HX].
- rewrite (union_difference {[ x ]} X) by solve_elem_of. - rewrite (union_difference {[ x ]} X) by set_solver.
apply Hadd. solve_elem_of. apply IH; solve_elem_of. apply Hadd. set_solver. apply IH; set_solver.
- by rewrite HX. - by rewrite HX.
Qed. Qed.
Lemma collection_fold_ind {B} (P : B C Prop) (f : A B B) (b : B) : Lemma collection_fold_ind {B} (P : B C Prop) (f : A B B) (b : B) :
...@@ -158,10 +158,10 @@ Proof. ...@@ -158,10 +158,10 @@ Proof.
symmetry. apply elem_of_elements. } symmetry. apply elem_of_elements. }
induction 1 as [|x l ?? IH]; simpl. induction 1 as [|x l ?? IH]; simpl.
- intros X HX. setoid_rewrite elem_of_nil in HX. - intros X HX. setoid_rewrite elem_of_nil in HX.
rewrite equiv_empty. done. solve_elem_of. rewrite equiv_empty. done. set_solver.
- intros X HX. setoid_rewrite elem_of_cons in HX. - intros X HX. setoid_rewrite elem_of_cons in HX.
rewrite (union_difference {[ x ]} X) by solve_elem_of. rewrite (union_difference {[ x ]} X) by set_solver.
apply Hadd. solve_elem_of. apply IH. solve_elem_of. apply Hadd. set_solver. apply IH. set_solver.
Qed. Qed.
Lemma collection_fold_proper {B} (R : relation B) `{!Equivalence R} Lemma collection_fold_proper {B} (R : relation B) `{!Equivalence R}
(f : A B B) (b : B) `{!Proper ((=) ==> R ==> R) f} (f : A B B) (b : B) `{!Proper ((=) ==> R ==> R) f}
......
...@@ -36,13 +36,13 @@ Proof. ...@@ -36,13 +36,13 @@ Proof.
Qed. Qed.
Lemma dom_empty {A} : dom D (@empty (M A) _) . Lemma dom_empty {A} : dom D (@empty (M A) _) .
Proof. Proof.
split; intro; [|solve_elem_of]. split; intro; [|set_solver].
rewrite elem_of_dom, lookup_empty. by inversion 1. rewrite elem_of_dom, lookup_empty. by inversion 1.
Qed. Qed.
Lemma dom_empty_inv {A} (m : M A) : dom D m m = . Lemma dom_empty_inv {A} (m : M A) : dom D m m = .
Proof. Proof.
intros E. apply map_empty. intros. apply not_elem_of_dom. intros E. apply map_empty. intros. apply not_elem_of_dom.
rewrite E. solve_elem_of. rewrite E. set_solver.
Qed. Qed.
Lemma dom_alter {A} f (m : M A) i : dom D (alter f i m) dom D m. Lemma dom_alter {A} f (m : M A) i : dom D (alter f i m) dom D m.
Proof. Proof.
...@@ -54,19 +54,19 @@ Lemma dom_insert {A} (m : M A) i x : dom D (<[i:=x]>m) ≡ {[ i ]} ∪ dom D m. ...@@ -54,19 +54,19 @@ Lemma dom_insert {A} (m : M A) i x : dom D (<[i:=x]>m) ≡ {[ i ]} ∪ dom D m.
Proof. Proof.
apply elem_of_equiv. intros j. rewrite elem_of_union, !elem_of_dom. apply elem_of_equiv. intros j. rewrite elem_of_union, !elem_of_dom.
unfold is_Some. setoid_rewrite lookup_insert_Some. unfold is_Some. setoid_rewrite lookup_insert_Some.
destruct (decide (i = j)); solve_elem_of. destruct (decide (i = j)); set_solver.
Qed. Qed.
Lemma dom_insert_subseteq {A} (m : M A) i x : dom D m dom D (<[i:=x]>m). Lemma dom_insert_subseteq {A} (m : M A) i x : dom D m dom D (<[i:=x]>m).
Proof. rewrite (dom_insert _). solve_elem_of. Qed. Proof. rewrite (dom_insert _). set_solver. Qed.
Lemma dom_insert_subseteq_compat_l {A} (m : M A) i x X : Lemma dom_insert_subseteq_compat_l {A} (m : M A) i x X :
X dom D m X dom D (<[i:=x]>m). X dom D m X dom D (<[i:=x]>m).
Proof. intros. transitivity (dom D m); eauto using dom_insert_subseteq. Qed. Proof. intros. transitivity (dom D m); eauto using dom_insert_subseteq. Qed.
Lemma dom_singleton {A} (i : K) (x : A) : dom D {[i := x]} {[ i ]}. Lemma dom_singleton {A} (i : K) (x : A) : dom D {[i := x]} {[ i ]}.
Proof. rewrite <-insert_empty, dom_insert, dom_empty; solve_elem_of. Qed. Proof. rewrite <-insert_empty, dom_insert, dom_empty; set_solver. Qed.
Lemma dom_delete {A} (m : M A) i : dom D (delete i m) dom D m {[ i ]}. Lemma dom_delete {A} (m : M A) i : dom D (delete i m) dom D m {[ i ]}.
Proof. Proof.
apply elem_of_equiv. intros j. rewrite elem_of_difference, !elem_of_dom. apply elem_of_equiv. intros j. rewrite elem_of_difference, !elem_of_dom.
unfold is_Some. setoid_rewrite lookup_delete_Some. solve_elem_of. unfold is_Some. setoid_rewrite lookup_delete_Some. set_solver.
Qed. Qed.
Lemma delete_partial_alter_dom {A} (m : M A) i f : Lemma delete_partial_alter_dom {A} (m : M A) i f :
i dom D m delete i (partial_alter f i m) = m. i dom D m delete i (partial_alter f i m) = m.
......
...@@ -155,7 +155,7 @@ Proof. ...@@ -155,7 +155,7 @@ Proof.
- revert x. induction l as [|y l IH]; intros x; simpl. - revert x. induction l as [|y l IH]; intros x; simpl.
{ by rewrite elem_of_empty. } { by rewrite elem_of_empty. }
rewrite elem_of_union, elem_of_singleton. intros [->|]; [left|right]; eauto. rewrite elem_of_union, elem_of_singleton. intros [->|]; [left|right]; eauto.
- induction 1; solve_elem_of. - induction 1; set_solver.
Qed. Qed.
Lemma NoDup_remove_dups_fast l : NoDup (remove_dups_fast l). Lemma NoDup_remove_dups_fast l : NoDup (remove_dups_fast l).
Proof. Proof.
......
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