Collections, Generics and the Theory of Sets
I am also moving to Generics.
In a way, we're repeating the history of the notion of the modern mathematical set. Bertrand Russell in England, and Gottlob Frege in Germany, wanted to find a "foundation" for mathematics in something outside mathematics, and the only viable candidate was logic (although other theorists found the foundation in the informal physiology, physics and psychology of perception).
To ground the concept of number, Frege and Russell used the "set" (the untyped Collection in our sense with differences I will specify), because intuitively the set of all sets (note the self-application) containing one member "is" the number One, the set of all sets containing two members "is" the number Two.
This sounds vaguely circular but reconstructed formally it is merely recursive: the sets become an abstract group defined by the successor operation, and the concept of number is defined and not used.
It is true that collections can contain duplicates and sets cannot.
But the main idea is that Frege and Russell believed that ANY set, including a set containing sets, existed in reality.
The problem, as is well known, is the set which self-contains based on a rule with a negation: the set of all sets that do not self-contain, the barber during the Cultural Revolution in China who is directed by the village committee to shave all men who don't shave themselves, etc.
Simulating this problem in .Net collections and blowing your computer up is left as an amusing exercise for the reader.
In response, Frank P. Ramsey came up with a rather complicated "type" theory and this roughly corresponds to the need for Generics.
The set containing this table and Charlie Chaplin, the set of all sets which do self-contain, the set of all sets which do not, are curiosities. Generics allow the programmer protection against electronic paradoxes.
Russell's original notion imposed a false unity and as such was part of early twentieth century progressive thought, which imposed large and mixed-type "collections" upon people such as "the world proletariat" which the set members chafed at, preferring to be members of smaller and more strongly typed sets, such as "surfer girl" or something like that.
However, perhaps because I am an old fart, I believe that even untyped Objects have a type and should have a richer set of base properties in my under-development language spinoza, such as a Name.
Yes, a Composite design pattern is "like" the set
The set of all shapes has "least common denominator" functionality: properties include extension in space and method include "make it bigger" and "make it smaller".
In fact, the Austrian philosopher Rudolf Carnap, based on a misunderstanding of the early Wittgenstein, tries to reconstruct as "software objects", without a computer, in prose, such notions as "color" and "shape". He'd probably assent today to the test of the adequacy of his work, as expressed in his book Der Logische Aufbau der Welt (The Logical Structure of the World), to its being a proper "specification" for a machine that would pass the Turing test, by discoursing wittily about such cocktail party constructs as "society" and "art".
20th century analytic philosophy formed as it were a trial run for software building. I saw the same sort of problematics in software as I saw in the Logical Positivist attempt to explain and reduce the world to "atomic sense data", which were phenomena expressible, it would seem, in a small number of bits.
I now believe, however, that the analysis is merely for convenience and that "reality" is probably One, which we divide actively into named entities. Children, for example, as seen in Alice Miller's work on "the drama of the gifted child", are first aware not of sense data but of a manifold of unified sense data AND FEELINGS which are indistinguishable from the sense data, which language orders.
Piaget? Uninteresting. Sure, kids can be just as good at math as grownups but what this shows is the limitations of mathematics as a tool for understanding as opposed to mathematics: as Groucho Marx said, a four year old could do this, get me a four year old.
Hey, Bill Moor, if you are listening, feel free to contribute your insights as a trained psychologist and philosopher.
OK, as to the paradox. Consider sets. They may include sets as members for the same reason Objects may delegate: for the same reason a Collection may have a member which is-a Collection.
[Indeed, Collections can be in general mathematical TREES and hazardously they may be GRAPHS, where a TREE is a GRAPH with no cycles: a Collection should probably never be a graph with cycles and should always be a tree because traversal, without noting where you have been, is hard when there are collections, within collections, which make reference to ancestor collections.]
[However, there is one case where you must assume that the Collection might be a general graph, and this is where you are writing a tool to detect cycles! I've written several versions of a tool which detects in complex software, which resources are used, and such cycles can occur whether in a benign fashion (benign recursion) or a malign fashion (a screwup: A wants B in all paths, but B wants A, indirectly or directly, in all paths, with no condition where B may avoid using A!)]
[What you do here, is you maintain a separate Dictionary keyed on the UID of each collection and do a fast lookup for each new node to see if it has occured as an ancestor.]
Back to sets. They can include sets. They can, it would seem, include themselves. The set A consists of my laptop and the set of all natural numbers: the fact that we can in grammatical English formulate the rule for membership was for Lord Russell a reason to believe that sets exist, and that any set with an explicitly specified "extensional" member list, or explicitly specified "intensional" rule for membership, was a sensible thing to have about the ontological shop.
Oops. Consider the intensional rule "the set of all sets which do NOT NOT NOT have themselves as a member": this is isomorphic to my unfortunate Chinese barber if you replace set by person and membership by shaving.
This set is either a member of itself or it is not, and these are the only two possibilities.
If it IS a member of itself, then it cannot be a member of itself by the rule: but then it MUST be a member of itself.
Boing.
This paradox may be reproducible in software. Consider a data base. It may mention itself in a permanent relation (table). Consider a data base of all non-including data bases. Then, have a stiff drink.
Some goddamn dweeb at the Department of Homeland Security may, as we speak, be using Access to tabulate all databases used by the gumshoes that do not include themselves, wasting my tax dollars.


Sets
This is an intriguing post, Edward, thank you. I always enjoy the philosophical, social, and technical intersections you articulate, and this post is a stellar example. I must admit, though, I got lost on this one:
On another note, this concept from your post reminds me of the Composite design pattern:
Do you agree? In particular, it's this aspect of Composite where I see the connection (quoting the Wikipedia article): "The key concept is that you can manipulate a single instance of the object just as you would a group of them."
Dan