could have/might have

[color=red]1-I prepared lunch for him because he could have come here yesterday.
[color=indigo]2-I prepared lunch for him because he might have come here yesterday.
Would either of the above sentences be ever used if he did actually come here yesterday?

[color=red]3-I took my umbrella with me because it could have rained yesterday.
[color=indigo]4-I took my umbrella with me because it might have rained yesterday.
Would either of the above sentences be ever used if it actually did rain yesterday?

To me, these sentences imply that he didn’t come, and it didn’t rain. (With different subject matter, this form of words might imply that the speaker doesn’t know if the thing happened or not.)

Thank you Dozy.

What do you think of this one:
a-An accident could have happened and it did.

And could you please give a example where “could have” is used and implies that the speaker doesn’t know if the thing happened or not?

I suppose it’s possible that someone might say this, but it’s not a great sentence, in my opinion.

“The train could have been late”, “She could just have been upset”, “They could’ve already called to collect it”, etc. It is not uncommon to hear sentences like this in informal speech, but “might have” is usually superior in such cases, in my opinion.

Thank you very much Dozy.

I agree with you that those sentences are correct, but I think they look at the past from a different perspective.

The train hasn’t arrived. It could have been late.
She behaved strangely. She could just have been upset.
The box is not here. Thye could’ve already called to collect it.

But consider:
[color=red]A-I took dictionary with me because I could have needed it.
meaning: I took a dictionary with me because I thought I could need it.
(“might” would work better here too but would not change much, I think.)

Yes, I think you’re right, the perspective is slightly different. In the second category of sentence, it may be easier to use “in case” (e.g. “I took a dictionary with me in case I needed it.”)