"if" here isn't a perfect analog to a traditional imperative language's if statement.
A better set of keywords to describe the logic might be "when ... allow". Because there is an implication here, it's just in reverse.
Because the relation finds all possible solutions that meet the relationship, this code really reads "when s is the letter a, allow x to be 0, and call that a solution. Otherwise, any pairing where x is 2 is a solution."
So if you were to call p(s, 0), you would find that you only get one solution, where s must be 'a'. From an imperative-ish POV, that "sets" (constrains) s to 'a'.
OP is using if, combined with the notions that you take only the first of all relation solutions, and that you treat the rightmost relation member as an output, to achieve an imperative-like behavior in a non-deterministic logic language. Which is mentioned in the paragraph following the example.
The problem is there even without else.
Should it be or Because IMHO it should be the second one (it's also basicaly the logical definition of implication, which IMHO should be consistent with "if").The first interpretation of if without else just give you another way of writing:
so why "if" at all?And if we take the second interpretation of if without else, then when there's else - it should also get the !if_condition implicitly.