## Isomorphism

Recently I’ve been reading a fascinating book by Douglas Hofstadter called Gödel, Escher, Bach. In an early chapter he introduces the concept of *Formal Systems*, which is any system of abstract thought based upon the model of mathematics.

Further into the book a Formal System called the PQ-system is proposed.

DEFINITION:

xP-Qx- is an axiom, wheneverxis composed of hyphens only.

RULE OF PRODUCTION:

Suppose

x,yandzall stand for particular strings containing only hyphens.

And suppose thatxPyQzis known to be a theorem.

ThenxPy-Qz- is a theorem.

The author then asks the reader to discover the decision procedure of the formal system, which is revealed to be that the first two hypen groups should add up, in length, to the third hypen group.

So theorems would include:

```
--P---Q-----
-P--Q---
-P---Q----
```

And would not include:

```
--P--Q-
-P-Q---
```

You may have noticed that effectively this formal system is about adding two numbers together, the - represents a count and the number of these either side of the P add up to the number after the Q. So, the theorem –P—Q—– is equivalent to 2 + 3 = 5.

This leads us to an interesting discovery, does the symbol P actual mean ‘Plus’ and the symbol Q mean ‘eQuals’? This is an example of isomorphism, we are attaching a real world meaning to a symbol in a Formal System.

But are our isomorphic assumptions correct? Does it influence our discovery of the Decision Procedure and thus the entire Formal System?

Programming languages are a form of Formal Systems, so it’s unsurprising that this same problem plays out in the code we write. Take the following example of LINQ (stolen from a Microsoft example).

```
people.Select(p => new { Name = p, p.Length });
```

But what is *p*? A sensible suggestion would be person as the collection is named people, but it could be pupil or even something not beginning with the letter p.

The lack of clarity could cause confusion to future readers of this code, it may even lead them to wrong assumptions. This is why naming is often the most important refactoring we can do to a code base, especially the removal of abbreviations that can lead to different interpretations or isomorphisms.