Assume I attended someone's seminar talk which I liked a lot. Also I heard that yet another expert X also said that the talk is interesting. Is it ok to say to the lecturer that the expert X and I liked the talk, or should I not mention another's opinion?
Now assume the opposite situation: the expert X and I did NOT like the talk. Is it ok to say to the lecturer that X and I did not like the talk, or again should I not refer to other people?
[update] Now assume that the lecturer explicitly asked me if I heard what X said about his/her talk. Can I tell the lecturer X's opinion (assuming X did not ask me in advance not to do that)?
X, being an expert in the field, can presumably find ways to communicate their opinions to the speaker, publicly or privately, if they wish to do so.
Often, opinions communicated between experts will be much more complicated and mixed than a simple like/dislike. "I agree with you on points A, B, and C, but I think point D is contradicted by Y's research. I'll send you a reference." is much more likely than either extreme.
If you just heard X talking about point D and Y's research, you could get the impression X disliked the talk. If you just heard X talking up points A, B, and C you could get the impression X liked the talk. Neither impression would be fully accurate.
Unless X has positively authorized you to speak on their behalf, you should not do so. If asked directly, indicate that you are unsure and, as suggested in a comment, encourage the speaker to talk to X directly.
Regarding (1), you could safely say something general and vague, such as
"The talk was very well received, congratulations."
Regarding (2), simply speak for yourself, unless you are the expert's assistant and are paid to speak for him.
Regarding (3), I recommend using a question, for example:
"Have you asked him/her?" or "Would you like me to introduce you to him/her?"
Definitely NOT ok. the second option is definitely not ok.
The first one is more acceptable, but it's definitely not usual. I don't see why you would do this.
The golden rule is: 'never speak for someone unless they cannot speak for themselves.'
This applies here as well as everywhere else. If the lecturer asks you what they thought, tell them to ask the person as you wouldn't want to guess their feelings.
That being said, you can always say 'I believe a lot of people appreciated/enjoyed the talk' or something similarly encouraging.
This is science, not theater.
What you should communicate isn't 'I liked it but X did not at all'. Rather, you should say 'I liked your approach to ...' or 'nice talk but I'm not convinced of...' If he/she wants to know what X thought (barring confidentiality), say 'he/she was critical of your interpretation of ...' Can you offer other attendee's assessments? I don't see why not, but I'm not sure offering names accomplishes much. It should be about content.
Of course this assumes substantive comments. I've seen my share of good data with horrible delivery and boring demeanor. That's harder to convey with tact. Saying 'professor x thought you were boring and also thinks your suit is ugly' doesn't help anyone.
Just stick to content and I think you'll be ok.
In this particular case, even if you thought that X thought the talk was nice, but actually he thought it was bad (or viceversa), I don't see why it would do any bad if you tell the lecturer what you think X thought. Unless the lecturer was very happily expecting to hear X's opinion, then it's ok. Of course, what I would do is to say to the lecturer exactly what I heard coming out of X's mouth, or whatever you've been told about X's opinion (in case you didn't even hear him personally). If the case was that the lecturer was really trying to impress X, then even if you make the mistake of telling him that X thought it was great, but he actually thought that it sucked, then the lecturer wouldn't get mad at you or something like that, basically because he would realize hours or days later, and much less is the chance of him getting mad at you if he doesn't know you.