Example #1
0
def ProjectivePlaneDesign(n, type="Desarguesian", algorithm=None):
    r"""
    Returns a projective plane of order `n`.

    A finite projective plane is a 2-design with `n^2+n+1` lines (or blocks) and
    `n^2+n+1` points. For more information on finite projective planes, see the
    :wikipedia:`Projective_plane#Finite_projective_planes`.

    INPUT:

    - ``n`` -- the finite projective plane's order

    - ``type`` -- When set to ``"Desarguesian"``, the method returns
      Desarguesian projective planes, i.e. a finite projective plane obtained by
      considering the 1- and 2- dimensional spaces of `F_n^3`.

      For the moment, no other value is available for this parameter.

    - ``algorithm`` -- set to ``None`` by default, which results in using Sage's
      own implementation. In order to use GAP's implementation instead (i.e. its
      ``PGPointFlatBlockDesign`` function) set ``algorithm="gap"``. Note that
      GAP's "design" package must be available in this case, and that it can be
      installed with the ``gap_packages`` spkg.

    .. SEEALSO::

        :meth:`ProjectiveGeometryDesign`

    EXAMPLES::

        sage: designs.ProjectivePlaneDesign(2)
        Incidence structure with 7 points and 7 blocks

    Non-existent ones::

        sage: designs.ProjectivePlaneDesign(10)
        Traceback (most recent call last):
        ...
        ValueError: No projective plane design of order 10 exists.
        sage: designs.ProjectivePlaneDesign(14)
        Traceback (most recent call last):
        ...
        ValueError: By the Bruck-Ryser-Chowla theorem, no projective plane of order 14 exists.

    An unknown one::

        sage: designs.ProjectivePlaneDesign(12)
        Traceback (most recent call last):
        ...
        ValueError: If such a projective plane exists, we do not know how to build it.

    TESTS::

        sage: designs.ProjectivePlaneDesign(10, type="AnyThingElse")
        Traceback (most recent call last):
        ...
        ValueError: The value of 'type' must be 'Desarguesian'.
        sage: designs.ProjectivePlaneDesign(2, algorithm="gap") # optional - gap_packages
        Incidence structure with 7 points and 7 blocks
    """
    from sage.rings.arith import two_squares

    if type != "Desarguesian":
        raise ValueError("The value of 'type' must be 'Desarguesian'.")

    try:
        F = FiniteField(n, 'x')
    except ValueError:
        if n == 10:
            raise ValueError("No projective plane design of order 10 exists.")
        try:
            if (n%4) in [1,2]:
                two_squares(n)
        except ValueError:
            raise ValueError("By the Bruck-Ryser-Chowla theorem, no projective"
                             " plane of order "+str(n)+" exists.")

        raise ValueError("If such a projective plane exists, "
                         "we do not know how to build it.")

    return ProjectiveGeometryDesign(2,1,F, algorithm=algorithm)
Example #2
0
def projective_plane(n, check=True, existence=False):
    r"""
    Returns a projective plane of order ``n`` as a 2-design.

    A finite projective plane is a 2-design with `n^2+n+1` lines (or blocks) and
    `n^2+n+1` points. For more information on finite projective planes, see the
    :wikipedia:`Projective_plane#Finite_projective_planes`.

    If no construction is possible, then the function raises a ``EmptySetError``
    whereas if no construction is available the function raises a
    ``NotImplementedError``.

    INPUT:

    - ``n`` -- the finite projective plane's order

    EXAMPLES::

        sage: designs.projective_plane(2)
        Incidence structure with 7 points and 7 blocks
        sage: designs.projective_plane(3)
        Incidence structure with 13 points and 13 blocks
        sage: designs.projective_plane(4)
        Incidence structure with 21 points and 21 blocks
        sage: designs.projective_plane(5)
        Incidence structure with 31 points and 31 blocks
        sage: designs.projective_plane(6)
        Traceback (most recent call last):
        ...
        EmptySetError: By the Ryser-Chowla theorem, no projective plane of order 6 exists.
        sage: designs.projective_plane(10)
        Traceback (most recent call last):
        ...
        EmptySetError: No projective plane of order 10 exists by C. Lam, L. Thiel and S. Swiercz "The nonexistence of finite projective planes of order 10" (1989), Canad. J. Math.
        sage: designs.projective_plane(12)
        Traceback (most recent call last):
        ...
        NotImplementedError: If such a projective plane exists, we do not know how to build it.
        sage: designs.projective_plane(14)
        Traceback (most recent call last):
        ...
        EmptySetError: By the Ryser-Chowla theorem, no projective plane of order 14 exists.

    TESTS::

        sage: designs.projective_plane(2197, existence=True)
        True
        sage: designs.projective_plane(6, existence=True)
        False
        sage: designs.projective_plane(10, existence=True)
        False
        sage: designs.projective_plane(12, existence=True)
        Unknown
    """
    from sage.rings.arith import is_prime_power, two_squares

    if n <= 1:
        if existence:
            return False
        raise EmptySetError("There is no projective plane of order <= 1")

    if n == 10:
        if existence:
            return False
        ref = ("C. Lam, L. Thiel and S. Swiercz \"The nonexistence of finite "
               "projective planes of order 10\" (1989), Canad. J. Math.")
        raise EmptySetError("No projective plane of order 10 exists by %s"%ref)

    if (n%4) in [1,2]:
        try:
            two_squares(n)
        except ValueError:
            if existence:
                return False
            raise EmptySetError("By the Ryser-Chowla theorem, no projective"
                             " plane of order "+str(n)+" exists.")

    if not is_prime_power(n):
        if existence:
            return Unknown
        raise NotImplementedError("If such a projective plane exists, we do "
                                  "not know how to build it.")

    if existence:
        return True
    else:
        return DesarguesianProjectivePlaneDesign(n, check=check)
Example #3
0
def ProjectivePlaneDesign(n, type="Desarguesian"):
    r"""
    Returns a projective plane of order `n`.

    A finite projective plane is a 2-design with `n^2+n+1` lines (or blocks) and
    `n^2+n+1` points. For more information on finite projective planes, see the
    :wikipedia:`Projective_plane#Finite_projective_planes`.

    INPUT:

    - ``n`` -- the finite projective plane's order

    - ``type`` -- When set to ``"Desarguesian"``, the method returns
      Desarguesian projective planes, i.e. a finite projective plane obtained by
      considering the 1- and 2- dimensional spaces of `F_n^3`.

      For the moment, no other value is available for this parameter.

    .. SEEALSO::

        :meth:`ProjectiveGeometryDesign`

    EXAMPLES::

        sage: designs.ProjectivePlaneDesign(2)
        Incidence structure with 7 points and 7 blocks

    Non-existent ones::

        sage: designs.ProjectivePlaneDesign(10)
        Traceback (most recent call last):
        ...
        ValueError: No projective plane design of order 10 exists.
        sage: designs.ProjectivePlaneDesign(14)
        Traceback (most recent call last):
        ...
        ValueError: By the Bruck-Ryser-Chowla theorem, no projective plane of order 14 exists.

    An unknown one::

        sage: designs.ProjectivePlaneDesign(12)
        Traceback (most recent call last):
        ...
        ValueError: If such a projective plane exists, we do not know how to build it.

    TESTS::

        sage: designs.ProjectivePlaneDesign(10, type="AnyThingElse")
        Traceback (most recent call last):
        ...
        ValueError: The value of 'type' must be 'Desarguesian'.
    """
    from sage.rings.arith import two_squares

    if type != "Desarguesian":
        raise ValueError("The value of 'type' must be 'Desarguesian'.")

    try:
        F = FiniteField(n, 'x')
    except ValueError:
        if n == 10:
            raise ValueError("No projective plane design of order 10 exists.")
        try:
            if (n%4) in [1,2]:
                two_squares(n)
        except ValueError:
            raise ValueError("By the Bruck-Ryser-Chowla theorem, no projective"
                             " plane of order "+str(n)+" exists.")

        raise ValueError("If such a projective plane exists, "
                         "we do not know how to build it.")

    return ProjectiveGeometryDesign(2,1,F)
def ProjectivePlaneDesign(n, type="Desarguesian", algorithm=None):
    r"""
    Returns a projective plane of order `n`.

    A finite projective plane is a 2-design with `n^2+n+1` lines (or blocks) and
    `n^2+n+1` points. For more information on finite projective planes, see the
    :wikipedia:`Projective_plane#Finite_projective_planes`.

    INPUT:

    - ``n`` -- the finite projective plane's order

    - ``type`` -- When set to ``"Desarguesian"``, the method returns
      Desarguesian projective planes, i.e. a finite projective plane obtained by
      considering the 1- and 2- dimensional spaces of `F_n^3`.

      For the moment, no other value is available for this parameter.

    - ``algorithm`` -- set to ``None`` by default, which results in using Sage's
      own implementation. In order to use GAP's implementation instead (i.e. its
      ``PGPointFlatBlockDesign`` function) set ``algorithm="gap"``. Note that
      GAP's "design" package must be available in this case, and that it can be
      installed with the ``gap_packages`` spkg.

    .. SEEALSO::

        :meth:`ProjectiveGeometryDesign`

    EXAMPLES::

        sage: designs.ProjectivePlaneDesign(2)
        Incidence structure with 7 points and 7 blocks

    Non-existent ones::

        sage: designs.ProjectivePlaneDesign(10)
        Traceback (most recent call last):
        ...
        ValueError: No projective plane design of order 10 exists.
        sage: designs.ProjectivePlaneDesign(14)
        Traceback (most recent call last):
        ...
        ValueError: By the Bruck-Ryser-Chowla theorem, no projective plane of order 14 exists.

    An unknown one::

        sage: designs.ProjectivePlaneDesign(12)
        Traceback (most recent call last):
        ...
        ValueError: If such a projective plane exists, we do not know how to build it.

    TESTS::

        sage: designs.ProjectivePlaneDesign(10, type="AnyThingElse")
        Traceback (most recent call last):
        ...
        ValueError: The value of 'type' must be 'Desarguesian'.
        sage: designs.ProjectivePlaneDesign(2, algorithm="gap") # optional - gap_packages
        Incidence structure with 7 points and 7 blocks
    """
    from sage.rings.arith import two_squares

    if type != "Desarguesian":
        raise ValueError("The value of 'type' must be 'Desarguesian'.")

    try:
        F = FiniteField(n, 'x')
    except ValueError:
        if n == 10:
            raise ValueError("No projective plane design of order 10 exists.")
        try:
            if (n % 4) in [1, 2]:
                two_squares(n)
        except ValueError:
            raise ValueError("By the Bruck-Ryser-Chowla theorem, no projective"
                             " plane of order " + str(n) + " exists.")

        raise ValueError("If such a projective plane exists, "
                         "we do not know how to build it.")

    return ProjectiveGeometryDesign(2, 1, F, algorithm=algorithm)
def projective_plane(n, check=True, existence=False):
    r"""
    Returns a projective plane of order ``n`` as a 2-design.

    A finite projective plane is a 2-design with `n^2+n+1` lines (or blocks) and
    `n^2+n+1` points. For more information on finite projective planes, see the
    :wikipedia:`Projective_plane#Finite_projective_planes`.

    If no construction is possible, then the function raises a ``EmptySetError``
    whereas if no construction is available the function raises a
    ``NotImplementedError``.

    INPUT:

    - ``n`` -- the finite projective plane's order

    EXAMPLES::

        sage: designs.projective_plane(2)
        Incidence structure with 7 points and 7 blocks
        sage: designs.projective_plane(3)
        Incidence structure with 13 points and 13 blocks
        sage: designs.projective_plane(4)
        Incidence structure with 21 points and 21 blocks
        sage: designs.projective_plane(5)
        Incidence structure with 31 points and 31 blocks
        sage: designs.projective_plane(6)
        Traceback (most recent call last):
        ...
        EmptySetError: By the Ryser-Chowla theorem, no projective plane of order 6 exists.
        sage: designs.projective_plane(10)
        Traceback (most recent call last):
        ...
        EmptySetError: No projective plane of order 10 exists by C. Lam, L. Thiel and S. Swiercz "The nonexistence of finite projective planes of order 10" (1989), Canad. J. Math.
        sage: designs.projective_plane(12)
        Traceback (most recent call last):
        ...
        NotImplementedError: If such a projective plane exists, we do not know how to build it.
        sage: designs.projective_plane(14)
        Traceback (most recent call last):
        ...
        EmptySetError: By the Ryser-Chowla theorem, no projective plane of order 14 exists.

    TESTS::

        sage: designs.projective_plane(2197, existence=True)
        True
        sage: designs.projective_plane(6, existence=True)
        False
        sage: designs.projective_plane(10, existence=True)
        False
        sage: designs.projective_plane(12, existence=True)
        Unknown
    """
    from sage.rings.arith import is_prime_power, two_squares

    if n <= 1:
        if existence:
            return False
        raise EmptySetError("There is no projective plane of order <= 1")

    if n == 10:
        if existence:
            return False
        ref = ("C. Lam, L. Thiel and S. Swiercz \"The nonexistence of finite "
               "projective planes of order 10\" (1989), Canad. J. Math.")
        raise EmptySetError("No projective plane of order 10 exists by %s" %
                            ref)

    if (n % 4) in [1, 2]:
        try:
            two_squares(n)
        except ValueError:
            if existence:
                return False
            raise EmptySetError("By the Ryser-Chowla theorem, no projective"
                                " plane of order " + str(n) + " exists.")

    if not is_prime_power(n):
        if existence:
            return Unknown
        raise NotImplementedError("If such a projective plane exists, we do "
                                  "not know how to build it.")

    if existence:
        return True
    else:
        return DesarguesianProjectivePlaneDesign(n, check=check)