Make no mistake about it: what Volkswagen did belongs in a movie. Think The Constant Gardener, except with cars.

But it's also a lesson in the eternal corporate quest to game regulations. Which means it's an opportunity to think about better ways to design regulations. And that might lead us to look in a seemingly unrelated place: namely, a carbon tax.

A few days ago, the Environmental Protection Agency (EPA) revealed that, in 2009, Volkswagen began inserting code into the software of its diesel cars to fool emissions tests. When the cars were in regulators' laboratories, they released the appropriate levels of nitrogen oxides (NOx) — a pollutant from fossil fuels that contributes to smog and is associated with all sorts of cardiovascular diseases and other health problems. But on the road, the emissions were massively higher — as much as 40 times the federal limit, in some cases.

Volkswagen has now admitted that 11 million of its supposedly clean diesel cars worldwide have these "defeat devices" installed. Its stock has cratered; it faces up to $18 billion in fines by the EPA; and the Justice Department is looking into criminal charges. Indeed, as Kevin Drum pointed out, precedent suggests top Volkswagen officials may be in for some jail time.

But another disturbing angle to all this is how close Volkswagen came to getting away with it.

The fraud was only uncovered because the International Council on Clean Transportation — a nonprofit environmental group that includes some former EPA people — decided to test diesel cars in America under real-world road conditions. As The New York Times laid out, they weren't looking for mischief at all: European emission standards are less stringent than U.S. standards, and the group was essentially looking for a comparison that would shame the Europeans into action. Some researchers from West Virginia University decided to help out, and just by chance two of the three diesel cars they checked out were from Volkswagen. As soon as they realized the massive discrepancy between what the cars should be emitting and what they were emitting, things unraveled from there.

An additional wrinkle is that, thanks to lobbying from the auto industries, the National Highway Traffic Safety Administration lacks a lot of the legal tools needed to fight these sorts of shenanigans. The maximum penalty it can impose, for example, is $35 million, which is peanuts for the likes of Volkswagen. That's why EPA is handling the matter: The Clean Air Act gives it a lot more muscle and room to maneuver.

Corporations actually prefer detailed regulations that are complex to implement and police, because it gives them more opportunities to game them. In the realm of emissions, regulators have to usually rely on lab testing — Volkswagen's software actually detected when the car was in lab conditions and when it wasn't. That cars use a lot of software these days also makes regulations harder to implement. In many ways, big, dumb, and simple rules can be more effective.

This is also a common story in other economic sectors, like finance. And the realities of capitalism are that there's always a huge profit incentive in gaming regulations: In this case, diesel fuel is popular because, pound for pound, it has a higher energy content than regular gasoline. But it's also dirtier, so getting a good mix of performance, fuel economy, and cleanliness is a costly and difficult trick. Volkswagen "solved" the problem by simply faking the cleanliness part.

As it turns out, a carbon tax is a big, dumb, and simple rule that could help here. When you reduce carbon dioxide emissions, you tend to reduce nitrous oxides, sulfer dioxides, and particulate matter as well — the pollution that doesn't necessarily affect climate, but that poisons ecosystems and wreaks havoc on people's health.

Furthermore, while carbon taxes can be designed in many ways, one of the simplest and most straightforward strategies is to tax fuels at their source. We know how much carbon is in a pound of coal or a barrel of oil, and how much carbon dioxide will be released if that pound of coal or barrel of oil is burned. And we have computer models that tell us how much the economic costs will incrementally increase because of that additional carbon dioxide.

Put it all together and you can calculate a tax that can be applied to the company that dug up the coal or oil or whatever, at the moment it dug it up. That avoids complex tax schemes: Once the price of the tax is built in at the source, that price follows the fossil fuel to where it's used on the grid or at the pump or whatnot. And while no policy is fullproof, it also avoids the complexities of laboratory tests to determine compliance, or the mammoth amount of moving parts involved in something like the EPA's carbon rule for power plants.

In fact, we can take this logic further: Instead of a carbon tax, we can levy a direct tax — at the source — on NOx emissions and other pollutants. One of the big discoveries in environmental and health science over the last few decades was that cleaning up fossil fuel emissions leads to enormous economic benefits, precisely because people get sick and die less often. So, as with carbon, we can estimate the amount of health costs built into a certain amount of fossil fuel when it's dug up, and tax it accordingly. And since the two things are conceptually distinct, there's no reason you couldn't do both: levy one tax for the climate change costs of the carbon content, and one tax for the health costs of other pollutants.

The regulations we already have don't actually ban these emissions. They just keep them below a manageable level. A tax— properly priced — would achieve the same. The trade-off is we would lose certain forms of innovation: The regulations we have now encourage car companies to come up with cleaner ways to burn fossil fuels. But a tax at the source would encourage them to find other fuels to use. That too would be innovation, but not focused on using the energy sources that are common now. (And given the looming threat of climate change, that's arguably a feature rather than a bug.)

What it would do is make the mechanism for the goal of pollution reduction much cleaner, more straightforward, and difficult to evade. There are lots of potential solutions here, many less outside-the-box. But this is one to think about.