checking if a list is empty

rusi rustompmody at gmail.com
Sun May 15 13:33:38 EDT 2011


On May 15, 10:07 am, Steven D'Aprano <steve
+comp.lang.pyt... at pearwood.info> wrote:
>
> I'm afraid I don't understand what you mean. Can you explain please, what
> properties of "first class booleans" do you think are missing from Python?


Dijkstra's writings I alluded to, take a logic/math line to this.  Let
me try to rephrase Dijkstra (who is now sadly not able to defend our
(mis)understandings of his writings) in a more linguistic way:

In English when we say something like "x is y"  the y (predicate) can
be an adjective phrase -- the apple is red -- or a noun phrase -- the
apple is a fruit.

They seem similar; they are very different -- you agree??

>From times immemorial 'true' and 'false' have been used in the
adjective sense: eg Such-and-such statement is true.
Boole's contribution -- actually Dijkstra's recognition of Boole's
contribution -- is that dignifying {true, false} from adjectives to
nouns -- the boolean domain -- fundamentally alter and improve the
rules and possibilities for our thinking. [See his puzzles in the same
paper:
http://www.google.com/url?sa=D&q=http://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EWD1070.html

As an analogy for this consider arithmetic.

Even primitive people can count: My 3 children, my 5 sheep.  They do
this with the ordinals -- first child, second child, third child...
But arithmetic cannot really take off until we allow these numbers
(ordinals) to be dignified into entities in their own right --
cardinals.
ie the mathematician needs to believe in the existence of the numbers
1,2 etc for him to do his job well.

[As an aside I may mention that philosophers of mathematicians will
call this platonism: "In which heaven do these numbers exist?"
And platonism is mysticism. And mysticism is bullshit.  But the vast
majority of practicing mathematicians refuse to be dislodged from
their 'platonic heaven.'  For them mathematics can only be done if it
is done in 'discovery' mode and not in 'invention' mode.]

And so just as good math happens by believing that the numbers exist
and discovering their properties, good logic happens when we believe
that {True, False} exist (in some platonic heaven). Which is to say
they should be nouns in our language.

Well that in summary is the Boole's ideology (Dijkstra's evangelism)
understood linguistically and independent of python/programming.

Reapplied back to the math/programming field, we find that if a value-
domain (data-type) has to be first-class, it at the least has to be a
denotable entity in the language which should be conformable with its
abstract/expected properties.
For example if my language seems to have entities like '2' '3' '+' but
2+3 does not work out equal to 5 we would (I hope!) not say the
language has first-class numbers.

But in order for any of this discussion to be possible, equality
should be well-defined.
Which means that in addition to being an equivalence relation it must
have substitutivity
http://en.wikipedia.org/wiki/Equality_%28mathematics%29#Some_basic_logical_properties_of_equality
which is another form of a very fundamental principle attributed to
Leibniz, the principle of identity of indiscernibles:
http://en.wikipedia.org/wiki/Leibniz%27s_law

Seemingly you and Dijkstra are saying something similar when you say
[1,2,3] is a way of writing true
and he says 2<3 is a way of writing true.
But on further examination (with Leibniz law above) Dijkstra's 2<3 =
True will work consistently in all contexts but [1,2,3] = True will
work sometimes and fail sometimes.

In mathSpeak we say, the definition of bool is not well defined
In CSSpeak we say the definition is not first class.

In the language of algebraic specifications, the slogan is "No
confusion, No junk"
eg http://www.informatik.uni-bremen.de/agbkb/lehre/ws06-07/casl/slides/Datatypes-II.pdf

This is usually applied to specific models in a given language

But it could as well be applied to the models that a language supplies
by default.
And when we apply it to python's bool as a model of the abstract/math
concept bool it has confusion and junk.



More information about the Python-list mailing list