LustreExprInternal reperesentation of a Lustre expression
A LustreExpr.t does not contain node calls, temporal operators or expressions under a pre operator.
There is exactly one -> operator at the top of the expression, thus an expression can be represented as a pair of expressions (i, t) without -> operators.
The argument of a pre operator is always a variable, therefore an expression pre x can be represented by the variable x at the previous state.
A non-variable expression under a pre has to be abstracted to a fresh variable that is defined by this expression. There are no node calls in a Lustre expression. They have to be abstracted out and the results are captured in fresh variables. See LustreAstNormalizer for details about how the input file is translated
The offsets of state variable instances are zero for the initial state and zero for the current state, see the constants base_offset and cur_offset and pre_offset. These are different from the offsets in the transition system, because here we want to know if the initial and the step expressions are equal without bumping offsets. Use the functions base_term_of_expr, cur_term_of_expr, and pre_term_of_expr to take the expression on one side of the -> operator and adjust to the variable offsets to the given base.
Expressions can only be constructed with the constructors which do type checking and some easy simplifications with constants.
type expr = private Term.tA Term.t representing a Lustre expression, state variable offsets refer to the current and the previous instant.
Cannot be constructed outside this module to enforce invariants about allowed offsets of state variable instants, see the constructors below.
val is_true_expr : expr -> boolReturns true iff the expr is the constant true.
type t = private {expr_init : expr;Lustre expression for initial state
*)expr_step : expr;Lustre expression after initial state
*)expr_type : Type.t;Common type of both initial and the step expression
*)}A Lustre expression
The -> operator is moved to the top of the expression, the expression is to be interpreted as expr_init -> expr_step.
val hash : t -> intEquality of expressions
All pretty-printers take a Boolean flag as first argument, indicating if identifiers should be valid Lustre identifiers. If the flag is false, indexed identifiers are printed with [, ] and .. These characters are replaced with _ if the flag is true.
val pp_print_bound_or_fixed :
Stdlib.Format.formatter ->
expr bound_or_fixed ->
unitPretty-print a bound or fixed annotation
val pp_print_lustre_type : bool -> Stdlib.Format.formatter -> Type.t -> unitPretty-print a Lustre type
val pp_print_lustre_var : bool -> Stdlib.Format.formatter -> StateVar.t -> unitPretty-print a Lustre variable
val pp_print_lustre_var_typed :
bool ->
Stdlib.Format.formatter ->
StateVar.t ->
unitPretty-print a Lustre variable with its type
val pp_print_lustre_expr : bool -> Stdlib.Format.formatter -> t -> unitPretty-print a Lustre expression
Pretty-print a Lustre expression. The optional parameter as_type indicates that the expression should be printed as if it had this type (used for encoded enumerated datatypes).
val pp_print_lustre_expr_pvar :
bool ->
(Stdlib.Format.formatter -> StateVar.t -> unit) ->
Stdlib.Format.formatter ->
t ->
unitval pp_print_expr_pvar :
?as_type:Type.t ->
bool ->
(Stdlib.Format.formatter -> StateVar.t -> unit) ->
Stdlib.Format.formatter ->
expr ->
unitPretty-print a term as an expr.
val pp_print_term_as_expr_pvar :
?as_type:Type.t ->
bool ->
(Stdlib.Format.formatter -> StateVar.t -> unit) ->
Stdlib.Format.formatter ->
Term.t ->
unitPretty-print a term as an expr using the given printing function for state vars *
val pp_print_term_as_expr_mvar :
?as_type:Type.t ->
bool ->
string StateVar.StateVarMap.t ->
Stdlib.Format.formatter ->
Term.t ->
unitPretty-print a term as an expr using the given map from state vars to strings If a state variable is not in the map, the name of the state variable is used instead
Return true if the expression contains a previous state variable
val is_var : t -> boolReturn true if expression is a current state variable
val is_const_var : t -> boolReturn true if expression is a constant state variable
val is_pre_var : t -> boolReturn true if expression is a previous state variable
val pre_is_unguarded : t -> boolReturn true if there is an unguarded pre operator in the expression.
val is_const_expr : expr -> boolReturn true if the expression is constant
These offsets are different from the offsets in the transition system, because here we want to know if the initial and the step expressions are equal without bumping offsets. Use the constants base_offset, cur_offset or pre_offset of this module, or the constants TransSys.init_base and TransSys.trans_base for the zero offsets.
val base_offset : Numeral.tOffset of state variable at first instant
val cur_offset : Numeral.tOffset of state variable at current instant
val pre_offset : Numeral.tOffset of state variable at previous instant
val base_var_of_state_var : Numeral.t -> StateVar.t -> Var.tInstance of state variable at first instant with the given offset as zero
val cur_var_of_state_var : Numeral.t -> StateVar.t -> Var.tInstance of state variable at current instant with the given offset as zero
val pre_var_of_state_var : Numeral.t -> StateVar.t -> Var.tInstance of state variable at previous instant with the given offset as zero
val base_term_of_state_var : Numeral.t -> StateVar.t -> Term.tTerm of instance of state variable at first instant with the given offset as zero
val cur_term_of_state_var : Numeral.t -> StateVar.t -> Term.tTerm of instance of state variable at current instant with the given offset as zero
val pre_term_of_state_var : Numeral.t -> StateVar.t -> Term.tTerm of instance of state variable at previous instant with the given offset as zero
Term at first instant with the given offset as zero
Term at current instant with the given offset as zero
Term at previous instant with the given offset as zero
val state_var_of_expr : t -> StateVar.tReturn the state variable of a variable
Fail with Invalid_argument "state_var_of_expr" if the expression is not a variable at the current or previous offset.
Return the free variable of a expresion
Fail with Invalid_argument "var_of_expr" if the expression is not a free variable.
Return the free variable of the initial state expression
Fail with Invalid_argument "var_of_init_expr" if the initial state expression is not a free variable.
val state_vars_of_expr : t -> StateVar.StateVarSet.tReturn all state variables occurring in the expression in a set
val vars_of_expr : t -> Var.VarSet.tval select_terms : t -> Term.TermSet.tReturn the terms of the form (select ...) that appear in a expression
val base_state_vars_of_init_expr : t -> StateVar.StateVarSet.tReturn all state variables of the initial state expression at the base instant
val cur_state_vars_of_step_expr : t -> StateVar.StateVarSet.tReturn all state variables of the step expression at the current instant
val indexes_of_state_vars_in_init : StateVar.t -> t -> expr list listval indexes_of_state_vars_in_step : StateVar.t -> t -> expr list listSplit a list of Lustre expressions into a list of pairs of expressions for the initial step and the transition steps, respectively
val t_true : tThe propositional constant true
val t_false : tThe propositional constant false
The constructors do some easy simplifcations, such as arithmetic and Boolean operations on constants. If the types of the arguments are do not match the signature of the symbol, the Type_mismatch exception is raised.
val mk_var : StateVar.t -> tReturn an expression of a variable.
val int_of_index_var : t -> intReturn the number/position of the index variable.
val has_indexes : t -> boolReturns true if the expression has index variables.
Return the bitvector extraction of the third argument and the indices of the first and third expressions
mk_pre e returns the expression e if it is a constant, and the previous state variable if the expression is a current state variable.
Apply the pre operator to the expression, abstract the expression to a fresh variable if it is not a variable at the current state.
mk_pre_with_context f c b e returns the expression e and context c unchanged if it is a constant, and the previous state variable if the expression is a current state variable, again together with c unchanged.
Otherwise the expression e is abstracted to a fresh variable obtained by calling the function f, which returns a fresh state variable and a changed context c that records the association between the fresh variable and the expression. Then return an expression of the fresh state variable and the changed context.
b is used to denote that we're in a context where there are unguarded pres and so we should always introduce fresh intermediate variables.
val is_select : t -> boolReturns true if the expression is a selection in an array
val is_select_array_var : t -> boolReturns true if the expression is a selection of an array variable
val is_store : t -> boolReturns true if this is a store in an array
val mk_let_cur : (StateVar.t * t) list -> t -> tSubstitute state variable at current instant with expression
val mk_let_pre : (StateVar.t * t) list -> t -> tSubstitute state variable at previous instant with expression
Return an expression with the same term on both sides of the ->
val is_const : t -> boolReturn true if the expression is constant
val is_numeral : expr -> boolval mk_uf : UfSymbol.t -> Type.t -> t list -> tBuild a UF application expression with given return type and arguments
Build an ADT selector expression: (CtorName_i e) with the given result type
Return an expression where the top-level selects of the initial and/or the step expressions (if any) have been pushed