Logic Programming Technology

But would they be neighbours like this?

Photo by lorenzaccio* CC BY
Photo by lorenzaccio* CC BY

The “Doors to Heaven and Hell” riddle. It’s an oldie and a goodie. I’m sure everyone’s pretty familiar with it, but in case you’re not here’s a quick recap:

Bad news, you’ve just died. You find yourself in a nondescript hallway with two identical doors, each guarded by a man. You realise you’re holding a scrap of paper. It reads:

1. One of these doors leads to Heaven, one leads to Hell.
2. The man guarding Hell’s door always lies. The man guarding Heaven’s door always tell the truth.
3. You may ask one of them one question.

(Note: You also can’t use any external reference points e.g “Does 1 + 1 = 2?” You have to limit your questions to the men and their situation. Nor can you do a Karl Pilkington and try to trick God into coming to the door to sign for his post)

So if you were to ask them, “Where does your door lead?” the man guarding Heaven would say “Heaven”, as would the man guarding hell (since he’d lie). That would be a bad question, since if you asked either of them, they would give the same answer. The aim of the riddle is to ask a question which is guaranteed to let you know which door leads to heaven and which leads to hell. The good thing is, there is a solution.

The answer is annoyingly simple once you hear it. The correct question to ask is “If I was to ask the other guy what door he was guarding, what would he say?” If you happened to ask the man guarding heaven, he’d know the other guy was guarding hell, and he’d know he’d lie, so he’d say “Heaven”. Likewise if you happened to ask the man guarding Hell what the other guy would say, he’d know the guy guarding heaven would say “Heaven”, so he’d lie and say “Hell”. The answer they give is the answer to which door they’re guarding.

In fact there are several variations of the question which you could ask (E.g. “If I was to ask the other guy what door you were guarding, what would he say?”) Another interesting variation is “If I were to ask you what door you were guarding, what would you say?”. The liar’s process would have to be:

1. OK, I’m guarding hell
2. If he was to ask me what door I was guarding, I’d say “Heaven”
3. But I need to lie about the answer to (2)

And he’d have to say “Hell”. So you’d know he was guarding hell.

The same principle behind each of these questions is the principle of chaining their systems in series. Let’s use some logic gates to show you what I mean.

So a basic NOT gate (or inverter) takes in a value and returns its opposite.

That's not a knife that's a spoon

So 0 goes in, 1 come out. Another way to put this:

Hell goes in, heaven come out. The liar in the riddle is a basic inverter. He is forced to tell the opposite of what he knows is the truth. The truth-teller, on the other hand, does nothing to the truth. The input travels unmolested through his “process”.

Asking one of these guys what the other would say guarantees that we are passing our input through both processes. And we know that one of them is an inverter, and the other does nothing to the input. So with a question structured to invoke both processes, we know the output will be the negative of the answer we really want. And again, in logic gates:

Similarly, my alternative “What would you say if I were to ask you…” example is the equivalent of passing the input twice through the inverter. In other words, the input would exit the process having been inverted twice, thereby having suffered no modifications.

Interesting stuff. And who’d have thought I’d actually find some use for my logic-gate knowledge?

Life Writing

Lead Balloon

Photo by groggy_girl
Photo by groggy_girl CC BY

So, my lung collapsed on Tuesday 22nd of June.

I woke up at my usual time, stood up, sat down. Stood up, tried to stretch, sat down again. It felt like a lead ball was sitting in my chest – every time I tried to take a breath, it would send a wave of – not pain – discomfort across my upper body. I shuffled around for a while, giving it a chance to dissipate, but it got worse.

If I were directing this film, we’d now cut to a montage of half-second shots spliced one after another: stethoscope placed on a back; blood filling a vacuum tube; a blood pressure sleeve inflating; the flash-click of an X-ray machine; EKG stickers ripping off a chest. After a swathe of tests, I was moved to a room and told to wait for a doctor.

Three hours later, she appeared.

“All the test were clear – you can go home!” she said, obviously expecting me to high-five her and scamper.
“Oh, great… What’s this pain then?”

She shrugged.

“Maybe a pulled muscle?”
“Well, if it still hurts in a couple of days, should I come back?”
“Have you tried any pain killers?”
“Uh, no.”
“Try some… Cocodamol?”

She had no clue. I didn’t want to ignore the pain – I wanted to know what was causing it. To me, that’s like responding to getting shot in the stomach by changing your shirt. Nevertheless, sad little pack of painkillers in hand, I was sent home with an all-clear.

Two hours later I got a phone call from the same doctor.

“We’ve been looking at your X-ray again and you need to come in, OK?” She went to hang up.
“Whoa, why?”
“Oh, there’s a pocket of air.”
“In your chest.”
“Outside my lung?”
“Right hand side.”
“Wait, outside my lung?”
“Right hand side.”

It was infuriating. So I packed some overnight stuff and headed back to hospital. When I got there, I was assigned another doctor, who promptly informed me that I had spontaneous pneumothorax.

“What caused this?” I asked
“There’s no real cause. It tends to affect young, tall men – how tall are you?”

I was sitting down.

“About 5’11.”
“Well, young men.”

I didn’t have time to feel offended as she reeled off a number of things I’m now no longer allowed to do: Scuba diving, free diving, space travel. (Space travel! Looks like I’m never getting off this rock.)

And then, feeling like a seedy call-girl, I was undressed, drugged up and things were put in my body. The doctor had a fun time making room for my chest drain. I didn’t so much hear as feel a crunch as he broke through my intercostal muscle. Within minutes, a tube snaked its way from 6 inches in my chest to a tub of water on the ground. When I breathed, the water bubbled.

For a beautiful, glorious moment I felt the cinder block float off my chest and I sighed in relief.

Then someone stabbed me in the lung. In the space of 2 minutes, my lung had gone from sad deflated party balloon to majestic zeppelin, and there were 6 inches of tube in my chest. Oh the humanity! I have this image in my head of my chest waking up from the local anesthetic, looking around, seeing a big daddy tube and going “WhoaaaAA! Get this OUT OF ME!” I was shot up with morphine and left in agony for a few hours until my chest must’ve decided to just get used to it. And so began my 3 night stay in a mad house.

I was kept in a ward with 5 other guys, ranging from 50 to – really – 95. Fun crowd. The guy to my left spent the first night moaning in agony. Distraught, he cried for a nurse for about half an hour. Thinking he couldn’t reach his buzzer, I buzzed my own and the nurse came through.

I said, “Sorry, it’s not for me, but this guy was calling for help.” She jabbed my buzzer off and yapped “He can do it himself!” I was outraged. Here I was trying to do good for my fellow man, and she had the temerity to chide me for it! After all his moaning and agonising, when she asked him what the problem was he replied pathetically,

“I’ve got heartburn.”

The next night, the man across from me – obviously delirious with fever or drugs – tried to escape. Since he wasn’t stable on his feet, the nurses had repeatedly told him to stay in bed. I watched him cast a furtive glance right and left, clamber out of bed wearing nothing but an adult-sized pair of nappies, and make a fucking run for it out the corridor. It was like the Great Escape. I buzzed a nurse and they caught him 3 hallways down. I don’t think I’ll ever forget the image I saw through the window to the corridor, of that near-naked man as he stumbled hurriedly to freedom, his glazed expression betraying an accent of hope.

When he wasn’t breaking out, Dave (we’ll call him Dave) spent his time sleeping, shouting at imaginary people, and stress-testing his Pampers. Terribly, I got used to it. I woke up on the third night to the sound of a meaty thud. Peering from my bed I just saw his two legs lying toes-down on the ground. I buzzed a nurse, made sure someone came, and went back to sleep.

Dave didn’t lack for competition. A man at the far end spent his time pulling his oxygen line out of the wall, grabbing his zimmer frame while lying in bed and sweeping it around dangerously, clattering cups and food all over the floor. So not an insignificant amount of my time was spent attempting to ignore the sound of oxygen hissing out of the wall, drinkware crashing to the floor, and hallucination-induced screaming.

The 95 year old man slept sitting upright in the chair next to his bed. He bore his illness stoically. During the day he’d shuffle up and down the corridor to stretch his legs. Every night he went to the bathroom and shaved, and the nurses told me that back home he looked after his wife. The dignity with which he held himself made me want to cry. I was sorry to leave without having spoken a word to him.

I’m now back at work, whittling days off the next 7 weeks until I can gingerly place trust in my lungs enough to start exercising again. In 7 weeks, with luck, it’ll be like nothing ever happened. But now I have a chink in my armour. It’s idiotic I know, but on an emotional level it took my lung collapsing to realise “Oh right, yeah, I’m not invincible”.

I should probably be clear – what I went through was nothing. At no point did I ever have to face my mortality, at no point was I ever in any real danger. My worst fate is that if it happens again, I might be forced to drop all forms of exercise. Compared to what so many people I know have been through or are still going through, it’s not even a drop in the ocean. It’s not a bead of sweat falling from a flea’s testicle into the Pacific.

But I can’t help feeling like King Xerces with a cut cheek, realising he can bleed, too.

And since we’re on a 300 kick, I’ll end with a quote from Richard, who kindly left me this message:

It’s just a lung. The Gods saw fit to grace you with a spare.