From 7cfc4e5146be5666419451bdd516f1f3f264d24a Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Sun, 25 Jan 2015 14:42:51 +0100 Subject: Imported Upstream version 8.5~beta1+dfsg --- tactics/dnet.mli | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 tactics/dnet.mli (limited to 'tactics/dnet.mli') diff --git a/tactics/dnet.mli b/tactics/dnet.mli new file mode 100644 index 00000000..4bfa7263 --- /dev/null +++ b/tactics/dnet.mli @@ -0,0 +1,124 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* | Leaf + | Node of btree * btree | Node of 'a * 'a + +*) + +(** datatype you want to build a dnet on *) +module type Datatype = +sig + (** parametric datatype. ['a] is morally the recursive argument *) + type 'a t + + (** non-recursive mapping of subterms *) + val map : ('a -> 'b) -> 'a t -> 'b t + val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t + + (** non-recursive folding of subterms *) + val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a + val fold2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b t -> 'c t -> 'a + + (** comparison of constructors *) + val compare : unit t -> unit t -> int + + (** for each constructor, is it not-parametric on 'a? *) + val terminal : 'a t -> bool + + (** [choose f w] applies f on ONE of the subterms of w *) + val choose : ('a -> 'b) -> 'a t -> 'b +end + +module type S = +sig + type t + + (** provided identifier type *) + type ident + + (** provided metavariable type *) + type meta + + (** provided parametrized datastructure *) + type 'a structure + + (** returned sets of solutions *) + module Idset : Set.S with type elt=ident + + (** a pattern is a term where each node can be a unification + variable *) + type term_pattern = + | Term of term_pattern structure + | Meta of meta + + val empty : t + + (** [add t w i] adds a new association (w,i) in t. *) + val add : t -> term_pattern -> ident -> t + + (** [find_all t] returns all identifiers contained in t. *) + val find_all : t -> Idset.t + + (** [fold_pattern f acc p dn] folds f on each meta of p, passing the + meta and the sub-dnet under it. The result includes: + - Some set if identifiers were gathered on the leafs of the term + - None if the pattern contains no leaf (only Metas at the leafs). + *) + val fold_pattern : + ('a -> (Idset.t * meta * t) -> 'a) -> 'a -> term_pattern -> t -> Idset.t option * 'a + + (** [find_match p t] returns identifiers of all terms matching p in + t. *) + val find_match : term_pattern -> t -> Idset.t + + (** set operations on dnets *) + val inter : t -> t -> t + val union : t -> t -> t + + (** apply a function on each identifier and node of terms in a dnet *) + val map : (ident -> ident) -> (unit structure -> unit structure) -> t -> t +end + +module Make : + functor (T:Datatype) -> + functor (Ident:Set.OrderedType) -> + functor (Meta:Set.OrderedType) -> + S with type ident = Ident.t + and type meta = Meta.t + and type 'a structure = 'a T.t -- cgit v1.2.3