People talk about different kinds of humour/laughter: nervous laughter, relief, absurdity, surprise, etc. but I think these all boil down to the same thing really, they are all "misapplications" of logic, basically a faulty premise that is taken to its logical conclusion, which is then proven wrong thus revealing the premise was false.
Laughing in relief is for example, you were frightened by a rustling in the bushes, you thought it might be a tiger but it turned out to be a sparrow. You adopted the false premise that the rustling was made by a tiger and you created a threat in your mind based on that only to be proven wrong and your whole line of thought was thus a wayward path. Maybe the rustling really was a tiger and you barely managed to escape it! Then you might also laugh because (thankfully) your logical deduction that you would soon be tiger dinner was proven wrong.
Laughing in surprise is almost exactly the same but with the added layer that initially you didn't suspect a thing, then you get the surprise which might shock you and cause your mind to quickly leap to assumptions about the situation (possibly another phantom tiger!) and then this is proved wrong too. So you are both laughing in relief and laughing at your inability to detect anything was afoot at all.
Nervous laughter happens when you are trying to reassure yourself that you have indeed made a mistake, the situation cannot be as bad as it seems, this must be a joke, right?
Absurdity is I think the purest form of humour, it is the most abstract form of this same "faulty premised" logic. It would be fairly simple to give AI a childish absurdist humour, for example, all you need to do is miscategorise something on purpose, eg, "Q: What type of car does my Dad drive? A: A banana!", we were expecting a type of car but instead got a type of fruit; hilarious, I'm sure you'll agree.
I think the secret to the most effective humour is maintaining the wayward path of reasoning for as long as possible. But this isn't as simple as drawing out our misdirection, eg: "Q: What has four wheels, a horn, a windshield and seats? A: A banana!", none of those descriptors lead us any closer to a banana so we weren't really misled, just delayed. Although the fact I used, "A banana!", again as the answer is kind of amusing, which I guess is funny because if every answer I give is, "A banana!", then everything I say is an illogical conclusion, the whole idea of there being a question with a real answer becomes a misdirection and a faulty premise.
So what if I use the same joke but try to fit an answer that matches the description, then I really will have made a wayward path to follow. "What has four wheels, a horn, goes very fast and is a danger to pedestrians? A rhinoceros riding a skateboard." Now we're getting somewhere, this looks like an actual joke and it has a simple, replicable format: "find two unrelated objects, a combination of whose descriptors are also descriptors of a third object." IN this case a car, a rhino and a skateboard.
Let's give it a go. First find two objects that have a common descriptor but other unmatching descriptors: a cup and a door both have handles but are quite different in other respects. Now find a third object that shares a different characteristic with both. We can also think about combinations, like something that might use a cup or have a door in it, these combinations don't have to make sense (like our rhino on a skateboard). How about a spaceship, a "flying saucer"? That would have a door in it and cups go with saucers. "What has a handle and is usually found on a saucer? A spaceship door." Okay, not a classic but it works. We choose "spaceship door" as the answer because this is the least common of the two possible answers (the other being a cup). In fact the combination is usually going to be the least common answer so it will probably be the funnier of the two.
Let's try another using a door and a cup again. "What has a handle and can be filled with tea? An Englishman with a door in his face.", this requires knowledge of a further connection to appreciate fully: a door and a mouth are both portals. The door replaces the mouth on the face of the man.
The rhino joke works better because the "horn" refers to two very different things in the case of the rhino and the car, so this makes misdirection easier. Utilising this kind of distinction to produce humour requires data that distinguishes between different definitions of the same word. It is clear that a sense of humour requires a lot of detailed data.