I'm still very new to the prologue, and I'm trying to wrap my head around why mathematical constraints don't work the same as logical ones.
There seems to be enough information to solve this problem:
f(A, B) :- A = (B xor 2).
But when I try f(C, 3), I return C = 3 xor 2., which is not very useful. Even less useful is the fact that he simply cannot find a solution if the inputs are canceled. Using isinstead =leads to the fact that the input example returns the correct answer, but the reverse refuses to even try to do anything.
From my early experiments, it seems that I could write a function that did this logically using binary code without any problems, and that would actually go both ways. What is the difference between mathematics?
For reference, my first attempt to solve my problem is as follows:
f (Input, Output): -
A is Input xor (Input >> 11),
B is A xor ((A >> 7) / \ 2636928640),
C is B xor ((B << 15) / \ 4022730752),
Output is C xor (C >> 18).
This works fine from input to output, but not vice versa. If I switch isto =, it produces a long logical sequence with the values replaced, but cannot find a numerical solution.
swi-proog, xor , . , , . , , .