Core Maude, 315 302 286 277 276 273273 268 bytes
mod E is pr LIST{Int}. ops e i : Int ~> Int . var A B N X Y Z :[Int]. ceq e(N X A Y B Z)= 1 if(size(X)rem N + size(Y)rem N)size(A)size(B)i(N 0)X B Y A Z = 0 N N i(N(N ^ 2)). ceq e(N X A Y)= 1 if i(N 0)X I:Int Y := i(N(N ^ 2)). eq i(N 0)= nil . eq i(N s A)= i(N A)(0 ^(A rem s N)). endm mod E is pr LIST{Int} . ops e i : Int ~> Int . var A B N X Y Z : [Int] . ceq e(N X A Y B Z) = 1 if (size(X) rem N + size(Y) rem N) size(A) size(B) i(N 0) X B Y A Z = 0 N N i(N (N ^ 2)) . ceq e(N X A Y) = 1 if i(N 0) X I:Int Y := i(N (N ^ 2)) . eq i(N 0) = nil . eq i(N s A) = i(N A) (0 ^ (A rem s N)) . endm Saved 3 more bytes using 0 ^ X to do the equivalent of !x in C — i.e., convert non-zero to zero and zero to one. Maude's convention is that \$x ^ 0 = 1\$ even for \$x = 0\$.
Saved 5 more bytes by removing the base case for i and handling it in the pattern matches.