dolmen

A parser library for automated deduction
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library dolmen.std
Module Dolmen_std . Expr . Ty
Usual definitions
type t = ty

The type of types.

type subst = ( ty_var, ty ) Subst.t

The type of substitutions over types.

type 'a tag = 'a Tag.t

A type for tags to attach to arbitrary types.

exception Bad_arity of ty_cst * t list

Raised when applying a type constant to the wrong number of arguments.

exception Prenex_polymorphism of t

Raised when the type provided is polymorphic, but occurred in a place where polymorphic types are forbidden by prenex/rank-1 polymorphism.

val hash : t -> int

A hash function for types, should be suitable to create hashtables.

val equal : t -> t -> bool

An equality function on types. Should be compatible with the hash function.

val compare : t -> t -> int

Comparison function over types. Should be compativle with the equality function.

val print : Stdlib.Format.formatter -> t -> unit

Printing function.

Alias management
val alias_to : ty_cst -> ty_var list -> ty -> unit

Alias the given type constant.

val expand_head : t -> t

Expand head aliases.

View
type view = [
| `Prop(*

Propositions/booleans

*)
| `Int(*

Integers

*)
| `Rat(*

Rationals

*)
| `Real(*

Reals

*)
| `Array of ty * ty(*

Function arrays, from source to destination type.

*)
| `Bitv of int(*

Bitvectors of fixed length.

*)
| `Float of int * int(*

Floating points.

*)
| `String(*

Strings

*)
| `String_reg_lang(*

Regular languages over strings

*)
| `Var of ty_var(*

Variables (excluding wildcards)

*)
| `Wildcard of ty_var(*

Wildcards

*)
| `App of [ `Generic of ty_cst | `Builtin of builtin ] * ty list(*

Generic applications.

*)
| `Arrow of ty list * ty
| `Pi of ty_var list * ty
]

View on types.

val view : t -> view

View on types.

val pi_arity : t -> int

Reutnrs the number of expected type arguments that the given type expects (i.e. the number of prenex polymorphic variables in the given type).

val poly_sig : t -> ty_var list * ty list * ty

Split a type into a polymorphic signature.

Type structure definition
type adt_case = {
cstr : term_cst;
tester : term_cst;
dstrs : term_cst option array;
}

One case of an algebraic datatype definition.

type def =
| Abstract
| Adt of {
ty : ty_cst;
record : bool;
cases : adt_case array;
}

The various ways to define a type inside the solver.

val define : ty_cst -> def -> unit

Register a type definition.

val definition : ty_cst -> def option

Return the definition of a type (if it exists).

Variables and constants
module Var : sig ... end

A module for variables that occur in types.

module Const : sig ... end

A module for constant symbols the occur in types.

val prop : t

The type of propositions

val bool : t

Alias for prop.

val unit : t

The unit type.

val base : t

An arbitrary type.

val int : t

The type of integers

val rat : t

The type of rationals

val real : t

The type of reals.

val string : t

The type of strings

val string_reg_lang : t

The type of regular language over strings.

val of_var : Var.t -> t

Create a type from a variable.

val apply : Const.t -> t list -> t

Application for types.

val arrow : t list -> t -> t

Create an arrow type (i.e. function type)

val pi : Var.t list -> t -> t

Create a prenex/rank-1 polymorphic type.

val array : t -> t -> t

Build an array type from source to destination types.

val bitv : int -> t

Bitvectors of a given length.

val float : int -> int -> t

Floating point of given exponent and significand.

val roundingMode : t

Type for the various Floating point rounding modes.

val subst : ?fix:bool -> subst -> t -> t

Substitution on types.

val fv : t -> Var.t list

Returns the list of free variables in the type.

val unify : t -> t -> t option

Try and unify two types.

val set_wildcard : ty_var -> t -> unit

Instantiate the given wildcard.

val add_wildcard_hook : hook:( ty_var -> ty -> unit ) -> ty_var -> unit

Tag for hooks called upon the wildcard instantiation.

val get_tag : t -> 'a Tag.t -> 'a option

Get the value bound to a tag.

val get_tag_list : t -> 'a list Tag.t -> 'a list

Get the list of values bound to a list tag, returning the empty list if no value is bound.

val get_tag_last : t -> 'a list Tag.t -> 'a option

Get the last value bound to a list tag.

val set_tag : t -> 'a Tag.t -> 'a -> unit

Set the value bound to the tag.

val add_tag : t -> 'a list Tag.t -> 'a -> unit

Bind an additional value to a list tag.

val add_tag_opt : t -> 'a list Tag.t -> 'a option -> unit

Optionally bind an additional value to a list tag.

val add_tag_list : t -> 'a list Tag.t -> 'a list -> unit

Bind a list of additional values to a list tag.

val unset_tag : t -> _ Tag.t -> unit

Remove the binding to the given tag.