Module Logtk.TypeInference (.ml)

module TypeInference: LogtkTypeInference

type 'a or_error = [ `Error of string | `Ok of 'a ] 

Default LogtkTypes

type default_types = {
   default_i : LogtkType.t;
   default_prop : LogtkType.t;
   default_int : LogtkType.t;
   default_rat : LogtkType.t;
val tptp_default : default_types
Default TPTP types for ints, rats, etc.

Typing context

This module provides a typing context, with an applicative interface. The context is used to map terms to types locally during type inference. It also keeps and updates a signature when symbols' types are inferred.

This module is quite low-level, and shouldn't be used in simple cases (see the following modules)

module Ctx: sig .. end


A closure is a function that returns a 'a value if provided with a proper type inference context. It is useful to delay the translation from untyped terms to typed terms, because locally we don't have applied all the type constraints resulting from the context yet. Therefore, when inferring the type of a subterm, we apply local constraints, and return a closure that, given the final environment, converts the subterm into a typed term.

For instance, if we infer the type of nil in the terms cons(1, nil) and cons("foo", nil), we can't infer the most specialized type for nil unless we also take its context (cons(_,_)) into account. The same closure will therefore be used to build nil:$int and nil:$string respectively.

module Closure: sig .. end

Hindley-Milner LogtkType Inference

This module, abstract in the exact kind of term it types, takes as input a signature and an untyped term, and updates the typing context so that the untyped term can be converted into a typed term.

module type S = sig .. end
val map_error_seq : ('a -> 'b or_error) ->
'a Sequence.t -> 'b Sequence.t or_error
map_error_seq f seq maps f over the sequence seq, and returns the (persistent) sequence of result if all calls to f succeed. Otherwise it returns the first encountered error.
module FO: sig .. end
module HO: sig .. end