Sunday, May 15, 2011

Commutativity and Non-Associativity

This is part three of my three part series on Commutativity and Associativity. In the first part we looked at the definitions of commutativity and associativity. In part two we looked at a system that was associative but not commutative. Now let's look at a system that commutative but not associative.

Rock, Paper, Scissors, Shoot!

This example (found on Wikipedia) is based on the game Rock, Paper, Scissors. (If you don't know how to play look here; if you want to get some practice in, play here.) Recall that Rock beats Scissors, Scissors beats Paper, and Paper beats Rock (for some reason). Let r, p, and s represent rock, paper, and scissors respectively, and let x * y mean "x is played against y." After a match is played, the match is equal to the winner of the match; in a tie, the winner is whatever hand was played. Some examples:

English Language Version Notation  
"rock is played against paper and paper wins" r * p = p
"scissors is played against paper and scissors wins" s * p = s
"paper is played against paper and paper wins" p * p = p

Like before, we can keep all of our information organized by arraigning it as a table:

*    r    p    s   
r r p r
p p p s
s r s s

You can tell by the symmetry of the table that it's commutative (the order in which you evaluate expressions doesn't matter). However, it's non-associative:

(s * p) * r = s * r = r

but

s * (p * r) = s * p = s

It doesn't matter what order you evaluate terms, but it matters very much how you group them.

Conclusion

On this three part adventure (no, I don't think adventure is hyperbole) we've looked at structures that were commutative and associative, commutative and non-associative, non-commutative and associative, and non-commutative and non-associative. The table gives an example from all four categories:

CommutativeNon-Commutative
Associative Addition Triangle Transformations 
Non Associative    Rock, Paper, Scissors  Division

This shows that commutativity and associativity are independent notions. If you have one, that doesn't say anything about whether you have the other.

No comments:

Post a Comment