According to Ilse Depraetere 2009, the function of have in sentences with could + perfect infinitive either communicates anteriority (as in the example in (1)) or contributes to the establishment of counterfactual meaning (as it does in (2)), which are the main functions standardly attributed to have in could + perfect infinitive constructions.
And the paper highlights a special use of could + perfect infinitive in which have performs neither of the two functions (as it does in (3)).
- Michael scrutinised the window display in the hope of discovering
what had so held the child’s attention. Surely it couldn’t have been
the dresses.
It could be paraphrased as “surely it wasn’t possible for it to have
been the dresses”.
- “How long did you spend recording the album?” – “Probably about a
month of recording and a few weeks of tweaking. If I’d had a deadline
it could have been quicker.
It could be paraphrased as "If I had been given a deadline, it would
have been possible for me to have finished the album more quickly".
- How is it that the Secretary of Defence could have remained at his desk until the crash? Whose responsibility is it to relay emergency situations to him?
It could be paraphrased as "How was it possible for the Secretary of Defence to remain at his desk?"
I suspect that in the linked question "I don’t know how the killer could have known the key code, but I’m sure that’s when he must have got in", have belongs to the second category of its functions.
Wewe could roughly paraphrase it as "I don’t know how the killer would have been able to know the key code, unless somebody else had told him", as suggested by Frank's comment.
Do I understand it correctly? Here "could + perfect infinitive" expresses past counterfactual meaning.
The other important use of "could + perfect infinitive" expresses past factual possibility, as suggested by HostileFork's answer.
And I getquote here some extra examples below from the Internet, withadding some explanations of my own explanations added, so I might have a better understanding.
Which of them could be substituted with "would have known" or "knew""could know" without considerable change in meaning?
I suspect when "could have known" expresses a counterfactual meaning, they are more or less interchangeable with "would have known" in the following examples. When "could have known" evaluatesis used for evaluating the past factual possibility they are more or less interchangeable with "knew""could know".
Please help me walk me through them.
#1. "My name is Elijah," the man says, inspecting her with dark eyes.
"Your son –- Malachi, is it? –- asked me to help you."
...
He continues, "Like you, I'm a vampire, although I don't know how your son could have known (I'm a vampire) when he asked me to help you."
Here the speaker is expressing surprise.
We could roughly paraphrase it as "I don't know how it is possible for your son to have known..". I think have belongs to the first category. Using 'would'"would have known" wouldn't fit with the context. And why not just simply say "I don't know how your son knew"could know"? It seems neater.
I'm not quite sure about the function of have here. Is it possible to use 'would' instead? I would reword it as "I don't know how much I knewcould know about the festival at the time". I'm not sure if it's the intended meaning.
I think have"could have known" here expresses counterfactuality; the parents didn't know his bad results. Using 'would'"would have known" would workkeep the intended meaning intact, I suppose.
#4. That spring I met a girl, or more precisely she met me. I was what is usually described as shy. In truth I was already somewhat socially and emotionally retarded. I had never really even talked to a girl. While my non-user and “normie” peer group were out going to social functions and starting to develop into young adults, I was always loaded and making no attempt at emotional or social growth. I avoided facing my fears and insecurities by not facing the real world. I don't know how she could have known the only way I would have been able to talk to her, but she found it by offering to smoke a joint. This was heaven for me. I didn't have to do anything—theanything - the pot did it for me.
It seems to be a hypothetical scenario here. I suspect 'would'"would have known" is a possible alternative for 'could'"could have known" here while 'knew' couldn't be used"could know" would not work here.
I think have"could have known" here expresses anteriorityfactual possibility, as in #1. We could roughly paraphrase it as "I don't know how it is possible for Dave to have known..". Seems 'would'"would have known" couldn't work here. Again, I would just say "I don't know how Dave knewcould know that". Any different connotation conveyed?