123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113(******************************************************************************)(* _ __ * The Kappa Language *)(* | |/ / * Copyright 2010-2020 CNRS - Harvard Medical School - INRIA - IRIF *)(* | ' / *********************************************************************)(* | . \ * This file is distributed under the terms of the *)(* |_|\_\ * GNU Lesser General Public License Version 3 *)(******************************************************************************)(** Collection of rectangular instances. *)(** Two implementations are available for this signature. *)moduletypeS=sigtypettypemessagevalreceive_message:message->t->tvalempty:Model.t->tvaldebug_print:Format.formatter->t->unit(** {6 Updating the roots} *)valincorporate_extra_pattern:t->Pattern.id->IntCollection.t->unitvalbreak_apart_cc:t->Edges.t->?mod_connectivity_store:Roots.mod_ccs_cache->(int*int)option->unitvalmerge_cc:t->?mod_connectivity_store:Roots.mod_ccs_cache->(int*int)option->unitvalupdate_roots:t->bool->Pattern.Set.t->Edges.t->Roots.mod_ccs_cache->Pattern.id->int->unit(** {6 Checking instances} *)valis_valid:t->Pattern.id->int->bool(** {6 Counting instances} *)valnumber_of_instances:?rule_id:int->t->Pattern.idarray->int(** [number_of_instances ?rule_id state patterns] *)valnumber_of_unary_instances_in_cc:?rule_id:int->t->Pattern.id*Pattern.id->int->int(** [number_of_unary_instances_in_cc ?rule_id state (pat1, pat2) cc] *)(** {6 Picking instances} *)valpick_unary_instance_in_cc:?rule_id:int->t->Random.State.t->Pattern.id*Pattern.id->int->int*int(** [pick_unary_instance_in_cc state random_state (pat1, pat2) cc]
Returns a pair of roots corresponding to [pat1] and [pat2] respectively.
Optimized for currying before the [cc] argument.
In case of failure, one of the resulting roots is set to [(-1)]. *)valfold_picked_instance:?rule_id:int->t->Random.State.t->Pattern.idarray->init:'a->(int->Pattern.id->int->'a->'aoption)->'aoption(** [fold_picked_instances state random_state patterns ~init f]
with [f pat_id_in_array pat corresponding_root acc].
Monadic fold function that calls [f] for every root of a random
embedding from [patterns] in the mixture.
This function is lazy in the sense it stops to draw roots when
the accumulator besomes `None`. *)(** {6 Enumerating instances} *)valfold_instances:?rule_id:int->?excp:Pattern.id*int->t->Pattern.idarray->init:'a->(intarray->'a->'a)->'a(** [fold_enumerated_instances state patterns ~init f]
with [f roots acc].
Folds through every rectangular instance of an array of patterns. *)valfold_unary_instances:?rule_id:int->t->Pattern.id*Pattern.id->init:'a->(int*int->'a->'a)->'a(** [fold_unary_instances state (pat1, pat2) ~init f ]
with [f (root1, root2) acc]. *)end