Posts Tagged ‘Douglas Hofstadter’

Abstract Thinking

November 16, 2008

As a software engineer, abstracting problems is an important step in creating modular code.  Good abstract concepts are not only useful for a given problem, but they can also be applied in a variety of different situations.  It is especially exciting when 2 seemingly completely different problems can be described by the same abstraction, as this can lead to new insights and perspectives.  In fact, this paragraph itself can be abstracted by applying it to various fields besides software engineering!  I’m sure this analysis of the analysis would make Douglas Hofstadter proud ;) .

The most abstract ideas are those in mathematics.  Alone, the rules of math are not terribly useful (like a software interface without an underlying implementation), but they can be applied in extremely powerful ways to all other fields.  Let’s take the simple, yet incredible, example of numbers.

What is a number?  One explanation is to think of a practical example: pretend you have a basket of tomatoes.  You may want to count how many tomatoes you have and assign some label as the result.  These labels are numbers (or more specifically integers).  Why would you perform such a measurement?  Well in this case it seems very useful to take an inventory for storing, selling, cooking, or whatever you would like to do with your tomatoes. Now let’s say someone else gives you some more tomatoes or takes some away from you.  Numbers appear useful here too.  So we can define “operations” of addition and subtraction to accomplish this.

This concept of numbers and operations is abstract enough that you can clearly apply it to more than just baskets of tomatoes! In fact, you can apply it to “sets” composed of any “element” you can possibly imagine!  That is what a good abstraction is all about.

Let’s get formal about this in mathematical terms using Set Theory.  Given a Set S, there is a function f:S\rightarrow \mathbb{Z} which takes a set and counts how many elements are in it. This measure is called the cardinality of the set.

This function is often expressed by inserting the set in between vertical bars . Here are some examples of sets and their cardinality:

  • The empty set: |{}| = 0
  • A set of one tomato: |({tomato}| = 1
  • A set of letters: |({A, B, C, X, Y, Z}| = 6
  • A set of sets: |{{telephone}, {}, {1, 3}}| = 3

We can also talk about adding sets with another function: g:S\times S\rightarrow S.  This function takes two sets and outputs a third.  You can come up with a bunch of simple functions which do this, but one nice example is a function which concatenates the elements from both input sets and puts them into a single output set.  For example:$latex g({1, 3, 5}, {A}) = {1, 3, 5, A}.  What’s nice about this is that we can use this function to perform addition! since |{1, 3, 5}| = 3, |{A}| = 1, and |{1, 3, 5, A}| = 4.  And what is the additive identity?  It’s the empty set of course!  You can obviously cook up a bunch of other functions which relate to other mathematical operations as well.

This is all just scratching the surface, so we’ll have more cool stuff to go over in future posts.