Although I really wnjoyed the first 50 minutes, I feel there was a massive plot hole at the end- how did Hilbert intend to escape? That is, how did he intend to break open the blackboard, climb through and get down, with three healthy young people that want to kill him on his back? Loved loved loved the first hours, but I though the end was really hokey.
Hilbert probably didn't intend for them to find him out. Hell, he probably didn't intend to escape.
Pascal claimed that Hilbert had no intention of dying, but it was only speculation. We do know for a fact that he had been contemplating suicide, so he may have, in fact, intended to die in that room. The escape route may have been some sort of 'reward' for the other three proving their genius to him; an escape if they were smart enough.
Of course, I'm just speculating myself, and I also felt the end had a few unreasonable plot devices. As do you, I also did really like the movie. However, I really thought the movie would have integrated mathematics into the plot more, but it didn't really seem all that important in the scheme of things.
Hilbert had no intention of living. He had already contemplated suicide etc.
He wanted the other 3 though to find a way out. To find the secret to the room and as Local says prove their genius. He was baffled that the young man had figured out how to solve the problem so easily and early in his life, so he wanted to see just how genius he was. When he couldn't even get that riddle right you could see how upset Hilbert was and then the truth came out.
The only problem with that line of thinking is, if he was intending to die that night, why didn't he pick the name of a mathematician that was his age? He picked one that lived into his 80s, unlike all the other characters who were the correct age as they were.