HOL.Unification (hol v1.0.1)

View Source

This module provides the function unify/3 that tries to unify two terms.

Summary

Functions

This function tries to unify a set of terms with each other.

Functions

unify(terms, return_all_solutions \\ true, max_depth \\ 10)

This function tries to unify a set of terms with each other.

Returns a HOL.Data.Unification.unification_results/0 object that contains the summarized results.

Parameters

  • terms: A tuple containing two terms or a list of such tuples. The function only allows tuples with two terms.
  • return_all_solutions: If true tries to find all possible solutions it can. If false stops execution after finding one solution.
  • max_depth: How deep the function should look for solutions. The amount of branches that abort due to this constraint are reported in the result. If this value is set to a negative integer this constraint is removed.

Warning

This function is not guaranteed to terminate without a max_depth limit!

Example

# Create two terms to unify
iex> type_i = mk_type(:i, [])
iex> type_ii = mk_type(:i, [type_i])
iex> term_a = mk_free_var_term("x", type_ii) |> mk_appl_term(mk_const_term("c", type_i))
iex> PrettyPrint.pp_term(term_a)
"(x c)"
iex> term_b = mk_const_term("f", type_ii) |> mk_appl_term(mk_const_term("d", type_i))
iex> PrettyPrint.pp_term(term_b)
"(f d)"
iex> input = {term_a, term_b}
iex> result = unify(input)
iex> PrettyPrint.pp_res(result)
"{ max_depth reached 0 times; solutions: [{x <- (1. f d) , []}]}"
iex> get_solutions(result) |> hd() |> PrettyPrint.pp_sol()
"{x <- (1. f d) , []}"