The syntactic unification algorithm is a recursive algorithm that returns the most general unifier of two logical predicates, if it exists.
Process
Inputs: , two logical predicate formulae
- Initialise the set of equations and add the equality (potentially as a tuple) to it.
- Repeat the following continuously (while) contains equations of the forms below, do the associated operation
Form | Meaning | Operation |
---|---|---|
where and are terms and is a function | Same Function Signature | Decompose into equations and add them to |
where and are terms are functions OR | Different Function Signature | No way of unification, halt/fail |
where is a variable | Redundant Equation | Delete the equation from |
where is a variable is a function containing | Infinite Loop | No way of unification, halt/fail |
or where is a variable is a function is a constant | Opposite Sides, | Swap the equation ( on LHS) and replace in |
where is a variable is a term that doesn’t contain or equal | Valid Renaming | Treat as , apply the renaming to all other equations in |
- Finally, switch all to to create the final mapping.
- Return
Properties
- This algorithm always halts, so the problem of syntactic unification is decidable
- If the algorithm fails, it guarantees that and are non-unifiable
- Else, the resultant unifier is a most general unifier
Time Complexity
Case Scenario | Input Description | Growth Function | Big-O | Notes |
---|---|---|---|---|
Worst | ||||
Average | ||||
Best | ||||
^time-complexity |