I have DCG sentences with two persons, representing a male and a female. I want to refer to the person metioned in a previous sentence using "he" or "she".
Suppose we have these DCGs:
father --> [Peter].
mother --> [Isabel].
child --> [Guido].
child --> [Claudia].
verb --> [is].
relation --> [father, of].
relation --> [mother, of].
pronoun --> [he].
pronoun --> [she].
adjective --> [a, male].
adjective --> [a, female].
s --> father, verb, relation, child.
s --> mother, verb, relation, child.
s --> pronoun, verb, adjective.
Querying ?- s([Peter, is, father, of, Guido], []).
returns true
.
How can I make sure that when I query now for ?- s([he, is, a, male], []).
should return true
only because I already mentioned Peter (a male) in the previous sentence. Otherwise it should return false
.
This question uses the same example as here.
'
that were put in the other answer.Peter
is a variable,'Peter'
is an atom. See: write_canonical/1 – Guy Codermale('Peter')
and go from there. Once that is working, then remove the fact and get one sentence to convey the idea to the other sentence. Might need to have first sentence assert facts, or view the two sentences as one semantic idea that have an implied operator between the sentences. – Guy Coder