No doubt about it: Even by the eccentric standards of Cambridge University in the 1930s, Alan Turing was a mess.

The young mathematics student wore a jacket and tie, of course, just as all students did in those days. But he managed to make his clothes look as though he'd bought them in a rummage sale. He never seemed to comb his hair or clean his fingernails. He often neglected to shave, since he might nick himself and would invariably faint at the sight of blood.

In addition, he was rude, the kind of guy who thought it redundant to acknowledge your existence if he'd already said hello to you once that morning. And he had this . . . voice. It was a high-pitched stammer when he talked, a nervous crowing sound when he laughed and a kind of random squeak when he was lost in thought.

Turing got along well enough with his classmates, who found him to be a witty and lively, albeit odd, companion. Visitors to his rooms might find his teddy bear propped in front of the fire with a book.

But Turing was a very solitary young man. He had been born in 1912, the second son of parents who felt it best to leave their boys in foster care while they were away from England during their many tours of duty with the Indian Civil Service.

As a result, Alan grew up a shy, awkward, excitable lad, brilliant at mathematics and science but a comparative stranger to his parents -- and to almost everyone else. By the time he entered Cambridge, moreover, Turing had realized that he was homosexual, a secret reality that he hid from almost everyone, at the price of constant internal agonizing.

"Gross indecency," as it was officially known, was a criminal offense in the England of 1935. As Turing once lamented to a young (straight) friend, he had the constant sense of living in a looking-glass world in which all conventional ideas were the wrong way about.

As if by compensation, however, his loneliness also gave rise to a strange and wonderful originality. He did things in a way that seemed straightforward to him but that no one else would ever think of.

He loved to ride his bicycle through the countryside. To time himself, he would simply tie an alarm clock around his waist. During the war, according to I.J. Good, a Cambridge mathematician, Turing suffered horribly from hay fever during the first week of June every year. So to keep the pollen off while riding, he wore a military gas mask.

Turing's bicycle chain developed a habit of falling off after a certain number of revolutions. Rather than have it fixed, he would simply count the revolutions and dismount in time to readjust the chain by hand.

THE MATH WHIZ

Turing went at mathematics in much the same strange spirit. "When he attacked a problem, he liked to start from first principles," Good writes, "and he was hardly influenced by received opinion." Indeed, he often didn't even bother to find out what others had already accomplished in the field, preferring to reinvent the wheel.

Never was that more obvious than in a 60-page paper he published in 1937 at age 24. Turing's paper started with one of those trivial-seeming questions that isn't trivial at all: What does it mean to compute a number? Turing was thinking of "compute" in the then-current sense in which a human mathematician sat with pencil and paper to calculate, say, the area of a circle four inches in diameter.

Nonetheless, he knew that the elementary concept of number lies at the foundation of practically everything else in mathematics. So if he could define precisely what it means to compute a number, he could define precisely what it means to prove a mathematical theorem or to make a logical deduction.

Indeed, he could ask whether human reason itself is all-powerful. Can it encompass all conceivable truth? Or are there limits? Numbers that can't be computed? Theorems that can't be proved? Deductions that can't be made?

Such vexing questions were uppermost in mathematicians' minds at the time. Since the turn of the century, many theorists had begun to think that they were close to achieving the long-held goal of placing the logical "completeness" of mathematics on an unshakable footing.

But then in 1930, Czech-born logician Kurt Godel dropped a bomb in the form of a proof that no mathematical system, not even the comparatively simple case of arithmetic, could claim to be universal, self-contained and complete. No matter how powerful and consistent its axioms, it would still generate statements that could neither be proven nor refuted by the axioms in all cases.

Turing's reasoning addressed questions no less fundamental. "According to my definition," Turing declared on the very first page, "a number is computable if its decimal can be written down by a machine." No such computing machine existed in 1936, and modern digital computers wouldn't be developed for another 10 years.

A UNIVERSAL COMPUTER

Turing was undeterred. He defined precisely what his hypothetical machine would have to do. First, he said, imagine an infinitely long tape divided into squares like a roll of postage stamps. Each square is blank or has a symbol written on it.

What the symbols are doesn't matter, Turing said -- numbers, letters, colors, pictures, whatever -- as long as there is just one per square.

Next, imagine a scanning device that can move forward or backward along the tape. To use a modern analogy, it would function very much like the read/write head of a tape recorder or a VCR. When the machine is turned on, Turing said, this scanning device looks at one square at a time.

Depending on what symbol it finds there, it can do one of four things -- erase the symbol, write a new symbol, move one square forward or move one square back. And that is all.

Today, of course, we can recognize Turing's imaginary machine as an extremely simple version of a modern computer. The read/write head corresponds to the central processor, and the tape corresponds to a program residing in the computer's memory. But even then, Turing was able to show that his imaginary "universal" machine was as powerful as a computing machine can be. Given enough time and tape to work with, it could compute any number that can be computed.

No machine could do more. In modern terms, this means that all computers are fundamentally the same. Given enough time and memory capacity, the lowliest desktop PC can do anything that the mightiest supercomputer on the planet can do.

Turing went further. He showed that certain things cannot be computed, no matter how cleverly the machine is designed. For example, no computer can predict its own behavior. Except in very special cases, the fastest way to find out what your program will do is to run it and see.

That is, the old saying about the mindlessness of computers is true but irrelevant: A computer does only what the programmer tells it to do. But programmers can't really know the consequences of their commands until they see the program running -- one big reason that Microsoft and other software vendors spend so much time debugging their products.

There is no universal testing program that can guarantee another program's correctness. Or to put it still another way, Turing showed that his imaginary machine had some of the same unpredictability as the human mind.

BRAIN OF A NEW MACHINE

This was a philosophical departure for a young man who had spent his youth deeply concerned about issues of free will, convinced that spirit could not be reduced to mere matter.

By 1936, however, his feelings on this subject were clearly shifting -- he would soon declare himself an atheist -- and this paper marked the first public hint of what was to become a lifetime conviction that there is no fundamental difference between human brains and computing machines. They both perform the same functions, what we would now call information processing.

Although these concepts are familiar enough in 1999, they were radical at the time. But after some initial shock, Turing's tutor encouraged him to submit his paper to a journal. He did so despite a horrifying episode in which he found that American logician Alonzo Church of Princeton University had just published precisely the same result, though in slightly different terms.

If Turing had deigned to look at the research literature on the decidability problem before he started, he would have found Church's earlier papers and doubtless saved himself great effort and agony. Of course, as Andrew Hodges, a Turing biographer, points out, Turing also would have saved himself the trouble of inventing his machine and thereby founding the field of computer science.

The paper eventually was published, if little read. Meanwhile, Turing had gone to Princeton -- the Emerald City of mathematics -- in fall 1936. There he met such luminaries as John von Neumann, a versatile giant in several mathematical fields and a leading pioneer in logical design, now called systems architecture.

Offered the coveted position as von Neumann's assistant, Turing -- still a confirmed loner -- couldn't bring himself to say yes. By then, it was March 1938. Adolf Hitler had forcibly annexed Austria, and Turing desperately wanted to return home to Cambridge, to England and to the war.

CRACKING THE CODE

Very few mathematicians had paid attention to Turing's "universal computer" paper when it was published in 1937. Turing, however, remained anxious to see whether his imaginary machine could actually be built "in the metal." By a stroke of good fortune, World War II soon would show him the way.

Almost immediately after his return from Princeton in 1938, Turing began consulting with the British government on cryptanalysis, the breaking of codes. Precisely one day after the formal declaration of war in September 1939, he reported to a Victorian-era country house named Bletchley Park north of London, where some of Britain's best mathematicians were launching an all-out effort to decipher German military messages.

They were greatly aided in this task by the Germans themselves, who were continuing to use their "Enigma" encryption machine under the illusion that its codes were unbreakable. What the Germans didn't know was that the Polish secret service had learned how the Enigma was constructed and had revealed that information to the Allies shortly before Poland was overrun.

Armed with that knowledge, Turing and his associates could eventually crack any message they intercepted. The trick was to do it fast enough to be of use. If a German U-boat was closing in on an Allied convoy, the navy needed to know that now, not six weeks from now.

Here Turing made his mark, using the ideas on automatic computation that had been swirling through his brain since his imaginary machine of 1937. Decoding an Enigma message always started with an educated guess -- for instance, assuming that one particular combination of letters in the message, such as XFIFBQP, stood for a word such as "General."

Then a huge series of calculations was required to see whether the Enigma could actually produce that encoding. If not, then on to another guess.

Tackling the calculation problem first, Turing took the lead in designing the "Bombe," a high-speed calculator that could eliminate useless decoding schemes by the billions.

The Bombe couldn't be programmed to do anything else, so it didn't qualify as a full-fledged computer. But for this one problem, it was a wonder. By war's end in 1945, Bletchley Park was working dozens of Bombes day and night, with their frantically clicking relays making a noise like a thousand knitting needles at once.

Moving on to the trial-and-error part of the problem, Turing then used his knowledge of statistics and probability theory to show how guesses could be made systematically and with maximum efficiency. The whole Bletchley Park effort soon was reorganized to incorporate his methods. In 1944, moreover, some of Turing's fellow mathematicians had automated those methods with a programmable, fully electronic calculating machine known as Colossus, one of the world's first computers.

What Turing and his colleagues accomplished at Bletchley Park was one of the Allies' great secret weapons. To the German high command, convinced until the end that the Enigma codes were unbreakable, it seemed just the most inexplicable bad luck: The convoy would be elsewhere when U-boats arrived; tanks would hit a strong point, not the expected weak point, in the Allied line; supply ships would just happen to encounter Allied destroyers.

The war that had once seemed theirs for the winning kept slipping inexorably away.

NARROWING THE GAP

Turing finished the war having learned much about electronics and practical computing devices, and he soon put them to use at the National Physical Laboratories (NPL) outside of London, where British scientists were trying hard to match the American lead in electronic computers.

Not only did Turing's work on these projects convince him that his imaginary machine could be made to work, but it also finally convinced him that there was no fundamental difference between computers and the human brain.

This did not endear him to the NPL bosses, many of whom found his endless talk about "machine intelligence" crackbrained, disturbing and possibly sacrilegious.

But in 1948, he moved to the University of Manchester and two years later published precisely those ideas in the form of his famous "Turing test": If a computer can behave such that you can't tell whether its responses are made by a human or not, then you might as well say that the computer really is thinking.

That is, a computer simulation of a bomb most certainly doesn't go bang. But a computer simulation of information processing is information processing. And for Turing, information processing is the very stuff of which thought is made.

Viewed in retrospect, Turing's test certainly ranks as one of the most provocative assertions in all of modern science. To this day, people are still talking about the test, writing commentaries on it and voicing outraged objections to it.

At the time, however, it was generally ignored, and Turing began studying how pattern formation -- such as the spots on a butterfly's wings or the whorls of a seashell -- might be explained mathematically.

In January 1952, months after submitting his first paper on biological form, Turing was arrested in Manchester and charged with three acts of consensual sex with a teenage boy. His trial that spring resulted in a quick conviction.

Because of the importance of his work with the Manchester computer project, however, Turing was offered an alternative to jail: a one-year course of estrogen treatments, which, according to the medical thinking of the day, would reduce his supposedly perverted libido.

Turing took the estrogen. At the computing laboratory, he did his best to make a joke of the whole experience, including the fact that the female hormone was making his breasts develop. Moreover, he refused to show remorse or shame. He had become increasingly open and even proud of his homosexuality since the late 1940s, maintaining that the law was absurd. Nonetheless, he privately seemed to have been deeply humiliated by it all.

In June 1954, at age 41, Turing died suddenly after eating an apple dipped in cyanide. Officials declared his death a suicide, although his mother maintained forever afterward that it was the result of a playful chemical experiment gone awry. Either way, a mathematical genius was cut down at the height of his powers.

M. Mitchell Waldrop, a veteran science writer and author of Man-Made Minds (1987) and Complexity (1992), is finishing a book about computers.

CAPTION: Alan Turing, above, boarding bus, in 1946 when he was working at Britain's National Physical Laboratory. At left, the Nazi "Enigma" code machine.

CAPTION: Turing, shown here in 1946, was a top marathon runner.