LustreAstMinimally simplified Lustre abstract syntax tree
The types in this module closely represent the abstract syntax of Lustre. No type checking or simplification is performed when constructing the abstract syntax tree, this is done when producing the intermediate Lustre representation in LustreNodeGen.
Some values are reserved for future use and will cause the translation to intermediate Lustre to fail.
A Lustre file is parsed into a declaration list, where a declaration is either
type t = t',const c = v, orAlmost all types are annotated with the position in the input file for better error reporting in the translation.
module NI = NodeIdtype ident = HString.tAn identifier
module SI : sig ... endtype index = HString.tA single index
A clock expression
type binary_operator = | And| AndThen| Or| OrElse| Xor| Impl| LazyImpl| In of in_kind| Mod| Minus| Plus| Div| Times| IntDiv| BVAnd| BVOr| BVShiftL| BVShiftR| BVConcat| Union| Intersection| DifferenceWhether an Index within a structural update (StructUpdate) replaces a tuple slot or an array element.
Only user-written selectors carry a proof obligation
type pattern = | VarPat of Lib.position * identvariable binding
*)| Pat of Lib.position * ident * pattern listconstructor pattern
*)Pattern for match expressions
type lustre_type = | Bool of Lib.position| Int of Lib.position| SBitVector of Lib.position * int| UBitVector of Lib.position * int| Real of Lib.position| UserType of Lib.position * lustre_type list * ident| AbstractType of Lib.position * ident| TupleType of Lib.position * lustre_type list| GroupType of Lib.position * lustre_type list| RecordType of Lib.position * ident * typed_ident list| ArrayType of Lib.position * lustre_type * expr| EnumType of Lib.position * ident * ident list| History of Lib.position * ident| TArr of Lib.position * lustre_type * lustre_type| RefinementType of Lib.position * typed_ident * expr| Map of Lib.position * lustre_type * lustre_type| Set of Lib.position * lustre_type| ADT of Lib.position * ident * (ident * (ident * lustre_type) list) listA Lustre type
and proj_kind = | Unresolved| RecordFieldOrigin, the ADT type, and the constructor whose payload holds the field.
*)| Selector of selector_origin * lustre_type * identand expr = | Ident of Lib.position * ident| ModeRef of Lib.position * ident list| FieldProject of Lib.position * expr * index * proj_kind| Const of Lib.position * constant| UnaryOp of Lib.position * unary_operator * expr| BinaryOp of Lib.position * binary_operator * expr * expr| TernaryOp of Lib.position * ternary_operator * expr * expr * expr| ConvOp of Lib.position * conversion_operator * expr| CompOp of Lib.position * comparison_operator * expr * expr| AnyOp of Lib.position * typed_ident * expr| ChooseOp of Lib.position * typed_ident * expr| Extract of Lib.position * expr * int * int| RecordExpr of Lib.position * ident * lustre_type list * (ident * expr) list| GroupExpr of Lib.position * group_expr * expr list| StructUpdate of Lib.position * expr * label_or_index list * expr option| EmptyMap of Lib.position * (lustre_type * lustre_type) option| EmptySet of Lib.position * lustre_type option| ArrayConstr of Lib.position * expr * expr| IndexAccess of Lib.position * expr * expr * access_kind| Quantifier of Lib.position * quantifier * typed_ident list * expr| When of Lib.position * expr * clock_expr| Condact of Lib.position * expr * expr * NI.t * expr list * expr list| Activate of Lib.position * NI.t * expr * expr * expr list| Merge of Lib.position * ident * (ident * expr) list| RestartEvery of Lib.position * NI.t * expr list * expr| Pre of Lib.position * expr| Arrow of Lib.position * expr * expr| Last of Lib.position * ident| Call of Lib.position * lustre_type list * NI.t * expr list| TypeAscription of Lib.position * expr * lustre_type| ADTTerm of Lib.position * lustre_type list * ident * expr list| Match of Lib.position * expr * (pattern * expr) list * lustre_type optionSymbolic default value for an abstract type, used as a junk payload field in desugared ADTs.
*)| AbstractSymConst of Lib.position * lustre_type| ADTTester of Lib.position * expr * identA Lustre expression
and typed_ident = Lib.position * ident * lustre_typeAn identifier with a type
and label_or_index = | Label of Lib.position * index| Index of Lib.position * expr * struct_update_index_kindSet by the type checker from the updated expression's type: whether this replaces a whole tuple slot or a single array element.
*)| MapIndex of Lib.position * expr| SetIndex of Lib.position * expr| GenericIndex of Lib.position * exprA record field or an array or tuple index
type type_decl = | AliasType of Lib.position * ident * ident list * lustre_type| FreeType of Lib.position * identA declaration of an alias or free type
type clocked_typed_decl = Lib.position * ident * lustre_type * clock_exprAn identifier with a type and a clock as used for the type of variables
type const_clocked_typed_decl =
Lib.position * ident * lustre_type * clock_expr * boolAn identifier, possibly flagged as constant, with a type and a clock as used for the type of variables
type const_decl = | FreeConst of Lib.position * ident * lustre_type| UntypedConst of Lib.position * ident * expr| TypedConst of Lib.position * ident * expr * lustre_typeA constant declaration
type node_local_decl = | NodeConstDecl of Lib.position * const_decl| NodeVarDecl of Lib.position * clocked_typed_declA local constant or variable declaration of a node
type struct_item = | SingleIdent of Lib.position * ident| TupleStructItem of Lib.position * struct_item list| TupleSelection of Lib.position * ident * expr| FieldSelection of Lib.position * ident * ident| ArraySliceStructItem of Lib.position * ident * (expr * expr) list| ArrayDef of Lib.position * ident * ident listStructural assignment on the left-hand side of an equation
The left-hand side of an equation
An equation or assertion in the node body
For reachable properties, the user can optionally specify a bound to look for a witness from/within/at a certain timestep
Whether a property is reachable or invariant
type node_item = | Body of node_equation| IfBlock of Lib.position * expr * node_item list * node_item list| WhenBlock of Lib.position * expr * node_item list * node_item list| FrameBlock of Lib.position
* (Lib.position * ident) list
* node_equation list
* node_item list| AnnotMain of Lib.position * bool| AnnotProperty of Lib.position * HString.t option * expr * prop_kind| Auto of Lib.positionNo-op item, only allowed in the body of a lemma
*)An item in a node declaration
type contract_ghost_const = const_decltype contract_ghost_vars = Lib.position * contract_eq_lhs * exprtype contract_assume = Lib.position * HString.t option * bool * exprtype contract_guarantee = Lib.position * HString.t option * bool * exprtype contract_require = Lib.position * HString.t option * exprtype contract_ensure = Lib.position * HString.t option * exprtype contract_mode =
Lib.position * ident * contract_require list * contract_ensure listtype contract_call =
Lib.position * NI.t * lustre_type list * expr list * ident listtype contract_assump_vars = Lib.position * (Lib.position * HString.t) listtype decreases_clause = Lib.position * exprtype contract_node_equation = | GhostConst of contract_ghost_const| GhostVars of contract_ghost_vars| Assume of contract_assume| Guarantee of contract_guarantee| Mode of contract_mode| ContractCall of contract_call| AssumptionVars of contract_assump_vars| Decreases of decreases_clausetype contract = Lib.position * contract_node_equation listtype node_decl =
NI.t
* bool
* opacity
* ident list
* const_clocked_typed_decl list
* clocked_typed_decl list
* node_local_decl list
* node_item list
* contract optionDeclaration of a node or function as a tuple of
type contract_node_decl =
NI.t
* ident list
* const_clocked_typed_decl list
* clocked_typed_decl list
* contractA contract node declaration as a tuple of
contract.type node_param_inst = ident * ident * lustre_type listAn instance of a parametric node as a tuple of the identifier for the instance, the identifier of the parametric node and the list of type parameters
type declaration = | TypeDecl of span * type_decl| ConstDecl of span * const_decl| NodeDecl of span * node_decl| FuncDecl of span * node_decl * func_attrs| ContractNodeDecl of span * contract_node_decl| NodeParamInst of span * node_param_instA declaration of a type, a constant, a node, a function or an instance of a parametric node
type t = declaration listA Lustre program as a list of declarations
val pp_print_node_param_list : Stdlib.Format.formatter -> ident list -> unitPretty-printers
val pp_print_pattern : Stdlib.Format.formatter -> pattern -> unitval pp_print_ident : Stdlib.Format.formatter -> ident -> unitval pp_print_label_or_index : Stdlib.Format.formatter -> label_or_index -> unitval pp_print_expr : Stdlib.Format.formatter -> expr -> unitval pp_print_clock_expr : Stdlib.Format.formatter -> clock_expr -> unitval pp_print_lustre_type : Stdlib.Format.formatter -> lustre_type -> unitval pp_print_typed_ident : Stdlib.Format.formatter -> typed_ident -> unitval pp_print_clocked_typed_ident :
Stdlib.Format.formatter ->
(Lib.position * ident * lustre_type * clock_expr) ->
unitval pp_print_const_clocked_typed_ident :
Stdlib.Format.formatter ->
(Lib.position * ident * lustre_type * clock_expr * bool) ->
unitval pp_print_type_decl : Stdlib.Format.formatter -> type_decl -> unitval pp_print_var_decl :
Stdlib.Format.formatter ->
(Lib.position * ident * lustre_type * clock_expr) ->
unitval pp_print_const_decl : Stdlib.Format.formatter -> const_decl -> unitval pp_print_node_local_decl_var :
Stdlib.Format.formatter ->
node_local_decl ->
unitval pp_print_node_local_decl_const :
Stdlib.Format.formatter ->
node_local_decl ->
unitval pp_print_node_local_decl :
Stdlib.Format.formatter ->
node_local_decl list ->
unitval pp_print_struct_item : Stdlib.Format.formatter -> struct_item -> unitval pp_print_eq_lhs : Stdlib.Format.formatter -> eq_lhs -> unitval pp_print_contract_eq_lhs :
Stdlib.Format.formatter ->
contract_eq_lhs ->
unitval pp_print_node_body : Stdlib.Format.formatter -> node_equation -> unitval pp_print_node_item : Stdlib.Format.formatter -> node_item -> unitval pp_print_declaration : Stdlib.Format.formatter -> declaration -> unitval pp_print_program : Stdlib.Format.formatter -> t -> unitval pp_print_contract_item :
Stdlib.Format.formatter ->
contract_node_equation ->
unitval pp_print_contract_node_decl :
Stdlib.Format.formatter ->
contract_node_decl ->
unitval string_of_expr : expr -> string