module CoreML: sig
.. end
This module provides all necessary types and functions to
work with the CoreML language. The CoreML languge extends pure
lambda-calculus with let-bindings (used for abbreviations) and
the conditional if-then-else-construct (together with the
boolean constants true and false).
type
var = Strng.t * int
Type for CoreML-variables. Variables are represented by l-strings, the integer was introduced for renaming-purposes.
type
cons =
Type for CoreML-constants. For now only the boolean constants True and False are supported.
type
t =
Type for CoreML-expressions.
type
dir =
Type used to relate to certain subparts of a CoreML-expression. E.g., the Left subpart of an application App (t, s) relates to t.
type
pos = dir list
Type for subterm-positons.
CONSTRUCTOR-FUNCTIONS
val var : Strng.t -> t
Variable-constructor, takes a variable-name as input and returns the corresponding CoreML-expression.
Returns CoreML-expression
val abs : Strng.t list -> t -> t
Abstraction-constructor, takes a list of variable-names and a CoreML-expression as input and returns the corresponding abstraction.
val app : t list -> t
Application-constructor, takes a list of CoreML-expression as input and returns the corresponding application.
val leti : Strng.t -> t -> t -> t
Let-binding-constructor, takes a variable-name, the abbreviation and the body-term and returns the corresponding let-binding.
val ite : t -> t -> t -> t
If-clause-constructor, takes the condition, the then-branch and the else-branch as arguments and return sthe corresponding if-clause.
val cons : cons -> t
Constant-constructor, takes a constant as argument and returns the corrspinding CoreML-expression
BASIC-FUNCTIONS
val vars : t -> var St.t
Returns a set containing all variables of a given CoreML-expression.
val fvars : t -> var St.t
Returns the set containing all free variables of a given CoreML-expression. A variable is considered to be free if it is not bound by an abstraction or a let-binding.
val substitute : var -> t -> t -> t
Substitutes CoreML-expression for variable inside a given CoreML-expression. This function avoids variable-capture by introducing fresh variables when needed.
val beta : t -> t
Applies beta-step to a given CoreML-expression. If the expression is not a redex, this function fails with an exception.
val is_redex : t -> bool
Checks if given CoreML-expression is a redex.
val redexpos : t -> pos list
Retrieves a list of a CoreML-expression's redex-positions.
val is_whnf : t -> bool
Checks if a given CoreML-expression is in weak-head-normal-form.
val is_nf : t -> bool
Checks if a given CoreML-expression is in normal form.
val is_closed : t -> bool
Checks if a given CoreML-expression is closed, i.e. does not contain any free variables.
val pos : t -> t -> pos list
Takes a base-term and a search-term as arguments and retrieves the positions of search-term inside the base-term.
val get : t -> pos -> t
Returns a base-term and a position as arguments and returns the subterm at the given position. This function fails with an exception if the supplied position is not valid for the given base-term.
val replace : t -> t -> pos -> t
Takes a base-term, a replace-term and a position as arguments. This function inserts the replace-term at the given position of the base-term and returns the resulting CoreML-expression. If the supplied position is not valid for the base-term, this function fails with an exception.
val replace_all : t -> (pos * t) list -> t
Takes a base-term and a list of replacements - a replacement is a position-CoreML-expression-pair - as arguments and performs all replacements on base-term. If any position is not valid this function fails with an exception.
REDUCTION-FUNCTIONS
val reduce_vars : t -> t
This function reduces all variable indexs of a given CoreML-expression to a minimum. This operation does not change the meaning of the expression.
module Strategies: sig
.. end
All reduction-strategies are managed inside this module.
val do_step : (t -> (pos * t) list) -> t -> t
Takes a reduction-strategy and a CoreML-expression as arguments and applies one single beta-reduction.
val calc_steps : (t -> (pos * t) list) ->
t -> (t * pos list) list
Takes a reduction-strategy and a CoreML-expression as arguments. This function returns the full reduction-sequence in a list.
val calc_nf : (t -> (pos * t) list) -> t -> t
Takes a reduction-strategy and a CoreML-expression as arguments and returns the calculated normal form of the given CoreML-expression.
PARSERS
val varname : Strng.t -> char list Parser.result
Combinator Parser for variable names.
val ltp : t Parser.t
Combinator Parser for CoreML-expressions.
PRINTER-FUNCTIONS
val var2strng : char list * int -> char list
String-converter for variables. Returns the l-string for a given variable-name and index.
val to_strng' : t -> Strng.t
Basic string-converter for CoreML-expressions. Returns the l-string for a given CoreML-expression without using conventions (no pretty printing).
val to_strng : t -> Strng.t
String-converter for CoreML-expressions. Returns the l-string for a given CoreML-expression using conventions (pretty printing: nested abstractions, fewer parenthesis).
val to_strng_mark' : pos list -> t -> Strng.t
Basic string-converter for CoreML-expressions supporting highlighted subterms. Returns the l-string for a given CoreML-expression where all subterms referenced by the provided position-list are highlighted. Does not use conventions for pretty-printing.
val to_strng_mark : pos list -> t -> Strng.t
String-converter for CoreML-expressions supporting highlighted subterms. Returns the l-string for a given CoreML-expression where all subterms referenced by the provided position-list are highlighted. Uses conventions for pretty-printing.