Unification - Infinity of Results

I am developing (in Java) for entertainment an application that uses a unification algorithm.

I chose that my union algorithm returns all possible unifications. For example, if I try to solve

add (X, Y) = succ (succ (0))

he returns

{X = succ (succ (0)), Y = 0}, {X = succ (0), Y = succ (0)}, {X = 0, Y = succ (succ (0))}

However, in some cases there are an infinite number of possible unifications (for example, X> Y = true).

Does anyone know an algorithm to determine if there can be an infinite number of unifications?

Thanks in advance

+3
source share
2 answers

Prolog, "", . (X, Y) succ (succ (0)), ( ), arities . , , , add (X, Y) succ (succ (0)) . , , . . , , , N > 2, X ^ N + Y ^ N = Z ^ N , , , (.., ), . .

+8

, . , CLP (FD) (, SWI-Prolog, Jekejeke Minlog, , GNU Prolog B-Prolog , / ), , . , (SWI-Prolog):

?- use_module(library(clpfd)).
true.

?- X #\= 2.
X in inf..1\/3..sup.

, CLP (FD), , . , - , CLP (FD):

" 1900 , , . 1970 , : ". ( )

, , CLP (R). . , CLP (FD) ( , SWI-Prolog, Jekejeke Minlog No , GNU Prolog 4 "" ):

?- X #> Y.
Y#=<X+ -1.

?- X #> Y, Y #> X.
X#=<Y+ -1,
Y#=<X+ -1.

, CLP (R) :

?- use_module(library(clpr)).

?- {X > Y}.
{Y=X-_G5542, _G5542 > 0.0}.

?- {X > Y, Y > X}.
false.

, , .. , , .. * CLP (*). .

Bye

+3

Source: https://habr.com/ru/post/1773933/


All Articles