Hi,
There is a proof by Euler, that Formats Last Theorem
FLT is true for n=3. In his proof there is all kind
of reasoning.
At one point he reasons about cubics. Something
along when p^3 = a*b, then a=u^3*c and b=v^3*d
and c*d=w^3. Right?
Anyway: Some extension could also handle multiplication
constraints with exponents. Like for example:
X*Y^2 = 9529569
Because 9529569 = 3^4*7^6, this would give two new
constraints:
N1+2*M1 = 4
N2+2*M2 = 6
And the result would be:
X = 3^N1*7^N2
Y = 3^M1*7^M2
Its like 30-times faster:
?- [X,Y] ins 1..9529569, X*Y^2 #= 9529569, time((label([X,Y]), fail; true)).
% 263,673 inferences, 0.067 CPU in 0.068 seconds (99% CPU, 3917933 Lips)
?- [N1,M1,N2,M2] ins 0..6, N1+2*M1 #= 4, N2+2*M2 #= 6, time((label([N1,M1,N2,M2]), X #= 3^N1*7^N2, Y #= 3^M1*7^M2, fail; true)).
% 5,712 inferences, 0.002 CPU in 0.002 seconds (98% CPU, 2586957 Lips)
Have a Nice day!
P.S.: Here you see that both approaches give the same solutions:
Welcome to SWI-Prolog (threaded, 64 bits, version 7.5.8)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
?- use_module(library(clpfd)).
true.
?- [X,Y] ins 1..9529569, X*Y^2 #= 9529569, label([X,Y]).
X = 1,
Y = 3087
X = 9,
Y = 1029
X = 49,
Y = 441
X = 81,
Y = 343
X = 441,
Y = 147
X = 2401,
Y = 63
X = 3969,
Y = 49
X = 21609,
Y = 21
X = 117649,
Y = 9
X = 194481,
Y = 7
X = 1058841,
Y = 3
X = 9529569,
Y = 1.
?- [N1,M1,N2,M2] ins 0..6, N1+2*M1 #= 4, N2+2*M2 #= 6, label([N1,M1,N2,M2]), X #= 3^N1*7^N2, Y #= 3^M1*7^M2.
X = 1,
Y = 3087 ;
X = 49,
Y = 441 ;
X = 2401,
Y = 63 ;
X = 117649,
Y = 9 ;
X = 9,
Y = 1029 ;
X = 441,
Y = 147 ;
X = 21609,
Y = 21 ;
X = 1058841,
Y = 3 ;
X = 81,
Y = 343 ;
X = 3969,
Y = 49 ;
X = 194481,
Y = 7 ;
X = 9529569,
Y = 1.