Image copyright Reuters Image caption The UK is set for a hard Brexit from the EU

So the UK, it seems, is headed out of the European Union's single market, perhaps also out of the customs union.

Prime Minister Theresa May has said she wants to preserve barrier-free trade between the UK and the EU as far as possible.

One option that has been floated, if the two sides can't agree a comprehensive free trade agreement, is sectoral deals. They might cover cars, for example, or perhaps financial services.

But there is a problem with this approach: World Trade Organization rules.

Perhaps the most fundamental idea behind the WTO's rule book is non-discrimination.

It goes by the rather confusing name of "most favoured nation".

It is Article 1 of the WTO's main legal agreement. It means that you must give the same degree of access to your home market that you give to the most favoured nation to all WTO members. A favour for one should be given to all.

You should not discriminate for or against any WTO member.

'Closer integration'

There are a few situations where the rules allow countries to depart from this principle - the one that is relevant here is for free-trade areas and customs unions (the two have important similarities, but are not the same).

Image caption The World Trade Organization is based in Geneva and came into being in 1995

The WTO's rule book says the member countries "recognise the desirability of increasing freedom of trade by the development, through voluntary agreements, of closer integration between the economies of countries parties to such agreements".

So a trade agreement between the UK and the EU would be allowed under WTO rules, in fact welcomed, even though it is something that is intrinsically discriminatory. It would involve the EU and the UK discriminating in favour of each other against outside countries.

Of course, the EU itself has the same effect, offering EU members better access to each other's markets than is available to either China or the United States, for example.

But there is a catch. The WTO rules say such agreements should cover "substantially all the trade" between the members of the customs union or free-trade area.

What does "substantially all" mean? There is some case law which touched on this. A dispute between Turkey (which has a customs union agreement with the EU) and India went to the WTO's appeals body, which said in its report: "It is clear, though, that 'substantially all the trade' is not the same as all the trade, and also that 'substantially all the trade' is something considerably more than merely some of the trade."

Not as cut and dried as you might hope, but all the trade experts I have spoken to say that a deal covering just a few sectors wouldn't qualify.

'Glass houses'

That seems to be reinforced by what a WTO dispute panel said in another case. This one, as it happens was about cars, an agreement between the US and Canada in the 1960s known as the Auto Pact.

Image caption Nations living in protectionist glass houses shouldn't throw free-trade stones

There is one line in the panel's ruling that is particularly relevant here: "The Auto Pact, nevertheless, is a purely sectoral agreement which does not meet the requirements of Article XXIV:8" - that is the provision that sets out the "substantially all the trade" requirement.

So such a narrow sectoral deal might well be vulnerable to challenge in the WTO.

But would it actually happen?

There seems to be a great deal of reluctance to challenge these agreements. (The India v Turkey and Auto Pact disputes were not fundamentally about the wider trade agreements, but about very specific restrictions that the complaining country thought were against the rules.)

More than 600 of them have been notified to the WTO or its predecessor, the General Agreement on Tariffs and Trade.

Many are thought to stretch the credibility of "substantially all trade", by having various sectors uncovered.

But that makes countries reluctant to challenge others, for fear of shining an unwelcome light on their own agreements. As one senior trade official put it to me: "It's a glass houses kind of thing."

Rules are rules

So a sectoral agreement between the UK and the EU might be challenged, but it would depend on whether any country wanted to do so.

Think of cars. There is another factor that might make a challenge less likely. Japan and the United States have car industries that have a presence in Europe and might well benefit from a deal between the EU and UK.

So perhaps we might get away with a narrow trade agreement. Even so, the uncertainty would be unwelcome to the industry concerned.

There is also the possibility of simply ignoring any unwelcome WTO ruling. The WTO has no real powers of enforcement. It can allow the other side to retaliate, but it can't arrest the trade minister.

On the other hand, the British government appears to be keen on the rules-based system of international trade and would probably be very uncomfortable about defying a ruling.

All the more reason, if the UK and the EU are going to have a trade agreement, to get as many sectors covered as possible, to reduce the chances of a WTO challenge.