This is an elementary Prolog question. I'm trying to implement reasoning that may be informally expressed like this:
The (necessary but not sufficient) conditions for x(X) to be true are that a(X) and b(X) must hold. We know that x(mary). Those conditions must have held for x(mary) to be the case. It is the case. Therefore a(mary) and b(mary) are both true.
The following code clearly doesn't do what I have in mind:
a(jim).
b(jack).
x(X) :- a(X), b(X).
x(mary).
If I now ask a(mary), Prolog answers with a No.
I'm pretty sure I understand why it answers this way. I just don't know how to correctly implement what I want.
UPDATE:
The above example is simplified. In the actual problem I'm working on, a and b are intertwined. Instead of x(X) :- a(X), b(X)., I actually have r(A,B,C) :- p(A,D), p(C,E), a(D,n), a(E,c), s(B,E,F,2), s(C,E,D,1), s(C,E,F,1).. That is, for r(A,B,C) to hold, it is necessary that all the interlinked conditions on the right hold together. Now it doesn't seem right to replace this with a series of rules p(A,D) :- r(A,B,C). a(D,n) :- r(A,B,C). and so on, because, as I understand it, the D in the p(A,D) is no longer the same as the D in the a(D,n), these being now totally independent rules. I could easily implement the reasoning I want in a (deductive) automated theorem prover for first order logic, which I am more familiar with than with Prolog.
Another example. Consider this Prolog code:
breathable(X) :- part(X,Y), atom(Y,o).
part(air,oxygen).
breathable(air).
Air is breathable. Air contains oxygen. I want to infer that atom(oxygen,o). But Prolog will answer No.