On the surface, the new film, “Robot and Frank,” written by Christopher D. Ford and directed by Jake Schreier, seems to be a sweet, slight buddy comedy. The story centers on Frank (played with banked fire by Frank Langella) a retired cat burglar living out his sunset years a decade or so from now in a pleasant home in the Hudson Valley. Frank is in the early stages of dementia, and, as these things go, reluctant to admit it and fiercely resistant to any suggestion that he needs to be looked after. His son (James Marsden), fed up with spending hours on the road to visit him weekly only to have his father spit on all his attempts to help, hits upon the solution: a robot home-health aid.

Thus does buddy meet buddy. And things proceed initially pretty much as you’d expect: Frank resists, and robot – pleasantly but mechanically – persists in its mission of changing Frank’s life, from his diet to his sleep patterns to his exercise regimen, failing only in its efforts to engage Frank in a hobby or project that will sustain him cognitively. Frank grumblingly gets used to the robot without warming to him (Peter Sarsgaard provides the warmly-inflected voice), until he discovers a gap in the robot’s programming. Nobody thought to teach it that stealing is wrong. And thus, Frank finds his project: teaching the robot his criminal trade, and, with the robot’s help, getting back into the game. And so he does, and, as they say, complications follow.

The film is a charming little dramedy. There are just the right number of twists; the familial conflict and bitter-sweet resolutions thereto come with metronomic regularity; setups are planted unobtrusively and pay off with professional timing – all-in-all, a well-written and well-structured bit of Hollywood entertainment.

But there’s a chill under the cheer that not only is not dispelled, but blows with particular iciness in the final sequence.

From the days of Karel Čapek, we’ve told ourselves anxious stories about the rise of the machines, and the fear usually is that we will wind up ceding too much of ourselves to them – too much power, too much authority, too much of what makes our lives meaningful. This fear is what Frank articulates at the beginning – he’s not going to take orders from a machine, blah, blah, blah.

As the movie goes on, though, it becomes clear that this is not the deep, true fear. The deeper fear is that, as our machines get more and more human-like, we will be forced to confront the fact that we, too, are just machines.

The robot in “Robot and Frank” has a surprising (and wholly unrealistic, I hope) degree of self-awareness. At one point, when Frank balks at following this or that robotic instruction, saying he doesn’t care if this or that is good for him, and the robot asks: what about me? If he fails to help Frank, he’ll be sent back to the factory and his memory will be wiped. Then, later in the movie, the subject comes up again, and the robot admits that he doesn’t actually care what happens to his memory. He lied, in order to coerce Frank into compliance. Frank is charmed by the robot’s mendacity, but can’t believe the robot wouldn’t actually care about having his memory wiped. But the robot replies: he’s not a human. A human being knows he’s alive. He, being a robot, knows that he isn’t. So he doesn’t care. To which Frank responds: I can’t sit here and listen to you talking about how you don’t exist – it depresses him.

As well it would. After all, this isn’t an abstract question to an octogenarian suffering from dementia. But this little robot passes the Turing test sufficiently well that Frank confuses him for his son (as a young boy) at several points. So, if this robot, who knows he doesn’t exist, and hence doesn’t mind having his memory erased, can seem so human to Frank that he forms a closer bond with him than he has with his own family, then what is it that Frank is holding on to so desperately? What makes him think he’s any different from the robot? Isn’t all his cantankerousness, his determination to start thieving again, which Frank plainly thought of from his youth as a revolt against respectability and obedience to the social machine, just a desperate and doomed revolt against the reality principle? And what, ultimately, is so noble about that revolt?

That’s the question that resonates at the very end of the movie. Frank has finally been placed in a home. His dementia has gotten worse, which has (again, somewhat unrealistically) made him more tractable, more pleasant to his visiting family, who are plainly relieved that he has finally become so manageable (and that they no longer have to manage him, or feel guilty that they are not doing so). But Frank, in his fog, doesn’t seem to miss the old anger; to all outward appearance, he has ceased raging against the dying of the light.

He has one moment of lucidity, though, sufficient to pass on to his son a crucial piece of information, and then we see him, as they leave, standing in the corridor. Watching the other residents shuffle along, following their routines. Followed by their robotic attendants, who are simply following theirs.

The shot sent a chill up my spine, as it was intended to. There are unexpected depths beneath the pleasant surface of “Robot and Frank.” Depths worth the plumbing.