#### Valentine’s Day In New York: Booleans, Sheffer Strokes, Objective C, and Oxford Commas

Hi Everyone (instructor that reads this),

My name is Eoin Whitney and I am currently a student in the iOS class at the Flatiron School in New York City. I’m stoked to be learning about code and the creation of apps. This is the start of my third week of class, and as such I am expected to have a blog done by the end of the week. Apparently the purpose of this blog is to teach us how to write about our coding, and technical topics in general, but as we will soon see, I think the real purpose of this blog is to get us to feel comfortable embarrassing ourselves in front of potentially several readers out there in that series of tubes they call the internet.

For my first blog I am going to talk about some things that I was thinking about in the days preceding Valentine’s Day. As I mentioned, I go to school in NYC and as such it is probably safe to assume that I live in NYC too. According to Google, the population breakdown for NYC by gender is 53% women to 47% men. Being a straight male, and assuming there are at least a couple of straight females out there, you would think that I would easily be able to lock down a date for Valentine’s day. Easier said than done. While there are a myriad of possible reasons why I did not have a date for Valentine’s day, chief among them being that I sprained my tinder finger, today we are going to focus on just two out of the cornucopia of reasons. One is a somewhat legitimate reason while the other is a bold faced lie. I will let you the reader decide which one is which. I am a nerd and I am busy.

For the non programmers out there

there is a datatype called a boolean. A boolean can only be true or false. There are a number of operations that can be used between and amongst booleans to figure out logical conclusions and equivalencies.

= (means it is assigned the value)

== (means it is logically equivalent to)

&& (means and)

! (means it is not the case that)

if (premise) {

Woo=Yes;

}

• (means if the premise is true then the thing inside the { } happens. In this case Woo gets the value of Yes.(

So here is what I was thinking about the day before Valentine’s day.

(BOOL)EoinIsANerd=YES;

Assuming for the sake of argument that I am a nerd…

(BOOL)EoinIsBusy=YES;

Assuming for the sake of argument that I usually have something to do on a given Valentine’s Day…

My boolean equation for whether or not I should get a date on Valentine’s Day looks something like this:

if ((EoinIsANerd==YES)&&(EoinIsBusy==YES)) {

Date=NO;

}

or, more simply, since EoinIsANerd and EoinIsBusy are assumed to have a Boolean value of 1 or YES:

if(EoinIsANerd&&EoinIsBusy) {

Date=NO;

}

If I am a nerd and I am busy, I will not have a date on Valentine’s Day.

So I did not end up having a date on Valentine’s Day, but if by some miracle I had gotten a date, considering that:

if(EoinIsANerd&&EoinIsBusy) {

Date=NO;

}

one might reason:

Since Date=YES and the conditional stated that if EoinIsANerd and EoinIsBusy, then he will not have a date, then it must be true that Eoin is neither a nerd nor was he busy because otherwise there is no way that he could have gotten that date!

Or basically Arguing that:

if (Date=YES) {

EoinIsANerd=NO;

EoinIsBusy=NO;

}

is logically equivalent to:

if(EoinIsANerd&&EoinIsBusy) {

Date=NO;

}

This is actually flawed reasoning. Since the original conditional states that I have to both not be a nerd AND not be busy for me to fail at getting a date. The fact that I somehow, fictionally, finagled a date leaves three distinct possibilities.

1. I was not busy and not nerdy and thus was able to get a date.
2. I was busy, but was not nerdy so was able to get a date (maybe I was busy feeding the homeless and somebody assumed, wrongly, that I was a nice person and asked me out, and did not stick around long enough to listen to me go off on an entirely abstract tangent).
3. I was nerdy, but not busy so was able to get a date ( maybe I was sitting at home playing video games and somebody randomly knocked on my door and asked if I wanted to go on a date).

Obviously of these three possibilities the first is by far the most likely to have succeeded in getting me a date. Yet the other two possibilities are technically additional ways in which I could have gotten a date according to the if statement that we wrote.

Our if statement did not truly capture what we really wanted to say which was that the only possible way for me to ever get a date is for me to not be a nerd and not be busy which we could write like this:

if (!EoinIsANerd&&!EoinIsBusy) {

Date=YES;

}

Hah. Fat chance.

This is the way to capture our intention given the domain of booleans provided to us in objective C. Wouldn’t it be nice if we could capture that same intention without having to use those silly “!” ? Why can’t there be a simple symbol that means if neither this nor this, or in our case, if Eoin is neither a nerd nor is he busy. Enter the Sheffer Stroke.

The Sheffer Stroke was created by a mathematician in 1913 called Henry M. Sheffer (thanks wikipedia), and that is all the background you get.

It is usually written “|” . Much like in objective c we have && to mean and, || to mean or, and ! to mean not, we could easily have |(or some other one character symbol) mean neither nor. For example

if (EoinIsANerd|EoinIsBusy) {

Date=Yes;

}

would mean if Eoin is not a nerd and Eoin is not busy then he will get a date. I think this would add logical clarity to the language and reduce keystrokes (which is especially important for me since I use the two finger poke technique which makes the ! point especially difficult for me).

The Sheffer stroke is the single most badass operation in symbolic logic. You can actually replace every other logical operation with the Sheffer stroke and get the same logical precision.

Lets say that we have a classic conditional: if P then Q.

if it rains then I get wet

The three ways that this is true are:

1. P&Q (it rains & I get wet)
2. !P & !Q (it does not rain & I do not get wet)
3. !P &Q (it does not rain & I do get wet ) remember just because it does not rain does not mean I cannot get wet by some other means i.e. shower

so if P then Q is logically equivalent to ((P&Q)&(!P & !Q))& (!P &Q)

but remember, the Sheffer stroke is all about saying what is not included or not an outcome of a given statement. So perhaps it will be easier to think to make a Sheffer stroke interpretation of the conditional P>Q (if P then Q) by thinking about what specifically make P>Q not true.

4. P & !Q (it rains and I do not get wet)

if my conditional explicitly states that if it rains and I get wet, then if it rains and I do not get wet the conditional must be false. So using this

P>Q must be equivalent to ((P|(Q|Q))

P>Q is equivalent to neither P nor (neither Q nor Q, or for all intents and purposes !Q). If you think about it, saying neither P (it is raining) nor !Q (I do not get wet) is the same every other combination that is not P and !Q.

That’s it for my first blog post. The next one will have a lot more code and a lot less logic. Let me know if you have any advice on either coding, dating, or writing. There’s that oxford comma again, I knew I would get to it!

Like what you read? Give eoin whitney a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.