DEV Community

Cover image for My condition
Pato Z
Pato Z

Posted on • Edited on

My condition

A story about fickle memory, pirates, unnecessary details and boolean logic.

"Hey Lenny, it's me, Teddy!"

Leonard looks blankly at the stranger for what seems like minutes. He then pulls a bunch of yellowed Polaroids from his pockets and checks them out. Eventually he finds a photo of this man, the photo reads "Teddy".

"Hi, Teddy", he says, "did I tell you about..."

My condition

"Yes, yes", Teddy cuts him off, "memory fades, never trust memory, memory's unreliable, I know the drill"

"Look, Lenny, I need a favor", Teddy continues, "I'd do it myself, but you know how it is, very busy and all"

"What do you need?" asks Leonard.

The favor

"I need you to help me reduce a logical expression!", shouts Teddy excitedly.

If Leonard could remember, he'd get the feeling Teddy always has an agenda, alas, he can't.

"Uhm", replies Leonard, "is that the whole business with the ands and the ors and the trues and the falses?"

"Yes! That's exactly it... except this might be a bit more complex than your typical run-of-the-mill expression", Teddy looks amused, "Are you familiar with De Morgan's laws?"

Leonard looks blankly for a couple of seconds, "I can't say I am"

Teddy saw this coming so he continues, "OK, bring a chair, I'll tell you a story. I'm pretty sure De Morgan wasn't a pirate but for the purpose of this story he might as well be one..."

Denial in the high seas

(Teddy's story)

Back in the day where pirates were the rage, there was one pirate captain called De Morgan. Now De Morgan's crew was very well known in the seven seas as a bunch of weirdos.

They were very proficient in all their piraty skills, all but one: their pirate lingo.

They were obsessed with negations. You couldn't get a straight answer from them even if you bribed them with grog. You couldn't even begin to disbelieve the lengths they'd go not to avoid saying things in a way not simple.

Needless to say they got on De Morgan's nerves. Commanding this crew was proving more and more difficult. He needed to find a way to make this work.

He though long and hard, while the crew plundered, pillaged and had the most outrageous philosophical discussions on deck.

Eventually Captain De Morgan created a bunch of rules to help him understand his crew:

1) When they say "Nay (A or B)" that is the same as "(Nay A) and (Nay B)"
2) When they say "Nay (A and B)" that is the same as "(Nay A) or (Nay B)"

And because back then a Captain's word was law, these became known as De Morgan's laws:

not (A or  B) = (not A) and (not B)
not (A and B) = (not A) or  (not B)
Enter fullscreen mode Exit fullscreen mode

(Teddy concludes his story and waits for it to sink in)

Only facts go in the notes

Leonard thinks about this for a while and asks Teddy an unexpected question, "How can you be sure those laws actually work in practice? How can you trust them?"

The question catches Teddy off guard but he manages to come up with an answer, "I can tell you, but first I'll need to tell you about..."

The place where truth is stored

(Teddy pulls out a piece of paper and starts another monologue)

Take a very simple expression, for instance:

A and B
Enter fullscreen mode Exit fullscreen mode

We all know the values for A can be either True or False, and the same goes for B.

We could put all those values right after the expression above and we'd get something like this:

A and B
-------
T     T    # both A and B are true
T     F    # A is true, B is false
F     T    # A is false, B is true
F     F    # both A and B are false
Enter fullscreen mode Exit fullscreen mode

Now, if we also compute the value of the whole expression and put that under the and operator we get:

A and B
-------
T (T) T
T (F) F
F (F) T
F (F) F
Enter fullscreen mode Exit fullscreen mode

But if we negate the expression above, we get not (A and B), and we can also compute the values of this new expression for every possible combination of values for A and B:

not (A and B)
-------------
[F] (T (T) T)    # `[]` is the the opposite of `()`
[T] (T (F) F)
[T] (F (F) T)
[T] (F (F) F)
Enter fullscreen mode Exit fullscreen mode

So in other words...

value of A | value of B | not (A and B)
-----------+------------+---------------
     T     |      T     |       F
     T     |      F     |       T
     F     |      T     |       T
     F     |      F     |       T
Enter fullscreen mode Exit fullscreen mode

We'll get back to this in a second, but lets think about something else.

What would be the values of A or B?

A or  B
-------
T (T) T
T (T) F
F (T) T
F (F) F
Enter fullscreen mode Exit fullscreen mode

And, if we negate both A and B:

(not A) or  (not B)
------------------
([F] T) (F) ([F] T)
([F] T) (T) ([T] F)
([T] F) (T) ([F] T)
([T] F) (T) ([T] F)
Enter fullscreen mode Exit fullscreen mode

In other words...

value of A | value of B | not (A and B) | (not A) or (not B)
-----------+------------+---------------+--------------------
     T     |      T     |       F       |         F
     T     |      F     |       T       |         T
     F     |      T     |       T       |         T
     F     |      F     |       T       |         T
Enter fullscreen mode Exit fullscreen mode

As you can see, for every possible combination of values of A and B, both expressions are equivalent!

That's what De Morgan saw. You can do the same analysis for the other law.

These little table things are called Truth Tables, by the way.

(Just when Teddy was about to sourly comment on the futility of explaining this whole process, Leonard surprises him yet again...)

Trust as a building block

Leonard takes out his camera, takes a picture of De Morgan's laws and writes below the picture, "You can trust these, they work, you've seen the demonstration".

"What are you doing?" asks Teddy curiously.

(Leonard's explanation)

I have a method, because of my condition, you know. If every time I need to use these laws I have to do the same demonstration, I wouldn't be able to get anything done.

This way I can trust that things just work and build upon them. I don't need to see the gory details of everything every time.

I call this method...

The Abstraction Boundary

(...Leonard's explanation continues...)

The annotated Polaroid acts as an abstraction interface.

Only things that I trust go in the Polaroids.

Because I trust these things, I can just build upon that knowledge without being bothered by the implementation details.

If every time I use something I first need to stop and think about how that something is implemented, my time would run out before getting anything done.

The implementation details are important in context. Looking in, drilling down, they make sense. Looking up, abstracting away, they don't.

(Leonard stays quiet and after a while he asks...)

Did I ever tell you about...

"Yes, yes, Sammy Jankis, I know" interrupts Teddy.

"No, no, I mean, did I ever tell you about Ireneo Funes?" Leonard continues, "I read about him somewhere"

To think is to forget

(Leonard tells the story of Funes)

It turns out this Funes person could remember everything in excruciating detail. He suffered in some ways from the opposite of my condition.

He was so obsessed with the details that he was almost incapable of creating new thoughts.

Contemplation prevented composition.

"To think is to forget the differences, to generalize, to abstract" or so I read somewhere.

(Leonard trails off his face blank once again)

The request

Teddy seizes this lapse of distraction to slip another Polaroid into Leonard's pocket. The photo shows:

if (A) then (B) = (not A) or (B)
Enter fullscreen mode Exit fullscreen mode

"Ok, so anyway about my expression, I need you to help me reduce this" Teddy says as he hands Leonard a piece of paper.

The paper reads:

(C) and (not D) and (not J)
(not C) and (D) and (not J)
(not C) and (not D) and (J)
if A and ((B or ((C or D) and E))) then F
if A and (not (B or ((C or D) and E))) and (G and ((H and (not I)) or (not H))) then F
if A and (not (B or ((C or D) and E))) and (not (G and ((H and (not I)) or (not H)))) and H then L
if A and (not (B or ((C or D) and E))) and (not (G and ((H and (not I)) or (not H)))) and (not H) then M
if (not A) and J then K
if (not A) and (not J) and (C or D) and ((not E) and (not B)) then K
if (not A) and (not J) and (C or D) and (not ((not E) and (not B))) then F
if (not A) and (not J) and (not (C or D)) then F
Enter fullscreen mode Exit fullscreen mode

Leonard looks at the paper confused but when he looks up Teddy is gone.

Why would you expect anything else?

(Some time later)

"Hey Lenny, it's me, Teddy!"

Leonard looks blankly at the stranger for what seems like minutes. He then pulls a bunch of yellowed Polaroids from his pockets and checks them out. Eventually he finds a photo of this man, the photo reads "Teddy, check your left pocket".

Leonard checks his left pocket and pulls out a crumpled piece of paper, he reads it carefully and then addresses the stranger in front him.

"Hi, Teddy", he says, "you must be here about your expression..."

"Yes, yes!" says Teddy excitedly, "did you manage to reduce it?!?!"

"Oh yes I did", answers Leonard.

"Ok, what is it, Leonard, this is very important, what's the answer?" asks Teddy almost losing his patience.

Leonard looks blank for a second and then answers...

"I can't remember"

Top comments (2)

Collapse
 
r3trosteve profile image
Steve Schofield

How delightfully entertaining and/or informative in almost equal measure.

Collapse
 
santisan profile image
Santiago Figueiras

Excellent and really fun analogies as always! Truth tablets led me back to my first year at university.
BTW the Borges reference went straight into my ❤️