Image caption MPs in the House of Commons will debate how much European law the UK will keep

Exiting the EU would mean UK citizens losing their EU citizenship. That might sound like a formality, but actually it has big legal consequences.

Over the decades of EU membership the UK has incorporated a vast body of European law into its national laws.

Unpicking all that is going to be a mammoth task, likely to keep lawyers busy for years. And it's not yet clear when all that will start.

Is there any legal certainty about the UK leaving the EU?

No - the UK is not compelled to leave, because the referendum was "advisory", not legally binding.

But many commentators take the view that the Brexit triumph - 52% for Leave, 48% for Remain - provides a political imperative to exit.

The EU's Article 50 - a treaty clause on withdrawal from the 28-nation bloc - provides an orderly procedure for Brexit. That is the way the UK is expected to go.

But some legal experts say Article 50 would have to be triggered by an Act of Parliament - they argue that the prime minister alone could not legally do it. And most MPs are in the Remain camp - so they would be voting for something they disagreed with.

Article 50 sets a two-year deadline for leaving the EU, once the article is triggered. It assumes that a new agreement would be reached between the departing state and the EU, but does not demand it.

In order to scrap EU laws before Brexit the UK could repeal the European Communities Act 1972. But Prof Mark Elliott, a constitutional law expert at Cambridge University, says to do so "would risk legal chaos by placing the British and EU legal regimes on a collision course with one another prior to the UK's having extricated itself, as a matter of international law, from the EU legal order".

Image copyright Reuters Image caption It is not clear when UK passports would have to be exchanged for non-EU ones

Can the law stop Brexit?

Five challenges for UK leaving the EU

The UK's EU vote: All you need to know

Can the UK government simply strip its citizens of their EU citizenship?

There are various legal opinions about this - it is not clear whether the UK has an unequivocal right to do it.

Brexit would set a legal precedent - it is uncharted territory, because no EU member state has left the bloc before. Greenland left as a self-governing territory in 1985, but it remained part of Denmark, which is an EU member.

Image copyright Getty Images Image caption Greenland - with a tiny population - left the EU in 1985

Prof Sionaidh Douglas-Scott, a European law expert at Oxford University, told the BBC that if the UK was no longer in the EU, "this would suggest its citizens are no longer EU citizens".

But she said a European Court of Justice (ECJ) ruling - the Rottmann case - "held that deprivation of EU citizenship (albeit in circumstances different from Brexit) might not be a matter just for member states, but that the EU might have a role as well".

In a blog analysis on Brexit, Prof Steve Peers, a law expert at Essex University, says that "if a country ceases to be a member state of the European Union, then obviously its nationals therefore cease to be citizens of the Union".

Prof Catherine Barnard, a European law expert at Cambridge University, says some argue that "UK nationality is the gateway to EU citizenship and EU rights and if we are not in the EU any more UK citizens do not get those additional rights".

But, she adds, EU citizenship in the context of Brexit is "a really big question - and no-one knows the answer".

UK law provides enough human rights protection for UK citizens, doesn't it?

Brexit does not mean withdrawing from the European Convention on Human Rights - the fundamental rights law enforced by the European Court of Human Rights (ECHR) in Strasbourg. The ECHR is not an EU institution, so Brexit does not affect it.

And the convention has legal force in the UK through the 1998 Human Rights Act.

There is a move in the Conservative Party to replace that act with a new Bill of Rights. That would be complicated, however, because the rights guaranteed under the convention are also written into the Good Friday Agreement for Northern Ireland. That agreement underpins the Northern Ireland peace process.

Image copyright AFP Image caption The UK is subject to rulings of the European Court of Human Rights in Strasbourg

Various EU rights - such as the Working Time Directive, stipulating working hours and time off - are already enshrined in UK law. But they could be scrapped after Brexit.

Brexit could remove rights enshrined in the EU treaties - unless the UK agreed to keep them under a new settlement with the EU.

They include the right to move freely to another EU country and work there, and the right to stand for election in another EU country.

Media playback is unsupported on your device Media caption How does the European Union work?

The Charter of Fundamental Rights, attached to the EU treaties, would no longer apply to UK citizens.

Prof Douglas-Scott says "all Charter rights are currently effective in the UK", despite a UK opt-out from the Charter's fourth section, called "Solidarity", which deals with workers' rights. That opt-out was found to be ineffective, she told the BBC.

She says the UK Human Rights Act (HRA) "would not be an adequate replacement for the Charter".

"The Charter contains 47 rights - which is about three-and-a-half times as many rights as the HRA. So all those other rights would be lost," she said.

Doesn't the EU itself infringe some citizens' rights?

A debate is raging in the EU about this - it really depends where you stand politically.

Some argue that the EU's treatment of Greece - the painful austerity demanded as a condition for the bailout - was itself a violation of human rights. Many Greeks suffered from the cuts to jobs and welfare that were required for Greece to remain in the eurozone. Greece's lenders refused to write off its colossal debts.

The EU's deal with Turkey on sending migrants back from the Greek islands has also drawn criticism. There are serious concerns that Turkey may not adequately safeguard the rights of migrants - many of them Syrian refugees.