In some theories, the strict definition of anaphora includes only references to preceding utterances. Under this definition, forward references are instead named cataphora, and both effects together are endophora. Also, the term exophora names situations where the referent does not appear in the utterances of the speaker, but instead in the real world. Some linguists prefer to define anaphora generically to include all of these referential effects.
Reflexive anaphors must obey binding condition A, which states that "a reflexive pronoun must be bound within the smallest category containing it, its selecting head and a subject (=its governing category, or GC). In the following sentence: *John thought that she saw himself, the GC of the reflexive 'himself' is the relative clause, since it contains the anaphor itself, its selecting head (saw) and a subject (she). The only available noun that could bind 'himself' is 'she', but this is ruled out because of the gender mismatch. The anaphor is therefore left unbound, which violates condition A - explaining the sentence's ungrammaticality.
If the second sentence is quoted by itself, it is necessary to resolve the anaphor:
Although of course, as The Prime Minister of New Zealand is an office of state and she would seem to refer to the person currently occupying that office, it could quite easily be that the Prime Minister of New Zealand had visited New York since 1998 and before the present day, whilst the present incumbent she had not.
However, even when taken in context, anaphor resolution can become increasingly complex. Consider the two examples:
In the first sentence, "they" refers to "monkeys", whereas in the second sentence, "they" refers to "bananas". A semantic understanding that monkeys get hungry, while bananas become ripe is necessary when resolving this ambiguity. Since this type of understanding is still poorly implemented in software, automated anaphora resolution is currently an area of active research within the realm of natural language processing.
In (1), the anaphoric pronoun 'they' refers to the children who are eating the ice-cream. Contrastingly, in (2), 'they' seems to refer to the children who are not eating ice-cream.
The fact that sentences like (2) exist in the language seems at first odd: by definition, an anaphoric pronoun must refer to some noun that has already been introduced into the discourse. In complement anaphora cases, since the referent of the pronoun hasn't been formerly introduced, it's difficult to explain how something can refer to it. In the first sentence of (2), the set of ice-cream-eating-children is introduced into the discourse; but then the pronoun 'they' refers to the set of non-ice-cream-eating-children, a set which hasn't been priorly mentioned.
Several accounts of this phenomenon are found in the literature, based on both semantic and pragmatic considerations. The most important point of debate is the question, whether the pronoun in (2) refers to the complement set (i.e. only to the set of non-ice-cream-eating-children), or to the maximal set (i.e. to all the children, while discounting the minority group). The answer to this question may have theoretical concequences regarding the question of the kind of information that our brain is able to access or calculate, and also pragmatical concequences regarding the way a theory of anaphora resolution should be devised.