# Hitting two targets: OO + group theory (pedagogy)

Kirby Urner urner at alumni.princeton.edu
Sat Mar 3 18:16:14 CET 2001

```ullrich at math.okstate.edu (David C. Ullrich) wrote:

>Some people would say that the reference to Genesis
>is out of place here... probably you know that some
>people would say that. Might be regarded as just
>generally inappropriate - some other people might
>"Abelian" _does_ refer to a man named Abel, but
>not the one in Genesis.

True, but it's a useful mnemonic connected to a
well-known story.  Making allusions to Biblical
characters need be no more or less churchy than
alluding to Greek mythology or to cartoon characters
like Bugs Bunny (or Coyote in Native American lore)
-- just taking advantage of some shared cultural
heritage.

Anyway, I learned this mnemonic from a very strait-
laced group theory book (which I've since returned
to the library), plus saw it mentioned on another
list frequented by math heads -- sort of assumed
this clever CAIN/Abel thing was cited routinely
by those more familiar with the literature.  Agreed
though: we should make clear who the Abel in Abelian
was.

>of special cases? (Would be a class with a
>__mul__ method that does nothing but raise
>an exception "must implement __mul__ in
>a subclass", an Id attribute, etc. I can't think
>of anything offhand that Group would actually
>_do_, but if we're bent on this OO-math thing
>it seems like groups _should_ be descendants
>of a class Group...)
>

In my example, it's the elements of a group which
get instantiated as separate objects, with each
element inheriting the same meaning for *, whatever
that might be.  The modulus and order of the group
(= totient in this example) are also saved at the
same bytes in memory.  What's unique to each member
is its integer value.

For example:

>>> a = G(3,20)  # modulus 20, 3 is relatively prime
>>> b = G(7,20)  # modulus 20, 7 is relatively prime
>>> a*b          # product
1
>>> pow(a,2)     # a^2
9
>>> G.totient    # order of group (a & b share access)
8
>>> G.n          # modulus of group (ditto)
20
>>> a.val        # unique to a
3
>>> b.val        # unique to b
7

This approach parallels my implementation of a
Vector class and Quaternion class in other curriculum
segments.  Every v "looks within" to find a shared
definition of cross product, dot product or whatever,
such that we write v1.dot(v2).  But for people who
prefer to write dot(v1,v2), we can define a function:

def dot(v1,v2):
return v1.dot(v2)

Some might argue that Vector and Quaternion should
be integrated in some higher level superclass.  Whereas
I do, in fact, subclass Vector into Svector (spherical
coordinates) and Qvector (quadray coordinates), I don't
generalize in the other direction.

to develop OO + math curriculum segments.  It could be
that the abstractions re <G,*> inform the thinking of
students such that they imagine special case groups as
subclasses of the generic group class, without needing
to literally code it this way.  In other words, seeing
a class hierarchy from a given starting point on down,
helps them think upwards to higher levels of abstraction,
even though the computer language by itself doesn't
really go there (that's where we stay with a math
notation -- looking for when it starts to make sense
to implement more concretely as we descend to the
applications level).

Kirby

```