Theresa May is staring humiliation in the face, about to go down in history as the prime minister who had one job and failed. Her defining task was to take us out of the EU, and now it looks as if it will never happen.

Yet this week in parliament she seemed indestructibly positive, confident and cheerful.

She seems to have given up on her partners in the DUP, and I cannot see Jeremy Corbyn coming to her aid by facilitating Brexit. Nor does it seem likely that 30 or 40 Labour MPs are going to break ranks to vote for any deal she proposes.

Her party will do badly in the local elections on 2 May and disastrously in the European parliament elections three weeks later. This country was not supposed to be sending a new cohort of MEPs to Brussels and Strasbourg, and the Conservatives will be punished for allowing it to happen.

It is hard to see how she can survive as leader and prime minister much longer after that. Formally, the party rules may prevent another challenge to her leadership until 12 months after the last one, in December, but Tory MPs can change those rules. I think they are desperate enough now to take the risk of Boris Johnson in Downing Street.

Opposing protesters flock to parliament on would be date of Brexit Show all 30 1 /30 Opposing protesters flock to parliament on would be date of Brexit Opposing protesters flock to parliament on would be date of Brexit Pro-Brexit leave the European Union supporters attend a rally in Parliament Square after the final leg of the "March to Leave" in London AP Opposing protesters flock to parliament on would be date of Brexit The protest march which started on March 16 in Sunderland, north east England, finished on what was the original date for Brexit to happen before the recent extension Reuters Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter holds up a poster during a rally after the final leg of the "March to Leave" in London, Friday, March 29, 2019. Pro-Brexit demonstrators were gathering in central London on the day that Britain was originally scheduled to leave the European Union. (AP Photo/ Kirsty Wigglesworth) Kirsty Wigglesworth AP Opposing protesters flock to parliament on would be date of Brexit A pro-Brexit protester holds a sign next to a statue of Winston Churchill at the March to Leave demonstration in London, Britain March 29, 2019. REUTERS/Toby Melville TOBY MELVILLE Reuters Opposing protesters flock to parliament on would be date of Brexit Brexit demonstrators in Parliament Square in Westminster, London. PRESS ASSOCIATION Photo. Picture date: Friday March 29, 2019. See PA story POLITICS Brexit. Photo credit should read: Jonathan Brady/PA Wire Jonathan Brady PA Opposing protesters flock to parliament on would be date of Brexit Pro-Brexit protesters hold signs and wave flags at the March to Leave demonstration in London, Britain March 29, 2019. REUTERS/Toby Melville TOBY MELVILLE Reuters Opposing protesters flock to parliament on would be date of Brexit epa07471421 Pro-Brexit protesters gather outside of the Parliament for Nigel Farage's 'March to Leave' in London, Britain, 29 March 2019. MPs rejected Prime Minister's May EU withdrawal agreement earlier in the day. EPA/NEIL HALL NEIL HALL EPA Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter sips a can of Stella in protests outside of the Houses of Parliament AFP/Getty Opposing protesters flock to parliament on would be date of Brexit Dedicated anti-Brexit campaigner Steve Bray and likewise pro-Brexit campaigner Joseph Afrane go head to head near the Houses of Parliament AFP/Getty Opposing protesters flock to parliament on would be date of Brexit A pro-Brexit marching band in Parliament Square Getty Opposing protesters flock to parliament on would be date of Brexit Remain supporters wave EU flags from a bus in Parliament Square PA Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter shouts slogans outside parliament EPA Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter protests outside parliament Reuters Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter protests outside of the Houses of Parliament Getty Opposing protesters flock to parliament on would be date of Brexit Brexit supporters protest outside of the Houses of Parliament REUTERS Opposing protesters flock to parliament on would be date of Brexit A pro-Brexit flag is waved in Parliament Square AP Opposing protesters flock to parliament on would be date of Brexit The March to Leave nears the Houses of Parliament Reuters Opposing protesters flock to parliament on would be date of Brexit A Brexit protester holds a sign outside parliament EPA Opposing protesters flock to parliament on would be date of Brexit Brexit supporters carry the coffin of democracy AFP/Getty Opposing protesters flock to parliament on would be date of Brexit Brexit supporters march outside parliament AFP/Getty Opposing protesters flock to parliament on would be date of Brexit Brexit supporters take part in the March to Leave protest in London PA Opposing protesters flock to parliament on would be date of Brexit Brexit supporters protest outside parliament AFP/Getty Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter holds a sign outside the Houses of Parliament Getty Opposing protesters flock to parliament on would be date of Brexit A man holds satirical paintings of politicians Reuters Opposing protesters flock to parliament on would be date of Brexit An pro-Brexit float on the March to Leave march in London Reuters Opposing protesters flock to parliament on would be date of Brexit Far-right activist Tommy Robinson addresses protesters outside the Houses of Parliament Getty Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter outside the Houses of Parliament Reuters Opposing protesters flock to parliament on would be date of Brexit A Tommy Robinson supporter arrives at the Houses of Parliament Getty Opposing protesters flock to parliament on would be date of Brexit A jogger gestures rudely at a Brexit supporter outside of the Houses of Parliament AFP/Getty Opposing protesters flock to parliament on would be date of Brexit A Brexit supporter outside the Houses of Parliament PA

Yet when May stood at the dispatch box on Thursday, after EU leaders agreed in the early hours of that morning to postpone Brexit for up to six months, she seemed upbeat.

She even recklessly contradicted Sammy Wilson, the DUP MP, when he claimed she had never said “no” to anything in her Brexit negotiations. She had refused to accept Northern Ireland being separated from the UK in a temporary customs union, she said.

I am told that the prime minister’s mood is just as buoyant in private. Does she know something we don’t? Does she have a secret plan that will persuade MPs over the Easter break? Everything we know about her suggests not.

The only explanation I can think of is that she is human after all, and that, like the rest of us but more so, she is capable of deluding herself that something will turn up.

Prime ministers tend to be a curious combination of unrealistic optimism and paranoid pessimism. Most of them seem to spend a lot of time worrying about losing their jobs even when – unlike May’s – they seem secure. But equally they believe that, as long as they are in the job, they can shape events and take advantage of the unexpected.

So perhaps it is premature to write her off as a failure. But it seems that for three years Brexit has absorbed most of the energy of her government, distracting it from doing anything much about the “burning injustices” of which she spoke on coming to office. Now all that has been wasted, and she has nothing to show for those brave, empty words.

Looking back, I suspect historians may conclude that one of her mistakes, far from the conventional view that she triggered Article 50 too early, was that she did it too late, losing momentum. By this year, the conviction that the referendum had to be respected had dulled, and Labour MPs had become used to voting against leaving on the government’s terms – even if they were pretty much the same terms that they would have negotiated.

She will bequeath to the nation a terrible sense of unfinished business. Instead of giving up the attempt to leave the EU by a positive decision of parliament, endorsed by another referendum, what seems most likely is that Brexit will simply peter out in a series of extensions.

Support free-thinking journalism and attend Independent events

Whoever succeeds her as prime minister will no doubt be pledged to prepare for a no-deal Brexit, because that is the kind of unrealistic but strident rhetoric that will appeal to Tory party members. It will be boosted by the likely success of Nigel Farage’s Brexit Party in the European elections.

But it will get us nowhere, because we know that the House of Commons will not allow it. There is no majority in parliament for leaving the EU without a deal now, and there wouldn’t be after a general election, even if it went well for the Tory party, a proposition that only has to be written down to be dismissed.

What is more, there is no secure mandate for it from the 2016 referendum. In theory, people were voting to leave the EU with or without a deal, just as the 498 MPs who voted to trigger Article 50 were. But the assumption at the time was that a deal would be agreed. If a no-deal Brexit were put to a referendum now, I think it would lose. Boris Johnson has just been corrected by Ipso, the press regulator, for asserting, wrongly, that opinion polls find a no-deal Brexit “is by some margin preferred by the British public”.

Yet people believe what they want to believe. Theresa May believes she can still save her premiership. Much of her party believes that leaving the EU without a deal is still possible.