ELI5: Is AI just a bunch of if and else statements?

In popular culture, artificial intelligence is often depicted as an omniscient supreme power.

And in our day to day lives, even ordinary AIs like Siri and Alexa display human-like intelligence.

But is that impressive digital brainpower really just a bunch of if and else statements?

Well, the answer is both ‘yes’ and ‘no’.

Nuts and bolts

When we get down to the nuts and bolts of computers, everything is built on if and else statements. All logical processing uses if/else as a foundation.

If 1 and 1, then 2. If X happens, do a thing. Else, do another thing.

These kind of basic operations are the necessary building blocks for computers. They are then combined in innumerable ways to create increasingly sophisticated blocks capable of increasingly complex actions.

So, it’s certainly true that if and else statements are a core computing component. And that includes artificial intelligence systems, too.

 A simple AI example

What, then, is happening behind the scenes when you ask Siri a question? Let’s use asking for the time as an example.

An if/else flow for a time-related question would look something like:

IF user says something with “time” in it
1. Lookup local time
2. Speak “It is [%time%]"

The AI is essentially detecting keywords. Then, using a pre-set workflow, it performs the appropriate response to that keyword (or series of keywords).

So, AI systems are rather less than omniscient overlords. Often, the AI is indeed trotting off answers using pre-programmed if and else statements.

Where things get tricky

Of course, it’s not all quite so simple. Artificial intelligence learns from the input it’s provided via something called neural networks.

What this means is that AIs can mirror the human brain in terms of the ability to adapt and grow knowledge. So, as they learn more, they can also produce responses on the fly – responses that were not pre-programmed.

If we’re being reductive, we can still break the AI decision-making process down into if and else statements. But a human didn’t write those statements – the AI deduced them by learning from data.

If and else statements

So, is AI just a bunch of if and else statements? In broad strokes, then yes.

But the answer is reductive, and doesn’t necessarily offer the most useful insights.

Think of it this way: AI is a bunch of if and else statements in the same way that a human brain is a bunch of atoms. The declaration is true, but there’s a whole lot more to be said.

Further reading