158 CHAPTER 3 Relations
Table 3.1
SpecialDeck of
Cards
SpecialDeck
10 of Clubs
Jack of Clubs
King of Clubs
10 of Hearts
Jack of Hearts
Queen of Hearts
Much of the information about suits and card values is irrelevant to many card games.
Often, only two properties are important: whether two cards are in the same suit, and
whether one card is higher than another. Everything else, such as the names of the suits,
the names of the cards, and perhaps even the number of cards per suit, is unimportant. For
example, a person would immediately be able to translate the rules of many games to a
deck with five suits called red, yellow, blue, green, and black, with each suit consisting of
16 cards numbered 1, 2, 3,..., 16.
How can one abstract these important properties? Notice that both properties involve
a comparison between two objects. For example, given two cards a and b, does a have
a higher value than b? As a matter of convention, two elements that are related in some
special way are often represented by an ordered pair. If a is higher than b, then this could
be represented by the ordered pair (a, b). Formally, the relation HigherValue defined on
SpecialDeck is the set of ordered pairs (a, b) where the value of card a is higher than
the value of card b. This relation for SpecialDeck is shown in Table 3.2. Each ordered pair
(a, b) in the relation contributes one row to the table, with the higher-valued card appearing
first in the row and the lower-valued card second.
Table 3.2 HigherValue Relation
HigherValue
Jack of Hearts 10 of Hearts
Queen of Hearts 10 of Hearts
Jack of Clubs 10 of Hearts
King of Clubs 10 of Hearts
Queen of Hearts Jack of Hearts
King of Clubs Jack of Hearts
King of Clubs Queen of Hearts
Jack of Hearts 10 of Clubs
Queen of Hearts 10 of Clubs
Jack of Clubs 10 of Clubs
King of Clubs 10 of Clubs
Queen of Hearts Jack of Clubs
King of Clubs Jack of Clubs