Sbrs.TOutput signature of the functor Sbrs.Make.
val pp_react :
Ppx_deriving_runtime.Format.formatter ->
react ->
Ppx_deriving_runtime.unitval show_react : react -> Ppx_deriving_runtime.stringval react_to_yojson : react -> Yojson.Safe.tval react_of_yojson :
Yojson.Safe.t ->
react Ppx_deriving_yojson_runtime.error_orval graph_to_yojson : graph -> Yojson.Safe.tval graph_of_yojson :
Yojson.Safe.t ->
graph Ppx_deriving_yojson_runtime.error_orval pp_label :
Ppx_deriving_runtime.Format.formatter ->
label ->
Ppx_deriving_runtime.unitval show_label : label -> Ppx_deriving_runtime.stringval label_to_yojson : label -> Yojson.Safe.tval label_of_yojson :
Yojson.Safe.t ->
label Ppx_deriving_yojson_runtime.error_orval pp_limit :
Ppx_deriving_runtime.Format.formatter ->
limit ->
Ppx_deriving_runtime.unitval show_limit : limit -> Ppx_deriving_runtime.stringval stats_trans : Rs_intf.stats -> intNumber of transitions in the stats record.
val name : react -> stringThe name of the reaction rule.
val parse_react_unsafe :
name:string ->
lhs:Big.t ->
rhs:Big.t ->
?conds:AppCond.t list ->
?cond_captures:string list ->
label ->
Fun.t option ->
reactCreate a new reaction rule. If eta = None, the identity function is used as instantiation map. No validity check is performed.
val parse_react :
name:string ->
lhs:Big.t ->
rhs:Big.t ->
?conds:AppCond.t list ->
?cond_captures:string list ->
label ->
Fun.t option ->
react optionSame as parse_react_unsafe but returns None if it is impossible to parse a valid reaction.
val parse_react_err :
name:string ->
lhs:Big.t ->
rhs:Big.t ->
?conds:AppCond.t list ->
?cond_captures:string list ->
label ->
Fun.t option ->
(react, string) Stdlib.resultSame as parse_react but returns Error string if it is impossible to parse a valid reaction (with an error message), else Ok react.
val is_valid_react : react -> boolReturn true if the inner (outer) interfaces of the redex (reactum) are equal, the redex is solid and the instantiation map is total. Return false otherwise. See Big.is_solid.
exception NOT_VALID of react_errorRaised when a reaction rule is not valid.
val is_valid_react_exn : react -> boolSame as is_valid_react but an exception is raised when the rule is not valid.
val string_of_react_err : react_error -> stringString representation of reaction validity errors.
Bigraph isomorphism: returns true if two bigraphs are isomorphic (including parameter values). Same check used by the BFS state loop.
Compute the set of reachable states in one step. Note that isomorphic states are merged. The total number of occurrences is also returned.
val random_step :
Stdlib.Random.State.t ->
Big.t ->
react list ->
(Big.t * label * react list) option * intCompute a random state reachable in one step, using the given random state for reproducibility. The total number of occurrences is also returned.
val random_step_forced :
Stdlib.Random.State.t ->
Big.t ->
react list ->
react ->
(Big.t * label * react list) option * intCompute a random state reachable in one step, conditioned on rule firing: the successor is drawn from rule's occurrences and, for SBRS, the sojourn at the exit rate of the full class rules, the CTMC path conditioned on the rule firing. The total number of occurrences of rule is also returned.
Sequential application of a list of reaction rules. Non-enabled rules are ignored. None is returned if no rewriting is performed i.e., when all the reaction rules are non-enabled.
Reduce a reducible class to the fixed point. The number of rewriting steps is also returned.
val is_valid_priority : p_class -> boolReturn true if a priority class is valid, false otherwise.
val is_valid_priority_err : p_class -> (unit, string) Stdlib.resultOk () if the class is valid, otherwise Error reason with a precise explanation of the violation. is_valid_priority c = Result.is_ok (is_valid_priority_err c).
val is_valid_priority_list : p_class list -> boolReturn true if a list of priority classes contains at least a non reducible priority class, false otherwise.
val cardinal : p_class list -> intReturn the total number of reaction rules in a list of priority classes.
Scan priority classes and reduce a state. Stop when no more rules can be applied or when a non reducible priority class is enabled. Also return the number of rewriting steps performed in the loop.
type class_info = {ci_idx : int;Index of the class in the priority list.
*)ci_reducing : bool;Whether the class is a reducing (instantaneous) class.
*)ci_rules : rule_info list;Information about all the rules in the class.
*)ci_enabled_rules : rule_info list;Information about the enabled rules in the class.
*)}val scan_all_enabled : Big.t -> p_class list -> class_info listReturn all the priority classes with at least one enabled rule, in priority order.
val scan_top_enabled : Big.t -> p_class list -> class_info optionReturn the first priority class with at least one enabled rule (highest priority first), or None if no rule is enabled (deadlock).
Same reduction as rewrite, but also record a trace of the reducing classes that fired: for each, the names of the rules enabled at the start of the reduction and the number of fixing steps. The trace is returned in firing order.
Set the group-size threshold for wildcard structural matching. Groups with fewer than n rules use direct per-rule matching; larger groups use wildcard structural matching (one solve + partition). Default is 3. Call before select_path.
Resolve all matching implementation refs. Call once after priorities are compiled, before any matching or state exploration.
Functions to generate the labelled transition system of a reactive system.
exception MAX of graph * Rs_intf.statsRaised when a new state would be assigned an index greater than the maximum state index.
val bfs :
s0:Big.t ->
priorities:p_class list ->
predicates:Rs_intf.pred_entry list ->
max:int ->
(int -> Big.t -> unit) ->
graph * Rs_intf.statsbfs ~s0 ~priorities ~predicates ~max iter_f computes the transition system of the reactive system specified by initial state s0 and priority classes priorities. Arguments ~max and iter_f are the maximum state index of the transition system and a function to be applied whenever a new state is discovered, respectively. States are indexed from 0, so the transition system holds at most max + 1 states, including the initial state. iter_f takes two arguments, the index of the current state (starting from 0) and the corresponding bigraph. Priority classes are assumed to be sorted by priority, i.e., the first element in the list is the class with the highest priority. List of predicates ~predicates is also checked for every state. The generation of the transition system is performed in a breadth-first search fashion.
exception DEADLOCK of graph * Rs_intf.stats * limitRaised when a simulation reaches a deadlock state.
exception LIMIT of graph * Rs_intf.statsRaised when a simulation reaches the simulation limit.
val sim :
s0:Big.t ->
?seed:int ->
priorities:p_class list ->
predicates:Rs_intf.pred_entry list ->
init_size:int ->
stop:limit ->
(int -> Big.t -> limit -> unit) ->
graph * Rs_intf.statsSimulate the reactive system specified by initial state s0 and priority classes priorities. Arguments init_size and stop are the initial size of the state set and the simulation limit, respectively. Function iter_f is applied to every new state discovered during the simulation. It takes three arguments, the index of the current state (starting from 0), the corresponding bigraph, and the simulation progress, i.e. the current number of simulation steps or the current simulation time. Optional argument seed is used to initialise the random generator with a specific seed. List of predicates predicates is also checked for every state.
val to_txt : graph -> stringval to_dot : graph -> path:string -> name:string -> stringval to_state_rewards : graph -> stringval to_prism : graph -> stringval to_transition_rewards : graph -> stringval to_lab : graph -> stringFunctions to accumulate a transition system as steps are taken, mirroring what bfs and sim build internally.
val trace_make : Rs_intf.pred_entry list -> graphCreate an empty transition system for the given predicates. The entries' patterns are ignored here; they are checked by check_predicates as states are added.
Add a transition from source to dest, with the given label and the rules that fired.
val check_predicates :
graph ->
Rs_intf.pred_entry list ->
int ->
Big.t ->
Predicate.t listCheck the predicates against a state and record which ones match; return the recorded predicates, in the entries' order.
val state_preds : graph -> int -> Predicate.t listReturn the predicates recorded as matching a state.
val iter_edges :
(int -> int -> label -> Base.S_string.t -> unit) ->
graph ->
unitval fold_edges :
(int -> int -> label -> Base.S_string.t -> 'a -> 'a) ->
graph ->
'a ->
'aval rules_fired : graph -> intNumber of distinct reaction rules that fired along at least one transition of the transition system.
val kind : Rs.rs_typeThe kind of reactive system.
val rate : react -> floatThe rate of a reaction rule.