Obviously the big question is whether it's wise to add these protocols.
But I got curious and did a little research just on the naming question (sorry!), in order to see if "intensional set" and "extensional set" are well-established mathematical terms for different kinds of sets.
It seems like they're probably not.
I checked two reference works -- The Princeton Companion to Mathematics and the Encyclopedic Dictionary of Mathematics (2nd edition). I looked in their tables of contents, their indexes, and in their articles discussing set theory, and there is no mention of the idea of an "intentional set" or an "extensional set". Also, anecdotally, I did some math in grad school and never ran into the terms.
The terms "extensional" and "intensional" originate in philosophy of language and logic, where they describe different kinds of definitions, not of mathematical sets, but of any kind of object. (This Stanford Encyclopedia of Philosophy article on intensional logic was a fun primer.) The idea of an "extensional set" therefor seems to require us to treat how a set was defined, or might have been defined, as a property of the set itself. This has odd consequences. For instance, here is an extensional definition of the set of the counting numbers from 1 to 3 inclusive: X = {1,2,3}. And here is an intensional definition of exactly the same set: X = { x | x in N, x < 4 }. Is the set X extensional, intentional, or both? Does the answer change if I erase one of the sentences above? If I can’t think of one of the definitions?
But the bigger issue, I think, is that the names are misleading. The protocol names IntensionalSet
and ExtensionalSet
describe ways one might define a mathematical set. But the actual protocols themselves specify different operations required by the protocols. The problem is that the sets of operations are only very loosely related to how a set might be defined.
Basically, the functions required for IntensionalSet
represent a plain old mathematical set plus a computational complexity guarantee, and have nothing to do with intensionality per se.
And the functions required for ExtensionalSet
represent a lot of structure beyond a mathematical set: an implicit mapping between indexes and elements, an implicit ordering of the the indexes and therefor of the elements, and insertability. (Even insertability does not guarantee extensionality, because you could still define a type which allowed inserts but was partially defined by a predicate rule, and so was not a completely extensionally-defined set.)
Since “intensional” vs “extensional” do not cleanly map to what the protocols do, I don't think these terms should figure in the protocol names at all. I think the protocol names should be chosen to describe what the protocols do. For the first protocol, I would suggest a name like MathematicalSet
.
For the second protocol, I'd suggest something that alludes to the additional operations which have nothing to do with a mathematical set, something like CollectionSet
.
Of course, all this begs the question of whether they're worth introducing, whatever their names.