The cat flap may not be the most sophisticated of inventions – a tiny flap in a door that a cat can get through is not Nikola Tesla territory – yet they have still been around a surprisingly long time.
They even make an appearance in churches dating back to the 16th century, though it should be noted that this is a doggy door for the locals' dogs, rather than strictly a flap for cats.
The invention of the cat flap has been attributed to a few people, with one story attributing it to Isaac Newton. According to the (unlikely) tale, Newton created a hole in his door and draped a cloth over it as a flap after his cat kept ruining photosensitive experiments by opening the door and letting light in.
In some versions of the tale, Newton cut two holes in his door: a big one for the cat, and a second smaller hole for his kitten, not realizing that the kitten would go through the big hole with the cat.
As fun as that sounds, it's likely not true, and the story appears to come from a good 70 years after his death. However, mathematician John M.F. Wright, a scholar at Trinity College London about a century after Newton, did note that “whether this account be true or false, indisputably true is it that there are in the door to this day two plugged holes of the proper dimensions for the respective egresses of cat and kitten.”
If it was true, Newton was still too late to have invented it, especially if you include its predecessor: the simple cat hole.
It's difficult to track exactly when the cat door was invented, though we know it was sometime before Newton. The cat hole was mentioned as far back as Chaucer's late-14th-century The Canterbury Tales, and used by a servant to peek into a room.
"An hole he foond, ful lowe upon a bord
Ther as the cat was wont in for to crepe,
And at the hole he looked in ful depe,
And at the last he hadde of hym a sighte."
Cats have likely been at least partly domesticated from about 9,000 years ago, having been welcomed by humans at first as a form of pest control, taking out rodents that eat grain harvests. It's probable that we gave food to keep them around and doing their thing, before eventually giving them the freedom to get in and out of the house that will never be afforded to dogs.