This is what is usually called a Yes/No Question. The rules for English Y/N Qs are:
Invert subject and first auxiliary verb, add question intonation:
- Bill is going to the show. --> Is Bill going to the show?
If there isn't an auxiliary verb, use do, transfer the tense to do, and invert it.
- Bill went to the show --> Did Bill go to the show?
If there is a contraction with the first auxiliary verb, the whole contraction may be inverted:
- Bill wasn't going to the show --> Wasn't Bill going to the show?
Thus the negative is just a normal part of the question, in the normal place, so the grammar is nothing special. The meaning, however, is rather specialized, and there's a big literature on it in pragmatics, among other places.
The pragmatic solution is to note that if a special word is added to a question, but the modified question asks for the same information as the unmodified one, then there must be a special conventional meaning for the added word, right? -- but it doesn't have to be obvious. Since it's a request for information either way, the negation is used to signal speaker expectation.
And since it's not about the logical implications of the question, English speakers don't even notice the logic, and answering a negative question with a negative when you agree feels very strange to us; we're keeping our minds on the expectations, beliefs, and goals of the speaker.
Normally English speakers use a negative Y/N Q to suggest that the positive -- not the negative -- is what they expect. Thus:
- Is he going to do it? (no special implication, just a speaker request for information)
- Isn't he going to do it? (implies speaker had expected him to do it, but now doubts)
As others have pointed out, this is not a Tag Question; Tag Qs are tags, on the end of statements. (I'm sure you understand this now, don't you? :-) They have some interesting syntax, too. But the implications of positive and negative Tag Qs can be confusing when compared with those of regular Y/N Qs.
- He's going to do it, isn't he? (negative tag; speaker expected positive statement)
- He's isn't going to do it, is he? (positive tag; speaker expected negative statement)
These, by the way, have two different implications, depending on whether is he? (or isn't he?) has Y/N Q (rising) intonation, which is a real question, or ordinary full stop intonation (like a Wh-Q gets), which is simply a rhetorical question, stating the speaker's belief, and requires no response, though it often invites one.