diff --git a/notebooks/Congruence.ipynb b/notebooks/Congruence.ipynb new file mode 100644 index 0000000..ac0d7e9 --- /dev/null +++ b/notebooks/Congruence.ipynb @@ -0,0 +1,144 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Congruences\n", + "\n", + "Let $S$ be a semigroup and $\\rho \\subseteq S \\times S$. We say that is a $\\rho$ is a *left congruence* if $(sx,sy) \\in \\rho$ for all $(x,y) \\in \\rho$ and $s \\in S$. Similarly, we say that $\\rho$ is a right congruence if $(xs,ys) \\in \\rho$ for all $(x,y) \\in \\rho$ and $s \\in S$. If $\\rho$ is both a left and right congruence, then we say $\\rho$ is a congruence. \n", + "\n", + "A question we are interested in is, given a subset $\\rho \\subseteq S \\times S$, what is the \"smallest\" congruence that contains $(x,y)$. By smallest congruence, we mean this to be the intersection of every equivalence relation on $S$ containing $\\rho$. One way to do this is by using the *congruence by pairs* algorithm. \n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Python 3.8.2\r\n" + ] + } + ], + "source": [ + "!python -V" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from IPython.core.interactiveshell import InteractiveShell\n", + "InteractiveShell.ast_node_interactivity = \"all\"" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "from libsemigroups_cppyy import CongruenceByPairs, FroidurePin, Permutation, Transformation" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "S = FroidurePin(Transformation([1,2,3,0]), Transformation([1,0,2,3]))" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hai\n" + ] + }, + { + "ename": "TypeError", + "evalue": "Could not instantiate make,libsemigroups::FroidurePinTraits > >>:\n Failed to instantiate \"make,libsemigroups::FroidurePinTraits > >>(int,libsemigroups::FroidurePin,libsemigroups::FroidurePinTraits > >&)\"", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mC_right\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mCongruenceByPairs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"right\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Desktop/libsemigroups_cppyy/libsemigroups_cppyy/cong_pair.py\u001b[0m in \u001b[0;36mCongruenceByPairs\u001b[0;34m(t, S)\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Expected one of \"right\", \"left\", or \"twosided\"'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0mcp_type\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcppyy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgbl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlibsemigroups\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mCongruenceByPairs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0melement_type\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 32\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mcppyy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgbl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m: Could not instantiate make,libsemigroups::FroidurePinTraits > >>:\n Failed to instantiate \"make,libsemigroups::FroidurePinTraits > >>(int,libsemigroups::FroidurePin,libsemigroups::FroidurePinTraits > >&)\"" + ] + } + ], + "source": [ + "C_right = CongruenceByPairs(\"right\",S)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Python 3.7.4\r\n" + ] + } + ], + "source": [ + "!python -V\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import cppyy\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "WORK", + "language": "python", + "name": "work" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}