She denied to have seen him yesterday.
She denied seeing him yesterday.
She denied having seen him yesterday.
Are these sentences grammatically correct? Do they mean the same?
This is a licensing matter. Verbs in particular (but nouns and adjectives, too) license or permit only certain sorts of complements.
In this case, the verb is deny. Deny licenses:
that complements ("content clauses")
She denied that she saw him.
She denied that she had seen him.
Note the difference between the simple past and the past perfect in the complement clause: in the first, she claimed that she did not see him at the time she said it, in the second she claimed that she did not see him at some earlier time.
gerund (-ing form) complements
She denied seeing him.
She denied having seen him.
Again, the perfect gerund (having seen) places the act of seeing before the time at which she uttered the denial; but the simple gerund (seeing) may be understood as either a prior or a current act of seeing. Otherwise there is no semantic (meaning) difference between the versions with content clauses and those with gerunds.
In some very limited contexts, wh- complements ("embedded questions")
She denied what she was charged with. BUT NOT
∗She denied whether she {saw / had seen} him.
In Present-Day English deny does not license infinitival clauses:
∗She denied to see him.
∗She denied to have seen him.
Four hundred years ago She denied to see him was acceptable (you may encounter it in Shakespeare, for instance), but it had a different sense: "She refused to see him." This sense survives in utterances like "They denied him entrance", but today it is used only with noun phrase complements, not with clauses.
∗ marks an utterance as ungrammatical
This sentence is wrong:
He denied to have seen him yesterday
As far as I can tell, you can't use [Past Simple] + [Composite Verb] (denied + to have seen).
My understanding of grammar isn't as good as some users here, but I can't think of any sentence where that's a valid form to use.
She denied seeing him yesterday
She denied having seen him yesterday.
These two sentences are valid and identical in meaning. The first sentence is more commonly said than the second, "she denied having seen him yesterday" sounds like she was interrogated by the police.
The Free Dictionary says that the verb "deny" (when meaning to state that something said is untrue) must be followed by an object, a that-clause, or an -ing form. According to this explanation and the comments made by Tromono, the sentences #2 and #3 are grammatically correct. The sentence #1 is not correct because it has the present participle "to have" that's not acceptable.
The use of yesterday in the sentences is 0K as both the sentences are expressive of the past tense. In other words, the sentences mean:
2) She denied that she saw him yesterday.
3) She denied that she had seen him yesterday.
1 and 3 are wrong. Avoid using present perfect with the expression yesterday. From this:
We use the Present Perfect to say that an action happened at an unspecified time before now. The exact time is not important. You CANNOT use the Present Perfect with specific time expressions such as: yesterday, one year ago, last week, when I was a child, when I lived in Japan, at that moment, that day, one day, etc. We CAN use the Present Perfect with unspecific expressions such as: ever, never, once, many times, several times, before, so far, already, yet, etc.
Additionally, 1 sounds difficult to understand to me - it sounds like you are trying to say "He declined to see him yesterday". I think 3 is also breaking the above rule, but a reader/listener would not find it terribly jarring.