Beta

Is it a group? (Group theory, Abstract algebra)

Description
Loading description...
Mathematics
Algorithms
  • Please sign in or sign up to leave a comment.
  • akar-0 Avatar

    This comment has been hidden.

  • Little Turtle Avatar

    A useful fact: It is sufficient to check if there exist a left neutral element "e" (ie. e * g == g for all g) and each element "g" has a left inverse (ie. there is "h" such that h * g == e). Then, under associativity and using a few tricky comparisons, we can prove that any left inverse is also a right inverse, "e" is (two-sided) neutral element, from which the uniqeness of "e" and all inverses follows.

  • akar-0 Avatar

    I really enjoyed this one. It'd be nice to have similar other ones for different algebraic entities (I've never seen before). Well maybe it would be nice to make them myself if they don't exist....

  • bdupau Avatar

    This comment has been hidden.

  • bdupau Avatar

    It would be nice if you give information about the set and the binary operation used for a test, so that the user can debug more easily.

  • Voile Avatar

    Shouldn't group_set be a set rather than a list? Otherwise there can be duplicate elements.

  • Voile Avatar

    Is it really needed to make a class just to check one thing? A class that serves no purpose but to call a single function using the constructor parameters as its parameters is meaningless. You might as well just turn it into a function is_group(group_set, binary_operation).

    (Marking this an issue since inevitably every other language translation will pick this up and it'll be very messy)

  • Unnamed Avatar

    There's an accidental JS version now...

  • Unnamed Avatar

    Naming conventions described in PEP 8 are strongly preferred in Python. https://www.python.org/dev/peps/pep-0008/#naming-conventions

  • readerboy7 Avatar

    Test cases are incomplete I think. My code passed all tests only with checking for closed and associative. It did not check for identity element or inverse element. I would advise (if possible) to have four sets+funcs that each match three of conditions, but fail on the fourth, forcing all conditions to be checked. (okay, it's not possible for inverse element cond to exist without identity element cond for example I suspect, so my suggestion probably is impossible to implement exactly, but I feel the spirit of suggestion has merit)

  • readerboy7 Avatar

    Sample test cases in python don't match test cases. They ask for str(bool) instead of bool, and testGroup4 is not a group ("y" is not in {"a", "b"}, did you mean "b" )?