Module TransSys
Representation of a transition system
A transition system is uniquely identified by its scope. A transition system can contain subsystems. For each subsystem there is a map of all state variables of the subsystem to some state variable in this transition system, and a function to guard term in the scope of the subsystem to make them valid in this transition system. There must be no cycles in the subsystem relation, that is, a transition system cannot have itself as a subsystem.
A transition system constrains values of the set of state variables of a scope that make up the state of the transition system. The state variables in state_vars are assumed to be of the same scope scope. The initial state constraint init is a term over these state variables at offset init_base, the transition relation trans is a term over state variables at offsets trans_base and trans_base - 1.
- author
- Christoph Sticksel
- author
- Adrien Champion
val init_base : Numeral.tOffset of the current state variables in initial state constraint
val trans_base : Numeral.tOffset of current state variables in transition relation, subtract one for the offset of the previous state variables
val prop_base : Numeral.tOffset of current state variables in properties and invariants, subtract one for the offset of the previous state variables
type tThe transition system
Constructed with the function
mk_trans_sys
type pred_def= UfSymbol.t * (Var.t list * Term.t)Predicate definition
An uninterpreted function symbols and the pair of its formal parameters and its definition, to be used in an association list.
type instance={pos : Lib.position;Position as a unique identifier of the instance
map_down : StateVar.t StateVar.StateVarMap.t;Map from the state variables of this system to the state variables of the instance
map_up : StateVar.t StateVar.StateVarMap.t;Map from state variables of the called system to the state variables of this system
guard_clock : Numeral.t -> Term.t -> Term.t;Add a guard to the Boolean term to make it true whenver the the clock of the subsystem instance is false
guard_clock tassumes thattis a Boolean term and returns the termc => twherecis the clock of the subsystem instance.}Instance of a subsystem
val pp_print_trans_sys : Stdlib.Format.formatter -> t -> unitPretty-print a transition system
val pp_print_subsystems : bool -> Stdlib.Format.formatter -> t -> unitPretty-print a transition system and its subsystems
pp_print_subsystems t f spretty-prints the top node of transition systems, if parametertis set to true, and also all its subsystems.
val pp_print_trans_sys_name : Stdlib.Format.formatter -> t -> unitPretty-print the name of a transition system
Accessors
val init_of_bound : (UfSymbol.t -> unit) option -> t -> Numeral.t -> Term.tClose the initial state constraint by binding all instance identifiers, and bump the state variable offsets to be at the given bound
val trans_of_bound : (UfSymbol.t -> unit) option -> t -> Numeral.t -> Term.tClose the initial state constraint by binding all instance identifiers, and bump the state variable offsets to be at the given bound
val init_uf_symbol : t -> UfSymbol.tPredicate for the initial state constraint
val trans_uf_symbol : t -> UfSymbol.tPredicate for the transition relation
val trans_fun_of : t -> Numeral.t -> Numeral.t -> Term.tBuilds a call to the transition relation function linking state
kandk'.
val init_flag_state_var : t -> StateVar.tReturn the state variable for the init flag
val init_trans_open : t -> StateVar.t list * Term.t * Term.tReturn the instance variables of this transition system, the initial state constraint at
init_baseand the transition relation attrans_basewith the instance variables free.
val set_subsystem_equations : t -> Scope.t -> Term.t -> Term.t -> tUpdate the init and trans equations of a subsystem
val get_logic : t -> TermLib.logicReturn the logic fragment needed to express the transition system
val get_properties : t -> Property.t listReturns the properties in a transition system.
val get_real_properties : t -> Property.t listReturn current status of all real (not candidate) properties
val is_candidate : t -> string -> boolReturn true if the property is a candidate invariant
val get_candidate_properties : t -> Property.t listReturn list of candidate invariants properties
val get_unknown_candidates : t -> Term.t listReturn candidate invariants that have not been proved or disproved yet
val get_mode_requires : t -> Term.t option * (Scope.t * Term.t) listReturns the optional assumption term and the mode requirement terms for each mode.
Used by test generation.
val get_split_properties : t -> Property.t list * Property.t list * Property.t listReturns the list of properties in a transition system, split by their status as
valid, invalid, unknown.
val mk_trans_sys : ?instance_var_id_start:int -> Scope.t -> StateVar.t option -> StateVar.t -> (StateVar.t * Term.t list) list -> StateVar.t list -> LustreExpr.expr LustreExpr.bound_or_fixed list StateVar.StateVarHashtbl.t -> Var.t list -> UfSymbol.t list -> UfSymbol.t -> Var.t list -> Term.t -> UfSymbol.t -> Var.t list -> Term.t -> (t * instance list) list -> Property.t list -> (Term.t option * (Scope.t * Term.t) list) -> Invs.t -> t * intval iter_subsystems : ?include_top:bool -> (t -> unit) -> t -> unitIterate bottom-up over subsystems, including the top level system without repeating subsystems already seen
iter_subsystems f tevaluatesffor all subsystem oft. The subsystems are presented bottom-up such that for each evaluationf tthe functionf shas already been evaluated for each subsystemsoft. Iftcontains a subsystemstwice, no matter at which level,f sis evaluated only once.
val fold_subsystems : ?include_top:bool -> ('a -> t -> 'a) -> 'a -> t -> 'aFold bottom-up over subsystems, including or excluding the top level system, without repeating subsystems already seen
fold_subsystems f tfirst evaluatesf a sfor some subsystemsoftthat does not have subsystems itself. It then passes the result as first argument tofwith the second argument being a subsystem for which all subsystems have been evaluated withf. Iftcontains a subsystemstwice, no matter at which level,f sis evaluated only once.The systems are passes in topological order such that the each system is presented to
fonly after all its subsystems. The functionfis evaluated for the top system last, unless the optional labelled parameterinclude_topis set to false.
val fold_subsystem_instances : (t -> (t * instance) list -> 'a list -> 'a) -> t -> 'aFold bottom-up over subsystem instances
fold_subsystem_instances f tevaluatesf s i lfor each subsystem instance in the systemt, includingtitself. The functionfis evaluated with the subsystems, the reverse sequence of instantiationsithat reach the top systemt, and the evaluations offon the subsystems ofs. The sequence of instantiationsicontains at its head a system that hassas a direct subsystem, together with the instance parameters. For the top systemiis the empty list.The systems are presented in topological order such that each system is presented to
fafter all its subsystem instances have been presented.
val get_subsystem_instances : t -> (t * instance list) listReturn the direct subsystems of a system and their instances
val find_subsystem_of_scope : t -> Scope.t -> tFind the named subsystem
find_subsystem_of_scope t sreturns the subsystem oftidentified by the scopes. We assume that all subsystems with the same scope are identical. The transition systemtitself is returned ifsis its scope.Raise
Not_foundif there is no transition system of scopesin the subsystems oft.
val get_max_depth : t -> intval map_cex_prop_to_subsystem : (Scope.t -> instance -> (StateVar.t * Model.value list) list -> Model.value list -> Model.value list) -> t -> (StateVar.t * Model.value list) list -> Property.t -> t * instance list * (StateVar.t * Model.value list) list * Property.t
State Variables
val state_vars : t -> StateVar.t listReturn the state variables of a transition system
val add_global_constant : t -> Var.t -> tAdd a global constant to the transition system and all the subnodes
val vars_of_bounds : ?with_init_flag:bool -> t -> Numeral.t -> Numeral.t -> Var.t listReturn instances of the state variables of the transition system between given instants
vars_of_bounds t l ureturns the list of instances of the state variables of the transition systemtbetween and includinglandu. Include the state variable for the init flag unless the optional labelled argumentwith_init_flagis set to false.
val declare_vars_of_bounds : ?declare_init_flag:bool -> t -> (UfSymbol.t -> unit) -> Numeral.t -> Numeral.t -> unitDeclare variables of the transition system between given instants
declare_vars_of_bounds t f l uevaluatesfwith the uninterpreted function symbol of each state variable of the transition systemtat each instant between and includinglandu. Include the state variable for the init flag unless the optional labelled argumentdeclare_init_flagis set to false.
val declare_const_vars : t -> (UfSymbol.t -> unit) -> unitval declare_init_flag_of_bounds : t -> (UfSymbol.t -> unit) -> Numeral.t -> Numeral.t -> unitDeclare the init flag of the transition system between given instants
declare_init_flag_of_bounds t f l uevaluatesfwith the uninterpreted function symbol of the state variable for the init flag of the transition systemtat each instant between and includinglandu.
val declare_sorts_ufs_const : t -> (UfSymbol.t -> unit) -> (Type.t -> unit) -> unitDeclare the sorts, uninterpreted functions and const variables of this system and its subsystems.
val define_subsystems : t -> (UfSymbol.t -> Var.t list -> Term.t -> unit) -> unitDeclare the init and trans functions of the subsystems
val define_and_declare_of_bounds : ?declare_sub_vars:bool -> t -> (UfSymbol.t -> Var.t list -> Term.t -> unit) -> (UfSymbol.t -> unit) -> (Type.t -> unit) -> Numeral.t -> Numeral.t -> unitDefine predicates and declare constant and global state variables, declare state variables of top system between and including the given offsets
define_and_declare_of_bounds t f g l ufirst evaluates the functionffor the definition of the initial state constraint predicate and the transitions relation predicate of the top system in the transition systemtand all its subsystems. It then evaluates the functiongwith the declarations of all constant and global state variables of the top system, and with the declarations of the remaining state variables of the top system between and including the offsetslandu.If
l > u, only declarations of constant and global state are passed tog, andfis still evaluated with all definitions.If the optional parameter
declare_sub_varsistrue, it also iterates over all subsystems and evaluatesgwith the declarations of their constants and global state variables, and their state variables between and includinglandu. Thus the subsystems can be run in parallel to the top system.The signatures of
fandgare those ofSMTSolver.define_funandSMTSolver.declare_fun, repsectively, partially evaluated with their first argument.
val uf_defs : t -> pred_def listReturn predicate definitions of initial state and transition relation of the top system and all its subsystem in reverse topological order
uf_defs treturns a list of predicate definitions of the top systemtand all its subsystems such that the definitions of a subsystem precede the definitions of all systems containing it. The definition of the initial state predicate precedes the definition of the transition relation predicate.
Properties
val property_of_name : t -> string -> Property.tval get_prop_term : t -> string -> Term.tReturn term of the property
get_prop_term t nreturns the term of the first property of namenin the transistion systemt.
val get_prop_status : t -> string -> Property.prop_statusReturn current status of the property
get_prop_status t nreturns the status saved in the transition system of the first property of namen.
val is_proved : t -> string -> boolReturn true if the property is proved invariant
val is_disproved : t -> string -> boolReturn true if the property is proved not invariant
val get_prop_status_all_nocands : t -> (string * Property.prop_status) listReturn current status of all properties excepted candidates
get_prop_status treturns the status saved in the transition system of each property along with the name of the property.
val get_prop_status_all_unknown : t -> (string * Property.prop_status) listReturn current status of all unknown properties
get_prop_status_all_unknown treturns the status saved in the transition system of each property which is considered to be unknown along with the name of the property.According to
Property.prop_status_known, a property is known if it is invariant, or has ak-step counterexample.
val props_list_of_bound : t -> Numeral.t -> (string * Term.t) listInstantiate all properties to the bound
val set_prop_status : t -> string -> Property.prop_status -> unitUpdate current status of the property
set_prop_status t n ssets the status saved in the transition system of the first property of namentos.
val set_prop_invariant : t -> string -> Certificate.t -> unitMark property as invariant
val set_prop_false : t -> string -> (StateVar.t * Model.value list) list -> unitMark property as false
val set_prop_ktrue : t -> int -> string -> unitMark property as k-true
val set_prop_unknown : t -> string -> unitval set_subsystem_properties : t -> Scope.t -> Property.t list -> tval has_properties : t -> boolReturns true iff sys has at least one property.
val all_props_proved : t -> boolReturn true if all properties which are not candidates are either valid or invalid
val at_least_one_prop_falsified : t -> boolReturn true if at least one prop has been falsified
val add_properties : t -> Property.t list -> tAdd properties to the transition system
val add_invariant : t -> Term.t -> Certificate.t -> bool -> Term.tAdd an invariant to the transition system.
val add_scoped_invariant : t -> string list -> Term.t -> Certificate.t -> bool -> Term.tAdd an invariant to the transition system.
Returns the normalized terms and a boolean indicating whether it is one state.
val invars_of_bound : ?one_state_only:bool -> t -> Numeral.t -> Term.t listInstantiate invariants and valid properties to the bound
val clear_invariants : t -> unitClear invariants of the top_level system
val clear_all_invariants : t -> unitClear invariants of all (sub)systems
val instantiate_term_all_levels : t -> Numeral.t -> Scope.t -> Term.t -> bool -> (t * Term.t list) * (t * Term.t list) listInstantiate a term of a given scope from all instances of the system of that scope upwards to the top system
instantiate_term_all_levels t i s e tsinstantiates the Boolean termeof scopesin all systems it is a subsystem of, and further upwards until the top systemt. The offsetiis the offset of the current instant in the terme.tsis true if the invariant is two states.Return the top system
spaired with the instances of the term in it, and a list of all systems between the top systemtand the systems, includingsbut excludingt, each system paired with the instances ofein it.The offset
iis needed to properly guard the termefor clocked system instances.
val get_state_var_bounds : t -> LustreExpr.expr LustreExpr.bound_or_fixed list StateVar.StateVarHashtbl.tReturn arrays bounds of state variables of array type used in the system
val instantiate_term_cert_all_levels : t -> Numeral.t -> Scope.t -> (Term.t * Certificate.t) -> bool -> (t * (Term.t * Certificate.t) list) * (t * (Term.t * Certificate.t) list) listSame as above but with certificates