The Barber Paradox

October 31, 2011

I recently listened to the Radiolab podcast on Loops that has a segment on The Barber’s Paradox:

The barber shaves only those men in town who do not shave themselves.

Who shaves the barber?

Apparently this paradox was a big issue for set theory. The following SQL works quite nicely to describe the statement “all people either shave themselves, are shaved by someone else, or don’t shave at all”:

CREATE TABLE Person(
name VARCHAR(40) NOT NULL PRIMARY KEY,
shavedBy VARCHAR(40) REFERENCES Person(name)
);

INSERT INTO Person(name, shavedBy) VALUES(‘Floyd’, ‘Floyd’);
INSERT INTO Person(name, shavedBy) VALUES(‘Andy’, ‘Floyd’);
INSERT INTO Person(name, shavedBy) VALUES(‘Goober’, ‘Floyd’);
INSERT INTO Person(name, shavedBy) VALUES(‘Gomer’, ‘Gomer’);
INSERT INTO Person(name, shavedBy) VALUES(‘Opie’, NULL);

SELECT DISTINCT shavedBy AS barber FROM Person
WHERE shavedBy IS NOT NULL
AND shavedBy != name;

The result is:

barber
——–
Floyd

The relational model defines Entities and Attributes on those Entities. So is the issue with the Barber’s Paradox that the language does not make a distinction between Entities and Attributes or is the self-referencing part problematic? Creating a Barber TABLE to go with the Person TABLE is the wrong approach but I think it is only wrong if a self-referencing Attribute exists. We could define a patient-doctor relationship with either a doctor Attribute or a Doctor Entity and both approaches would work fine.

The SQL solution to the Barber Paradox nicely handles additional cases like a new barber moves to Mayberry or Aunt Bee shaves some men in her spare time.

Q.E.D.?

Advertisements

2 Responses to “The Barber Paradox”

  1. Kinga Says:

    Thanks for discussing your ideas on this blog. Likewise, a faastny regarding the banking companies intentions while talking about foreclosures is that the traditional bank will not getreceive my payments. There is a fair bit of time the bank can take payments here and there. If you are very deep within the hole, they’re going to commonly desire that you pay that payment fully. However, i am not saying that they will have any sort of repayments at all. If you and the lender can have the ability to work something out, the foreclosure practice may stop. However, when you continue to miss payments wih the new program, the foreclosures process can pick up from where it was left off.

  2. Adit Says:

    Uncovered your content quite raramkeble certainly. I actually enjoyed browsing it so you make fairly some very good factors. I am going to bookmark this site for that long term! Relly good content.


Comments are closed.