isolax(1, $U=V,         U=Y,            true) :- negate(V, Y).

isolax(1, U+V=W,        U=W+Y,          true) :- negate(V, Y).
isolax(2, V+U=W,        U=W+Y,          true) :- negate(V, Y).

isolax(1, U*V=W,        U=W*V1,  non_zero(V)) :- restrict_exp1(V, V1).
isolax(2, V*U=W,        U=W*V1,  non_zero(V)) :- restrict_exp1(V, V1).

isolax(1, log(U,V)=W,   U=V^W1,  non_zero(W)) :- restrict_exp1(W, W1).
isolax(2, log(V,U)=W,   U=V^W,          true).

isolax(1, U^N=V,        U=V^N1,  non_zero(V) & negative(N)) :-
						 restrict_exp1(N, N1).
isolax(1, U^N = #0,       false,   negative(N)).
isolax(1, U^(N ^ $1)=V,  U=V^N,          true).
isolax(1, U^N=V,        U=V^N1,  non_neg(U) & even(N)) :-
						 restrict_exp1(N, N1).
isolax(1, U^N=V,        U=V^N1 v U = $1*V^N1,even(N)) :-
						 restrict_exp1(N, N1).
isolax(1, U^N=V,        U=V^N1,                odd(N)) :-
						 restrict_exp1(N, N1).
isolax(2, V^U=W,        U=log(V,W),     true).

collax(W,   U*W+V*W,                    (U + V)*W       ).
collax(W,   W+V*W,                      (#1+ V)*W       ).
collax(W,   W+W,                        #2*W            ).
collax(U&V, (U+V)*(U + $1*V),            U ^ #2 + $1*V ^ #2 ).
collax(W,   W^U*W^V,                    W^(U + V)       ).
collax(W,   W*W^V,                      W^(#1+ V)       ).
collax(W,   W*W,                        W ^ #2            ).
collax(W,   log(W,U)+log(W,V),          log(W, U*V)     ).   /*new*/

attrax([U, V],  U*W+V*W,                (U+V)*W         ).
attrax([U, V],  W^U*W^V,                W^(U+V)         ).
attrax([U, V],  log(W,U) + log(W,V),    log(W, U+V)     ).
attrax([U, V],  U*log(W,V),             log(W, V^U)     ).
attrax([U, V],  log(W,V)*log(U,W),      log(U, V)       ).
attrax([U, V],  U=V,                    U+Y = #0          ) :- negate(V,Y).
attrax([U, V],  (W^U)^V,                W^(U*V)         ).
attrax([U, V],  U^(V*W),                (U^V)^W         ).

t_tidyax(U = U, true).
t_tidyax(U \=U, false).
t_tidyax(U ^ #0, #1).
t_tidyax(#0^U, #0) :- positive(U).
t_tidyax(#1^U, #1).
t_tidyax(log(U,#1), #0).
t_tidyax(log(U,U), #1).

nt_tidyax(U ^ #1, U).
nt_tidyax((U^N)^M, U^K) :- number(N), number(M), eval(K is N*M).
nt_tidyax(log(U,U^V), V).
nt_tidyax(U^log(U,V), V).
