Review of I Am A Strange Loop by Douglas Hofstadter – Part 2

Part 1

The toilet flush is one of the simplest and common feedback mechanisms that we find. There is a float which rises with the water level which controls the inflow of water. After a certain height is reached the water inflow is stopped. Do we attribute intentionality to the water flush? We usually do not. And this is the theme that Hofstadter explores in Chapter 4 Loops, Goals and Loopholes.

But what kinds of systems have feedback, have goals, have desires? Does a soccer ball rolling down a grassy hill “want” to get to the bottom? 52

We anthropomorphize objects and impart them our human attributes. Adding a “purpose” or a “goals” to any system is considering it from a teleological perspective. Teleology is the explanation of phenomena by the purpose they serve rather than by postulated causes. Considering examples of variations on this theme, we can say that answer to the above question is not clear cut. There are no black-and-white answers but are judgment calls. We tend to move towards the idea of teleology and intention for a system when the feedback mechanisms are not directly perceptible.

Among other examples, Hofstadter considers plants which in normal time will appear to be static and without any “goals”. But a time-lapse of the same would show that they have “goals” and “intentions” and use strategies to achieve them.

The question is whether such systems, despite their lack of brains, are nonetheless imbued with goals and desires. Do they have hopes and aspirations? Do they have dreads and dreams? Beliefs and griefs? 53

The claim is made that presence of a feedback loop in a system, triggers in us a response which shifts the description from a goalless level of mechanics to a goal-oriented level of some cognitive mechanism. Things have the desire to move!

So far we have considered basic feedback loops. Now we move onto a more complex idea of a positive feedback loop. In a positive feedback loop, a part of the output of the system goes into increasing the output by a certain factor. With each iteration the output increases, which causes the next output to increase even more. A small change in input can cascade into a very large change (exponential) in output.

Perhaps the most common example of a positive feedback loop is the unpleasant, high pitch sound one hears in an auditorium or a meeting. This happens when a microphone gains some of its output as an input and produces an ever increasing pitch and volume of the input sound. An example is given below:

Now one can imagine that due to the exponential nature of growth, any little disturbance in such a system might lead to a sound which will eventually destroy everything.

In theory, then, the softest whisper would soon grow to a roar, which would continue growing without limit, first rendering everyone in the auditorium deaf, shortly thereafter violently shaking the building’s rafters till it collapsed upon the now-deaf audience, and then, only a few loops later, vibrating the planet apart and finishing up by annihilating the entire universe. What is specious about this apocalyptic scenario?

But this is a fallacious argument. The first fallacy is the physical nature of the setup and the amplifier in our scheme of things. If the roof falls, it will destroy the amplifier too! The second case is the nature of the amplifier, it doesn’t amplify in an unlimited way. After a certain gain, due to the physical design, the amplification becomes equal to unity and the system stabilizes at its natural frequency. It so happens that the natural high frequency of an audio amplifier is close to a high pitch scream. This is achieved by the system tends to go towards that pitch in series of rapid iterations. These are the screeching high pitch oscillations that we hear. It seems the systems “wanted” to go there, the stable point of its existence. Thus we see that

Similarly, we can also “see” visual feedback loops, when the output of a camera is given back to the camera. This can be most easily setup by pointing the camera towards a screen which is showing a live output of the camera. The cover image of the book is one such image, captured during Hofstadter’s “experiments” with the visual feedback system. One of the difference, in this case, is that the camera is not an amplifying device, it just transmits. Yet the pictures it produces are bizarre and beautiful. Seeing images of video feedback gives one a sense of mystery and wonder. There is some inherent beauty in it, yet it seems un-natural to watch.

Feedback — making a system turn back or twist back on itself, thus forming some kind of mystically taboo loop — seems to be dangerous, seems to be tempting fate, perhaps even to be intrinsically wrong, whatever that might mean. 57

Shifting gears, we get a Hofstadter’s introduction to Gödel when he was fourteen. What intrigued him was the thought that one could have an entire book about a single book. The book was Nagel and Newman’s Gödel’s Proof, published in 1958. Hofstadter wrote the introduction to the new imprint in 2001. He was fascinated by footnote on formal use of quotation marks.

So here was a book talking about how language can talk about itself talking about itself (etc.), and about how reasoning can reason about itself (etc.). I was hooked! I still didn’t have a clue what Gödel’s theorem was, but I knew I had to read this book. 58

This is something that happens to me too. Some time back (almost a decade now) I had posted about books attracting me. Perhaps it happens to many people.

We next look at famous Russel’s Paradox. One of the examples derived from it is Barber’s Paradox

The barber is the “one who shaves all those, and those only, who do not shave themselves.” The question is, does the barber shave himself? [.]

There is also a loop here and there is contradiction too.

This loophole (the word fits perfectly here) was based on the notion of “the set of all sets that don’t contain themselves”, a notion that was legitimate in set theory, but that turned out to be deeply self-contradictory. 60

Russell tried to overcome this by formally re-defining the concepts of sets to save this, but it didn’t work out well. Rather it became too complex, though built on solid, atomic (in the mathematical sense) ideas.

In Principia Mathematica, there was to be no twisting-back of sets on themselves, no turning-back of language upon itself.  61

But why is self-reference considered problematic? Here Hofstadter quotes from his column Metamagical Themas (an anagram of Martin Gardner’s Mathematical Games) in Scientific American on Self-Referential sentences. But all were not receptive to the idea, some of the readers were sceptical about the utility of self-reference and denied any meaningful output of such activities.

In the next chapter On Video Feedback we explore the theme of video of video feedback and Hofstadter’s experiments with it. He explores and explains many of the images which were made by adding slight things in the image, fox example, truncated corridor, endless corridor, helical corridor etc. The common element in all these video feedback is the repeating of the primary image in scaled down fashion till the resolution of the screen can support (theoretically infinite). During one the experiments, he covers the lens and then removes his hands. During this, the movement of his hand is captured and forms an endless image which is moving, even when the hand is removed. This action has formed a loop and is feeding itself in a cyclic setup.

A faithful image of something changing will itself necessarily keep changing! 67

A similar phenomenon is that of dogs barking in sync. Some dog somewhere, starts to bark for something that is passing near it. Now, other dogs pick up and start barking too. And the chain goes on. Once setup, it doesn’t matter what was the reason for the first dog to bar, it may have gone away. But the chain of barking sustains itself. During one the flights, I have seen this happen with small babies. There were about 5-6 babies on the flight. It so happened that one of them started to cry for some reason. Then the rest joined in one-by-one. Perhaps the others were crying because the heard another one cry. And the event became self-sustaining. This went on for quite some time.

This is one of the core idea of an emergent phenomenon, once

In general, an emergent phenomenons omehow emerges quite naturally and automatically from rigid rules operating at a lower, more basic level, but exactly how that emergence happens is not at all clear to the observer. 68

The video explorations led to some fantastic images, many of which are reproduced in color in the central pages of the book. In the last part of the chapter, Hofstadter drives towards one of the central themes which we will explore in the remaining book. The idea is that strange and robust (self-sustaining) structures can emerge from the process of looping.

Once a pattern is onthe screen, then all that is needed to justify its staying up there is George Mallory’s classic quip about why he felt compelled to scale Mount Everest: “Because it’s there!” When loops are involved, circular justifications are the name of the game. 70

Some of the images I myself have collected are shown below:

The locking-in gives rise to abstract phenomena at higher levels.

In short, there are surprising new structures that looping gives rise to that constitute a new level of reality that could in principle be deduced from the basic loop and its detailed properties, but that in practice have a different kind of “life of their own” and that demand — at least when it comes to extremely finite, simplicity-seeking, new level of description that transcend the basic level out of which they emerge. 71

Whether we will be able to actually do it, or want to do it is another question. This reminds me of the saying: In theory, there is no different in theory and practice, in practice there is.

Here are a few more:

 

Batch Converting jp2 to jpg

I do not know why but jp2 files are very very heavy on GNU/Linux systems. Opening a folder full of them might very likely stall your file browser or system. Even a small file below 1 M, might take its own sweet time to open in GIMP.Here is a small command to convert a bunch of em into jpg, thought resulting file is usually 1o times larger.

Use this for lossless conversion

mogrify -format jpg -quality 100 *.jp2

Source

Time Lapse Film Using Scanner

In this post we will see how to make  a time-lapse animation of something which changes over time, with a scanner. Most probably you have seen some amazing time -lapse photography of different objects. Common examples include the ever changing skyscape, blooming flowers, metamorphosing insects etc. I wanted to do a similar stuff, but due to my lethargy and other reasons I did not. Though the cameras have intervelometer, and I have used it once to take photos of a lunar eclipse, (moon changing position which I was supposed to merge later, but never did), and wanted to do the same with a blooming of a flower. But as Ghalib has said, they were one of those हज़ारों ख्वाहिशें…

The roots of the idea what follows are germinated long back, when I had a scanner. It was a basic HP 3200 scanner. That time I did not have a digital camera, (c. 2002-2003), but then I used the scanner as a camera. I had this project lined up for making collages of different cereals. Though I got a few good images from botanical samples (a dried fern below) as well and also fractals from a sheet of rusting iron. Then, I sort of forget about it.

white-fern-00

Coming to now, I saw some amazing works of art done by scanning flowers. I remembered what had been done a few years back and combined this with the amazing time-lapse sequences that I had seen , the germ began can we combine the two?

http://vimeo.com/22439234

Can we make the scanner, make scans at regular intervals, and make a animation from the resulting images. Scanning images with a scanner would solve problem of uniform lighting, for which you may require an artificial light setup. So began the task to make this possible. One obvious and most easy way to do this is to scan the images manually, lets say every 15 minutes. In this case you setup the scanner, and just press the scan button. Though this is possible, but its not how the computers should be used. In this case we are working for the computer, let us think of making the computer do work for us. In comes shell scripting to our rescue. The support for scanners in GNU/Linux is due to the SANE (Scanner Access Now Easy) Project. the GUI for the SANE is the xsane, which we have talked about in a previous post on scanning books and scanimage is the terminal option for the sane project.

The rough idea for the project is this :

1. Use scanimage to acquire images

2. Use some script to make this done at regular time intervals.

3. Once the images are with use, combine them to make a time-lapse movie

For the script part, crontab is what is mostly used for scheduling tasks, which you want to be repeated at regular intervals. So the project then became of combining crontab and scanimage. Scanimage has a mode called --batch in which you can specify the number of images that you want to scan and also provides you with renaming options. Some people have already made bash scripts for ADF (Automatic Document Feeders), you can see the example here. But there seems to be no option for delay between the scans, which is precisely what we wanted. To approach it in another way is to introduce the the scanimage command in a shell script, which would be in a loop for the required number of images and you use the sleep command for the desired time intervals, this approach does not need the crontab for its operation. But with I decided to proceed with the crontab approach.

The first thing that was needed was to get a hang of the scanimage options. So if your scanner is already supported by SANE, then you are good to go.

$scanimage -L

This will list out the devices available for scanning. In my case the scanner is Canon Lide 110, which took some efforts to get detected. For knowing how to install this scanner, if it is not automatically supported on your GNU/Linux system, please see here.

In my case it lists out something like this:

device `genesys:libusb:002:007' is a Canon LiDE 110 flatbed scanner

If there are more than one devices attached to the system the -L option will show you that. Now coming to the scan, in the scanimage programme, we have many options which control various parameters of the scanned picture. For example we can set the size, dpi, colour mode, output type, contrast etc. For a complete set of options you can go here or just type man scanimage at the terminal. We will be using very limited options for this project, namely the x, y size, mode, format, and the resolution in dpi.

Lets see what the following command does:

$scanimage -d genesys:libusb:002:006 -x 216 -y 300 --resolution 600dpi --mode Color --format=tiff>output.tiff

-d option specifies the device to be used, if there is nothing specified, scanimage takes the first device in the list which you get with -L option.

-x 216 and -y 300 options specify the size of the final image. If for example you give 500 for both x and y, scanimage will tell us that maximum x and y are these and will use those values. Adjusting these two values you will be able to ‘select’ the area to be scanned. In the above example the entire scan area is used.

--resolution option is straight forward , it sets the resolution of the image, here we have set it to 600dpi.

--mode option specifies the colour space of the output, it can be Color, Gray or Lineart

--format option chooses the output of the format, here we have chosen tiff, by default it is .pnm .

The > character tells scanimage that the scan should be output to a file called “output.tiff”, by default this will in the directory from where the command is run. For example if your command is run from the /home/user/ directory, the output.tiff will be placed there.

With these commands we are almost done with the scanimage part of the project. With this much code, we can manually scan the images every 15 minutes. But in this case it will rewrite the existing image. So what we need to do is to make sure that the filename for each scan is different. In the --batch mode scanimage takes care of this by itself, but since we are not using the batch mode we need to do something about it.

What we basically need is a counter, which should be appended to the final line of the above code.

For example let us have a variable n, we start with n=1, and each time a scan happens this variable should increment by 1. And in the output, we use this variable in the file name.

For example, filename = out$n.tiff:

n =1 | filename = out1.tiff

n = n + 1

n = 2 | filename = out2.tiff

n = n + 1

n = 3 and so on…

We can have this variable within the script only, but since we are planning to use crontab, each time the script gets called, the variable will be initialized, and it will not do the function we intend it to do. For this we need to store variable outside the script, from where it will be called and will be written into. Some googling and landed on this site, which was very helpful to attain what I wanted to. Author says that he hasn’t found any use for the script, but I have 🙂 As explained in the site above this script is basically a counter, which creates a file nvalue. starting from n=0, values are written in this file, and each time the script is executed, this file with n=n+1 is updated.

So what I did is appended the above scanimage code to the ncounter script and the result looks something like this:

#!/bin/bash
nfilename="./nvalue"
n=0
touch $nfilename
. $nfilename
n=$(expr $n + 1)
echo "n=$n" > $nfilename
scanimage -x 80 -y 60 --resolution 600dpi --mode Color --format=tiff>out"$n".tiff

What this will attain is that every time this script is run, it will create a separate output file, depending on the value of n. We put these lines of code  in a file and call it time-lapse.sh

Now to run this file we need to make it executable, for this use:

$chmod +x time-lapse.sh

and to run the script:

$./time-lapse.sh

If  everything is right, you will get a file named out1.tiff as output, running the script again you will have out2.tiff as the output. Thus we have attained what we had wanted. Now everytime the script runs we get a new file, which was desired. With this the scanimage part is done, and now we come to the part where we are scheduling the scans. For this we use the crontab, which is a powerful tool for scheduling jobs. Some good and basic tutorials for crontab can be found here and here.

To edit your crontab use:

$crontab -e

If you are using crontab for the first time, it will ask for editor of choice which has nano, vi and emacs. For me emacs is the editor of choice.

So to run scans every 15 minutes my crontab looks like this:

# m h  dom mon dow   command
*/15 * * * * /home/yourusername/time-lapse.sh

And I had tough time when nothing was happenning with crontab. Though the script was running correctly in the terminal. So finally the tip of adding in the cronfile

SHELL=/bin/bash

solved the problem. But it took me some effort to land up on exact cause of the problem and in many places there were sermons on setting PATH and other things in the script but, I did not understand what they meant.

Okay, so far so good. Once you put this script in the crontab and keep the scanner connected, it will produce scans every 15 minutes. If you are scanning in colour at high resolution, make sure you have enough free disk space.

Once the scans have run for the time that you want them , lets say 3 days. You will have a bunch of files which are the time lapse images.  For this we use the ffmpeg and ImageMagick to help us out.

Using Inkscape in Batch Mode

Recently I had to make and print a lot of certificates, each with different names and affiliations. There are programs in the Office environment which do this. They are called as Mail Merge, primarily being used for sending mass mails to many individuals.

Basically following happens:

You have a database of Names / Addresses and Affiliations with you. Lets say there are 500 names in this database. If you want to make certificates for everyone of them, it is not very bright to manually add every name to the certificates. What the program does is takes this list of names, and inserts it into a template and generates a file for each entry in the database. Which is to be printed.

I had designed a certificate for one of the programs using a Free Software   SVG Editor Inkscape, initially the number of entries was not large, but then they became too much for me to manage manually.

So then there is small plugin called the Inkscape Generator that came to help  me big time.

This is something that I had been exactly looking for.

As explained on the page for the plugin the database has to be in a csv format, which can be conveniently generated and edited in any of the spreadsheet programs like Calc for Libre Office. With this it becomes super-easy to generate pdf’s for each of the entries in the database.

Once all the pdf’s have been generated using pdftk one can simple join all the files in a single pdf file and print at one go.

To join:

pdftk *.pdf cat output combined.pdf

As simple as this.