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
5
votes
1 answer

Feature structure unification in minikanren

How would one define a feature structure unification and subsumption in minikanren if we represent feature structures with lists? The general behaviour would be something like this (I think): (run* (q) (unifyo '(a b) '(a b) q))) => (a b) (run* (q)…
5
votes
1 answer

Instantiate type variable in Haskell

EDIT: Solved. I was unware that enabling a language extension in the source file did not enable the language extension in GHCi. The solution was to :set FlexibleContexts in GHCi. I recently discovered that type declarations in classes and instances…
danportin
  • 5,243
  • 1
  • 23
  • 42
5
votes
1 answer

is_list/1 and free variables

Here is a first observation: ?- is_list([]), is_list([_,_,_]). true. Here is another observation: ?- [] = _, [_,_,_] = _. true. Therefore, why would is_list/1 be implemented such that ?- is_list(_). false. or ?- is_list([_|_]). false. when _ can…
Fatalize
  • 3,433
  • 13
  • 23
5
votes
1 answer

In a Warren's Abstract Machine, how does bind work, if one of the arguments is a register?

I'm trying to create my own WAM implementation and I'm stuck at the exercise 2.4 I can't understand how to execute instruction unify_value X4 in figure 2.4. As far as I understand, this instruction should unify Y from the program with f(W) from the…
Orfest
  • 125
  • 6
5
votes
2 answers

Finding algorithm to seek argument to satisfy given function's return

I have this particular problem for which I don't have a solution yet. I think it would help if I know it exists a related algorithm. The algorithm I'm looking for is one that helps find an argument that satisfies a goal returned by a function. For…
4
votes
2 answers

Requires MonadPlus (ST a) Instance

I'm reading the paper Typed Logical Variables in Haskell, but I'm failing to understand the details of the ultimate implementation. In particular, the backtracking state transformer introduced in section 4. For some reason, unknown to me, GHC…
danportin
  • 5,243
  • 1
  • 23
  • 42
4
votes
1 answer

Generalized HM vs. Higher-Order Unification

AFAIK, unification used in the Hindley-Milner type system can be generalized to unify higher-kinded types by allowing type vars in constructor position and by relaxing the arity constraint in such cases: f a ~ T a1 b1 f ~ T a1 -- generatifity +…
4
votes
2 answers

Implementing unification and skipping variables

I'm working on an implementation of the usual unification algorithm in the usual way: recursive descent through expression trees, adding variable bindings to a hash table along the way, doing the occurs check. In Java as it happens, using override…
rwallace
  • 26,045
  • 30
  • 102
  • 195
4
votes
1 answer

What algorithms does the Rust compiler use to infer lifetime variables?

fn foo<'a>(x: &'a i32, y: &'a i32) {} fn main() { let a = 123; { let b = 234; foo(&a, &b); } } In the code above &a and &b should hopefully be references with different lifetimes. How does the compiler infer the…
user181351
4
votes
2 answers

Type Parameter Unification

Why is this disallowed in C#? alt text http://img706.imageshack.us/img706/7360/restriction.png Actually I'd like to be able to write alias Y : X, X The unification is actually desired here; if the A = B then just one method should…
Bent Rasmussen
  • 5,158
  • 7
  • 40
  • 60
4
votes
1 answer

How to query the unification type to ghci?

It is possible to query ghci for an unification type? For example, if I want to know the type of the unification between (Int -> Bool) and (a -> Bool) how can I query this to ghci? What I'm trying to solve is the exercise 13.23 from third edition of…
Fof
  • 307
  • 1
  • 8
4
votes
2 answers

prolog unification resolution

Why does this work: power(_,0,1) :- !. power(X,Y,Z) :- Y1 is Y - 1, power(X,Y1,Z1), Z is X * Z1. And this gives a stack overflow exception? power(_,0,1) :- !. power(X,Y,Z) :- power(X,Y - 1,Z1), Z is X * Z1.
TheOne
  • 9,685
  • 19
  • 74
  • 111
4
votes
1 answer

Algorithms for Unification of list-based trees

I need a unification algorithm to handle the following situation. Each node in my expression tree has a list (associative) or a set (associative and commutative) of children. I would like to get all possible matches to a specific pattern. Here is…
3
votes
0 answers

Non-linearity of Wielemaker-Demoen Unification

This is a follow up to the question here about acyclic terms. I am now interested in cyclic terms, and it seems their unification is not anymore linear in the Wielemaker-Demoen unification. The test case is basically: ?- X = f(f(X)), Y = f(f(f(Y))),…
Mostowski Collapse
  • 12,118
  • 3
  • 34
  • 78
3
votes
0 answers

Paterson-Wegman versus Wielemaker-Demoen Unification

The source code of SWI-Prolog says that the unification deployed is based on some idea from Bart Demoen. The core of the SWI-Prolog unification does detect reoccuring compounds and can therefore handle cyclic terms. But reoccuring compounds are also…
Mostowski Collapse
  • 12,118
  • 3
  • 34
  • 78
1 2
3
13 14