package alt-ergo-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=39e2c9128a7d1e89f332e31a2716f359f3b9e1a925fe81f11fa4a749b5d24d82
sha512=ca953fe5a4964287de7e328ec4e3724a9baaa908c22862b075da5870bbf3707c7f78bd9fe0af98ee6c6382b5de0a4ddfcc93e09dc8b5b8e7d6ab6b1196a0656d
doc/alt-ergo-lib/AltErgoLib/Ty/index.html
Module AltErgoLib.Ty
Types
This module defines the representation of types.
Definition
type t = | Tint(*Integer numbers
*)| Treal(*Real numbers
*)| Tbool(*Booleans
*)| Tvar of tvar(*Type variables
*)| Tbitv of int(*Bitvectors of a given length
*)| Text of t list * Uid.ty_cst(*Abstract types applied to arguments.
*)Text (args, s)is the application of the abstract type constructorsto argumentsargs.| Tfarray of t * t(*Functional arrays.
*)TFarray (src,dst)maps values of typesrcto values of typedst.| Tadt of Uid.ty_cst * t list(*Application of algebraic data types.
Tadt (a, params)denotes the application of the polymorphic datatypeato the types parametersparams.For instance the type of integer lists can be represented by the value
*)Tadt (Hstring.make "list", [Tint]where the identifier list denotes a polymorphic ADT defined by the user witht_adt.| Trecord of trecord(*Record type.
*)
and tvar = {v : int;(*Unique identifier
*)mutable value : t option;(*Pointer to the current value of the type variable.
*)
}Type variables. The value field is mutated during unification, hence distinct types should have disjoints sets of type variables (see function fresh).
and trecord = {mutable args : t list;(*Arguments passed to the record constructor
*)name : Uid.ty_cst;(*Name of the record type
*)mutable lbs : (Uid.term_cst * t) list;(*List of fields of the record. Each field has a name, and an associated type.
*)record_constr : Uid.term_cst;(*record constructor. Useful is case it's a specialization of an algeberaic datatype. Default value is "{__
*)name"
}Record types.
type adt_constr = {constr : Uid.term_cst;(*constructor of an ADT type
*)destrs : (Uid.term_cst * t) list;(*the list of destructors associated with the constructor and their respective types
*)
}type type_body = adt_constr listBodies of types definitions. Currently, bodies are inlined in the type t for records and enumerations. But, this is not possible for recursive ADTs
val assoc_destrs : Uid.term_cst -> adt_constr list -> (Uid.term_cst * t) listassoc_destrs cons cases returns the list of destructors associated with the constructor cons in the ADT defined by cases.
val type_body : Uid.ty_cst -> t list -> type_bodyType inspection
val hash : t -> intHash function
val pp_smtlib : Format.formatter -> t -> unitPrinting function for types in smtlib2 format.
val print : Format.formatter -> t -> unitPrinting function for types (does not print the type of each fields for records).
val print_list : Format.formatter -> t list -> unitPrint function for lists of types (does not print the type of each fields for records).
val print_full : Format.formatter -> t -> unitPrint function including the record fields.
Building types
val tunit : tThe unit type.
val fresh_var : unit -> tvarGenerate a fresh type variable, guaranteed to be distinct from any other previously generated by this function.
val fresh_empty_text : unit -> tReturn a fesh abstract type.
val text : t list -> Uid.ty_cst -> tApply the abstract type constructor to the list of type arguments given.
val t_adt :
?body:(Uid.term_cst * (Uid.term_cst * t) list) list option ->
Uid.ty_cst ->
t list ->
tCreate an algebraic datatype. The body is a list of constructors, where each constructor is associated with the list of its destructors with their respective types. If body is none, then no definition will be registered for this type. The second argument is the name of the type. The third one provides its list of arguments.
val trecord :
?sort_fields:bool ->
record_constr:Uid.term_cst ->
t list ->
Uid.ty_cst ->
(Uid.term_cst * t) list ->
tCreate a record type. trecord args name lbs creates a record type with name name, arguments args and fields lbs.
If sort_fields is true, the record fields are sorted according to Hstring.compare. This is to preserve compatibility with the old typechecker behavior and should not be used in new code.
Substitutions
val print_subst : Format.formatter -> subst -> unitPrint function for substitutions.
val esubst : substThe empty substitution, a.k.a. the identity.
union_subst u v applies v to u, resulting in u'. It then computes the union of u' and v, prioritizing bindings from u' in case of conflict.
Unification/Matching
Exception raised during matching or unification. TypeClash (u, v) is raised when u and v could not be matched or unified (u and v may be sub-types of the types being actually unified or matched).
Matching of types (non-destructive). matching pat t returns a substitution subst such that apply_subst subst pat is equal to t.
Shorten paths in type variables values. Unification in particular can create chains where the value field of one type variable points to another and so on... This function short-circuits such chains so that the value of a type variable can be accessed directly.
Manipulations on types
Apply the given substitution, all while generating fresh variables for the variables not already bound in the substitution. Returns a substitution containing bindings from old variable to their fresh counterpart.
instantiate vars args t builds the substitutions mapping each type variable in vars to the corresponding term in args, then apply that substitution to t.
Return a monomorphized variant of the given type, where type variable without values have been replaced by abstract types.
val fresh_hypothesis_name : goal_sort -> stringcreate a fresh hypothesis name given a goal sort.
Assuming a name generated by fresh_hypothesis_name, answers whether the name design a local hypothesis ?
Assuming a name generated by fresh_hypothesis_name, does the name design a global hypothesis ?
val print_goal_sort : Format.formatter -> goal_sort -> unitPrint a goal sort