HOL.Data (hol v1.0.1)
View SourceThis module defines the datastructures used in the application
Summary
Types
Represents a bound variable.
Represents a constant.
Combination type representing free variables, bound variables and constants.
Represents a free variable.
Represents a term in the simply typed lambda calculus.
Represents a substitution of a free variable with a term
This type encodes the type information for a HOL term or declaration.
Declaration
Creates a new declaration. This function should not need be called under normal usage of this Package
Accessor function for type of declaration.
Accessor function for the identifier
Accessor function for the type
Creates a bound variable with the given id and type.
Creates a constant with the given name and type.
Creates a free variable with the given name and type.
Creates a free variable with a unique name and type.
Substitution
Accessor function for the free variable of the substitution
Accessor function for the term of the substitution
Creates a new substitution
Creates a new substitution.
Term
Accessor function for the arguments of the term
Accessor function for the bound variables of the term
Accessor function for the free variables in the term
Accessor function for head of the term
Accessor function for the max_num of the term
Accessor function for the type of the term
Creates a new term.
Type
Accessor function for argument types
Accessor function for goal type
Creates a base type without arguments.
Creates a type with the given arguments.
Creates a new type. This function should not need be called under normal usage of this Package
Types
@type bound_var_decl() :: {:decl, :bv, pos_integer(), type()}
Represents a bound variable.
The name must be a positive integer.
Represents a constant.
The name must be a string.
@type declaration() :: free_var_decl() | const_decl() | bound_var_decl()
Combination type representing free variables, bound variables and constants.
Key | Data stored | Accessor Function |
:kind | Whether it is a free or bound variable or constant | get_kind/1 |
:name | Name | get_name/1 |
:type | Type | get_type/1 |
Represents a free variable.
The name can be either a string or a reference.
@type hol_term() :: {:term, bvars :: [bound_var_decl()], head :: declaration(), args :: [hol_term()], type :: type(), fvars :: [free_var_decl()], max_num :: non_neg_integer()}
Represents a term in the simply typed lambda calculus.
Terms are always automatically beta-reduced and eta-expanded.
Key | Data stored | Accessor Function |
:bvars | A list of bound variables that are bound here | get_bvars/1 |
:head | The head of the term | get_head/1 |
:args | A list of terms that are applied to the head | get_args/1 |
:type | The type of the term | get_term_type/1 |
:fvars | A list of all free variables in the term | get_fvars/1 |
:max_num | The highest bound variable that is bound here or in one of the args | get_max_num/1 |
@type substitution() :: {:subst, fvar :: free_var_decl(), term :: hol_term()}
Represents a substitution of a free variable with a term
Key | Data stored | Accessor Function |
:fvar | Free Variable to Replace | get_fvar/1 |
:term | Replacement Term | get_term/1 |
This type encodes the type information for a HOL term or declaration.
It has its goal type stored as an atom, with all input types in a list.
Key | Data stored | Accessor Function |
:goal | Goal Type | get_goal_type/1 |
:args | List of argument types | get_arg_types/1 |
Examples
# base type i is encoded as
iex> mk_type(:i)
{:type, :i, []}
# function type i->o is encoded as
iex> mk_type(:o, [mk_type(:i)])
{:type, :o, [{:type, :i, []}]}
Functions
Declaration
Creates a new declaration. This function should not need be called under normal usage of this Package
This Dataformat uses a Record
.
@spec get_kind(declaration()) :: :fv | :bv | :co
Accessor function for type of declaration.
Returns
:fv
when given a free variable:bv
when given a bound variable:co
when given a constant
@spec get_name(declaration()) :: String.t() | pos_integer() | reference()
Accessor function for the identifier
@spec get_type(declaration()) :: type()
Accessor function for the type
@spec mk_bound_var(non_neg_integer(), type()) :: bound_var_decl()
Creates a bound variable with the given id and type.
This function should not need be called under normal usage of this Package
Example
iex> mk_bound_var(1, mk_type(:i))
{:decl, :bv, 1, {:type, :i, []}}
@spec mk_const(String.t(), type()) :: const_decl()
Creates a constant with the given name and type.
Example
iex> mk_const("x", mk_type(:i))
{:decl, :co, "x", {:type, :i, []}}
@spec mk_free_var(String.t(), type()) :: free_var_decl()
Creates a free variable with the given name and type.
Also see function mk_uniqe_var/1
for creating a uniqe variable
Example
iex> mk_free_var("x", mk_type(:i))
{:decl, :fv, "x", {:type, :i, []}}
@spec mk_uniqe_var(type()) :: free_var_decl()
Creates a free variable with a unique name and type.
The name is created via the function Kernel.make_ref/0
. See the corresponding documentation for the limitations of this function.
Also see function mk_free_var/2
for creating a named free variable
Substitution
@spec get_fvar(substitution()) :: free_var_decl()
Accessor function for the free variable of the substitution
@spec get_term(substitution()) :: hol_term()
Accessor function for the term of the substitution
@spec mk_substitution(free_var_decl(), hol_term()) :: substitution()
Creates a new substitution
Creates a new substitution.
This Dataformat uses a Record
.
Term
Accessor function for the arguments of the term
@spec get_bvars(hol_term()) :: [bound_var_decl()]
Accessor function for the bound variables of the term
@spec get_fvars(hol_term()) :: [free_var_decl()]
Accessor function for the free variables in the term
@spec get_head(hol_term()) :: declaration()
Accessor function for head of the term
@spec get_max_num(hol_term()) :: non_neg_integer()
Accessor function for the max_num of the term
Accessor function for the type of the term
Creates a new term.
For creating new terms see HOL.Terms.mk_term/1
This function should not need be called under normal usage of this Package.
This Dataformat uses a Record
.
Type
Accessor function for argument types
Accessor function for goal type
Creates a base type without arguments.
Examples
# Creates base type i
iex> mk_type(:i)
{:type, :i, []}
# Creates base type o
iex> mk_type(:o)
{:type, :o, []}
Creates a type with the given arguments.
The goal type is always stored as an atom, but it doesn't have to be given as such
Parameters
- goal_type: Atom or
type()
that represents the goal type - arg_types: List of
type()
that represents the argument types
Examples
# Creates type i->i
iex> mk_type(:i, [mk_type(:i)])
{:type, :i, [{:type, :i, []}]}
# Creates type i->i->i
iex> mk_type(mk_type(:o, [mk_type(:i)]), [mk_type(:i)])
{:type, :o, [{:type, :i, []}, {:type, :i, []}]}
# Creates type i->i->i (identical to previous)
iex> mk_type(:o, [mk_type(:i), mk_type(:i)])
{:type, :o, [{:type, :i, []}, {:type, :i, []}]}
# Creates type (i->i)->i->i
iex> mk_type(:i, [mk_type(:i, [mk_type(:i)]), mk_type(:i)])
{:type, :i, [{:type, :i, [{:type, :i, []}]}, {:type, :i, []}]}
Creates a new type. This function should not need be called under normal usage of this Package
This Dataformat uses a Record
.