algorithms

Algorithms in English

If the rightmost point of one interval is to the right of the leftmost point of the other interval, and if the leftmost point of the first interval is to the left of the rightmost point of the other interval, then and only then do those two intervals overlap.

There are some assumptions, however. There are always some assumptions, even when dealing with the most rigorous of mathematics. It’s time to finally admit this fact of life.

The assumptions here are that intervals are collinear and closed, so that the rightmost and the leftmost points exist. And that “to overlap” means to have more than one common point. Which are all very reasonable.

We can name one interval “alice” and the other one “bob”. Then we can write it as follows:

If the rightmost point of alice is to the right of the leftmost point of bob, and if the leftmost point of alice is to the left of the rightmost point of bob, then and only then do alice and bob overlap.

If we call  the leftmost point “tail” and the rightmost point “head” as they are lying there in such an orientation and if we then substitute “to the left” with “smaller” and “to the right” with “greater”  we obtain:

If alice’s head is greater than bob’s tail, and if alice’s tail is smaller than bob’s head, then and only then do alice and bob overlap.

or even better:

If alice’s head is greater than bob’s tail, and bob’s head is greater than alice’s tail, then and only then do alice and bob overlap.

or:

If the head of both is greater than the tail of the other one, then and only then do alice and bob overlap.

or even:

If every head is greater than every tail, then and only then do alice and bob overlap.

or:

If there is no head bellow any tail, then and only then do alice and bob overlap. (1)

with the:

If there is no interval’s supremum smaller of any interval’s infimum there, then and only then two intervals do overlap. 

the assumption of the closed intervals is no more needed. Any combination of closed, semi-closed or open intervals now works. Our assumption moved to the infimum/supremum concept. Fortunately, quite a fundamental one in mathematics.

Usually we say:

If A2>B1 && B2>A1 overlaping=true Else overlaping=false   (2)

The assumption of what A1 and A2 and B1 and B2 are, as well as every other assumption, must be first handled somehow. Otherwise some defaults may be understood by the compiler and only if we are lucky, will everything work well after compiling.

The formula (2) is a free gift to your machine compiler, when the formula (1) is the most understandable for us. Isn’t it? You and your machine compiler are meeting at the midpoint between the natural language expression from the beginning and the binary code it will eventually produce. You are just to soft with your machine. Therefore too harsh to yourself.

You are born to think in some human language, where you can really understand things. Don’t worry about computers, they are perfectly capable of understanding English (or Slovenian). At least in principle.

The English language is a perfect engine. It can run all the logics, mathematics, physics and all the programming languages, including assembly. All. You can enrich the English language with formulae and pictures, but you don’t need to. Every single picture is perfectly describable in English.

Just imagine a superintelligent machine running on Latin! Holly apparatus! Machina Sancta.

Advertisements
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s