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, whenever x is composed of hyphens only.

RULE OF PRODUCTION:

Suppose x, y and z all stand for particular strings containing only hyphens.
And suppose that xPyQz is known to be a theorem.
Then xPy-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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.93426335,"math_prob":0.9135604,"size":2176,"snap":"2020-45-2020-50","text_gpt3_token_len":496,"char_repetition_ratio":0.09438305,"word_repetition_ratio":0.0,"special_character_ratio":0.22242647,"punctuation_ratio":0.10280374,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9871865,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-12-04T01:22:09Z\",\"WARC-Record-ID\":\"<urn:uuid:688a1af4-f7f5-4c8b-aabb-8267b5e7c596>\",\"Content-Length\":\"10719\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f7f3a01f-72d8-4b87-bad8-6350f1e42346>\",\"WARC-Concurrent-To\":\"<urn:uuid:80184acd-20b2-4027-a5ed-fa3f141a193b>\",\"WARC-IP-Address\":\"185.199.110.153\",\"WARC-Target-URI\":\"https://www.iainjmitchell.com/blog/isomorphism\",\"WARC-Payload-Digest\":\"sha1:DIOGHPTB7J4GQ22DWMSG7HOXQHCTM2BN\",\"WARC-Block-Digest\":\"sha1:W7JTEB6AD4P3X3OU5EYZ3ORTMGXUSJMD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141733120.84_warc_CC-MAIN-20201204010410-20201204040410-00129.warc.gz\"}"}