Questions tagged [unification]

Unification, in computer science and logic, is an algorithmic process by which one attempts to solve the satisfiability problem. The goal of unification is to find a substitution which demonstrates that two seemingly different terms are in fact either identical or just equal.

Unification, in computer science and logic, is an algorithmic process by which one attempts to solve the satisfiability problem. The goal of unification is to find a substitution which demonstrates that two seemingly different terms are in fact either identical or just equal.

Unification is widely used in automated reasoning, logic programming and programming language type system implementation. In particular, it is widely used in type deduction for example in C++ templates type deduction or in functional language such as Scala/Ocaml/Haskell type synthesis.

Several kinds of unification are commonly studied: syntactic unification (for theories without any equations) and semantic unification (for non-empty equational theories).

See also

207 questions
56
votes
4 answers

Higher-order unification

I'm working on a higher-order theorem prover, of which unification seems to be the most difficult subproblem. If Huet's algorithm is still considered state-of-the-art, does anyone have any links to explanations of it that are written to be…
rwallace
  • 26,045
  • 30
  • 102
  • 195
37
votes
5 answers

Unification with STO detection

In ISO Prolog unification is defined only for those cases that are NSTO (not subject to occurs-check). The idea behind is to cover those cases of unifications that are mostly used in programs and that are actually supported by all Prolog systems.…
false
  • 10,182
  • 12
  • 93
  • 182
32
votes
2 answers

What is the difference between == and = in Prolog?

Can someone explain the difference between the == and the = operator in Prolog? I know that X = Y means X unifies with Y and is true if X already unifies with Y or can be made to, but I don't understand how this differs from ==. Follow up: That (see…
JohnS
  • 1,082
  • 1
  • 11
  • 21
29
votes
2 answers

Is it possible to get the infinite kind error in Haskell 98?

I am implementing a kind system for a new functional programming language and I am currently writing the function to unify two kinds. There are four cases two consider: +---------+---------+-------------------------------------------------------+ | …
Aadit M Shah
  • 67,342
  • 26
  • 146
  • 271
26
votes
4 answers

Differences between pattern matching and unification?

I thought I understand how pattern matching like found in Scala and Haskell is different from unification found in Prolog but my misunderstands of Prolog is great. What is some simple problems solvable by one that cannot be solved by the…
Eli Schneider
  • 4,717
  • 3
  • 24
  • 50
23
votes
4 answers

Prolog, access specific member of list?

Can anyone tell me how to access a specific member of a list in prolog? Say for example I need to access the 3rd or 4th element of a list passed into a rule?
David Carpenter
  • 1,066
  • 2
  • 12
  • 25
17
votes
4 answers

How can I implement the unification algorithm in a language like Java or C#?

I'm working through my AI textbook I got and I've come to the last homework problem for my section: "Implement the Unification Algorithm outlined on page 69 in any language of your choice." On page 69, you have the following pseudo-code for the…
Mithrax
  • 7,053
  • 17
  • 52
  • 58
15
votes
2 answers

Why don't Func<...> and Action unify?

I find myself constantly wanting to pass a Func with a return and no inputs in place of an Action, for example Func DoSomething = ...; Task.Run(DoSomething); where, I don't really care about the return value of DoSomething. These types don't…
mjgpy3
  • 7,413
  • 4
  • 25
  • 47
15
votes
5 answers

Haskell: how to infer the type of an expression manually

Given ist the Haskell function: head . filter fst The question is now how to find the type "manually" by hand. If I let Haskell tell me the type I get: head . filter fst :: [(Bool, b)] -> (Bool, b) But I want to understand how this works using…
mythbu
  • 509
  • 1
  • 6
  • 16
13
votes
2 answers

Seemingly unnecessary case in the unification algorithm in SICP

I'm trying to understand the unification algorithm described in SICP here In particular, in the procedure "extend-if-possible", there's a check (the first place marked with asterix "*") which is checking to see if the right hand "expression" is a…
Paul Hollingsworth
  • 11,954
  • 12
  • 48
  • 66
12
votes
1 answer

Hindley-Milner algorithm: using types to ensure bindings are applied

I am implementing the Hindley-Milner type inference algorithm, following the tutorials of Mark Jones and Oleg Kiselyov. Both of these have an "apply bindings" operation with a type roughly of the form applyBindings :: TyEnv -> Type -> Type which…
reinerp
  • 3,504
  • 1
  • 15
  • 20
12
votes
1 answer

Prolog is vs = with lists

Why does this fail L is [1,2,3,4], and this works: L = [1,2,3]? But L is 1, and L = 1 both work the same.
TheOne
  • 9,685
  • 19
  • 74
  • 111
11
votes
2 answers

What is the optimal "most general unifier" algorithm?

The Question What is the most efficient MGU algorithm? What is its time complexity? Is it simple enough to describe in a stack overflow answer? I've been trying to find the answer on Google but keep finding private PDFs that I can only access via an…
Paul Hollingsworth
  • 11,954
  • 12
  • 48
  • 66
11
votes
3 answers

Implementing the Prolog Unification algorithm in Python? Backtracking

I'm trying to implement Unification, but having problems.. already got dozen of examples,but all they do is to muddy the water. I get more confused than enlightened…
sten
  • 5,313
  • 6
  • 33
  • 43
11
votes
2 answers

Why double negation doesn't bind in Prolog

Say I have the following theory: a(X) :- \+ b(X). b(X) :- \+ c(X). c(a). It simply says true, which is of course correct, a(X) is true because there is no b(X) (with negation as finite failure). Since there is only a b(X) if there is no c(X) and…
Willem Van Onsem
  • 321,217
  • 26
  • 295
  • 405
1
2 3
13 14