Commit 9201446c authored by Robbert Krebbers's avatar Robbert Krebbers

Rewrite set_unfold using type classes.

It now traverses terms at most once, whereas the setoid_rewrite
approach was travering terms many times. Also, the tactic can now
be extended by defining type class instances.
parent 9d497b89
This diff is collapsed.
...@@ -117,6 +117,8 @@ Proof. ...@@ -117,6 +117,8 @@ Proof.
Qed. Qed.
End hashset. End hashset.
Typeclasses Opaque hashset_elem_of.
(** These instances are declared using [Hint Extern] to avoid too (** These instances are declared using [Hint Extern] to avoid too
eager type class search. *) eager type class search. *)
Hint Extern 1 (ElemOf _ (hashset _)) => Hint Extern 1 (ElemOf _ (hashset _)) =>
......
(* Copyright (c) 2012-2015, Robbert Krebbers. *) (* Copyright (c) 2012-2015, Robbert Krebbers. *)
(* This file is distributed under the terms of the BSD license. *) (* This file is distributed under the terms of the BSD license. *)
(** This file implements sets as functions into Prop. *) (** This file implements sets as functions into Prop. *)
From stdpp Require Export tactics. From stdpp Require Export collections.
Record set (A : Type) : Type := mkSet { set_car : A Prop }. Record set (A : Type) : Type := mkSet { set_car : A Prop }.
Add Printing Constructor set. Add Printing Constructor set.
...@@ -40,4 +40,12 @@ Instance set_join : MJoin set := λ A (XX : set (set A)), ...@@ -40,4 +40,12 @@ Instance set_join : MJoin set := λ A (XX : set (set A)),
Instance set_collection_monad : CollectionMonad set. Instance set_collection_monad : CollectionMonad set.
Proof. by split; try apply _. Qed. Proof. by split; try apply _. Qed.
Global Opaque set_elem_of set_union set_intersection set_difference. Instance set_unfold_set_all {A} (x : A) : SetUnfold (x ( : set A)) True.
Proof. by constructor. Qed.
Instance set_unfold_mkSet {A} (P : A Prop) x Q :
SetUnfoldSimpl (P x) Q SetUnfold (x mkSet P) Q.
Proof. intros HPQ. constructor. apply HPQ. Qed.
Global Opaque set_elem_of set_all set_empty set_singleton.
Global Opaque set_union set_intersection set_difference.
Global Opaque set_ret set_bind set_fmap set_join.
\ No newline at end of file
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