sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 480 forks source link

LatticePoset: add function to get lattice of sublattices #20921

Closed f29946bc-ee7b-48cd-9abc-3445948c551d closed 8 years ago

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago

Add a function to get the lattice of sublattices.

(First wait #20669 to get integrated at 7.3beta7.)

CC: @tscrim

Component: combinatorics

Keywords: lattice poset

Author: Jori Mäntysalo

Branch/Commit: fe8b4f6

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/20921

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,3 @@
 Add a function to get the lattice of sublattices.

-(First wait #20669 to get closed.)
+(First wait #20669 to get integrated at 7.3beta7.)
tscrim commented 8 years ago

Changed keywords from latticeposet to lattice poset

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago
comment:3

Isn't "lattice" an ambiguous keyword? It refers to two different things, try to click it and see.

tscrim commented 8 years ago
comment:4

In and of itself, yes, "lattice" is ambiguous. However, "latticeposet" is not a word (in English), but having the "lattice poset" together makes it clear. (More of a random note, there are also 2 other distinct non-mathematical uses of the word lattice that comes to mind as well.)

However, you're free to build here upon #20669 before it gets released in a beta.

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago
comment:5

Replying to @tscrim:

In and of itself, yes, "lattice" is ambiguous. However, "latticeposet" is not a word (in English), but having the "lattice poset" together makes it clear.

But trac does not seem to accept two words keyphrase. Trying to put "foo bar, xyzzy" as keywords does just what "foo, bar, xyzzy" would do. lattice_poset maybe?

However, you're free to build here upon #20669 before it gets released in a beta.

True, but Volker releases betas so often that it makes no big delay.

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago

Branch: u/jmantysalo/latticeposet__add_function_to_get_lattice_of_sublattices

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago
comment:7

Not ready, but I save it here and will continue on another computer after next beta.


New commits:

85ccdc2Added function sublattices_lattice.
f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago

Commit: 85ccdc2

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

29f13a1Add sublattices_lattice().
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Changed commit from 85ccdc2 to 29f13a1

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago
comment:10

Just pinging... Examples are hard, as even very small lattice can generate a big lattice of sublattices.

tscrim commented 8 years ago
comment:11

I would write the input section as:

        - ``element_constructor`` -- string; can be one of the following:

          * ``'lattice'`` - (the default) elements of the lattice will
            be lattices that correspond to sublattices of ``self``
          * ``'tuple'`` - elements are tuples of elements of the
            sublattices of ``self``
          * ``'integer'`` - the elements are plain integers

Also, it looks like you have an unneeded import of DiGraph. Otherwise LGTM.

tscrim commented 8 years ago

Reviewer: Travis Scrimshaw

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

2863437Reviewer comments.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Changed commit from 29f13a1 to 2863437

f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago
comment:13

Corrected those. I used format "original lattice", as self is not very much used in docstring in this file.

Should it be "elements" or "the elements"?

tscrim commented 8 years ago
comment:14

Formally (i.e., if a English professor looked at it), I'm not sure if the "the" is necessary here because it is plural and the structure of the sentence is declarative. Feel free to add it as it is not wrong. Also, I missed this above, it should just be (default), i.e., no "the" there. Thanks.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Changed commit from 2863437 to cf557bb

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

85ccdc2Added function sublattices_lattice.
cf7f1e5Merge branch 'u/jmantysalo/latticeposet__add_function_to_get_lattice_of_sublattices' of git://trac.sagemath.org/sage into t/20921/latticeposet__add_function_to_get_lattice_of_sublattices
cf557bbRemoved a 'the'.
f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago
comment:16

Replying to @tscrim:

Formally (i.e., if a English professor looked at it), I'm not sure if the "the" is necessary here because it is plural and the structure of the sentence is declarative. Feel free to add it as it is not wrong.

If it is not needed, I can left it off. I was just wondering when you wrote "tuple - elements are" vs. "integer - the elements".

Ready now?

tscrim commented 8 years ago
comment:17

Replying to @jm58660:

Replying to @tscrim:

Formally (i.e., if a English professor looked at it), I'm not sure if the "the" is necessary here because it is plural and the structure of the sentence is declarative. Feel free to add it as it is not wrong.

If it is not needed, I can left it off. I was just wondering when you wrote "tuple - elements are" vs. "integer - the elements".

Whoops, my bad.

Ready now?

Yep. Thanks.

vbraun commented 8 years ago
comment:18
sage -t --long src/sage/combinat/posets/lattices.py
**********************************************************************
File "src/sage/combinat/posets/lattices.py", line 1743, in sage.combinat.posets.lattices.FiniteLatticePoset.sublattices_lattice
Failed example:
    sll = L.sublattices_lattice()
Exception raised:
    Traceback (most recent call last):
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 499, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 862, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.combinat.posets.lattices.FiniteLatticePoset.sublattices_lattice[4]>", line 1, in <module>
        sll = L.sublattices_lattice()
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/lattices.py", line 1868, in sublattices_lattice
        G.relabel(lambda x: self.sublattice(x))
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/graphs/generic_graph.py", line 19817, in relabel
        perm = dict( [ i, perm(i) ] for i in self.vertices() )
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/graphs/generic_graph.py", line 19817, in <genexpr>
        perm = dict( [ i, perm(i) ] for i in self.vertices() )
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/lattices.py", line 1868, in <lambda>
        G.relabel(lambda x: self.sublattice(x))
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/lattices.py", line 1680, in sublattice
        return LatticePoset(self.subposet(current_set))
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/posets.py", line 4513, in subposet
        elements = [self(e) for e in elements]
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/posets.py", line 1232, in __call__
        return super(FinitePoset, self).__call__(element)
      File "sage/structure/parent.pyx", line 1107, in sage.structure.parent.Parent.__call__ (/home/buildbot/slave/sage_git/build/src/build/cythonized/sage/structure/parent.c:9904)
        return mor._call_(x)
      File "sage/structure/coerce_maps.pyx", line 110, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (/home/buildbot/slave/sage_git/build/src/build/cythonized/sage/structure/coerce_maps.c:4651)
        raise
      File "sage/structure/coerce_maps.pyx", line 105, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (/home/buildbot/slave/sage_git/build/src/build/cythonized/sage/structure/coerce_maps.c:4539)
        return C._element_constructor(x)
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/posets.py", line 1208, in _element_constructor_
        % type(element))
    ValueError: <type 'int'> is not an element of this poset
**********************************************************************
File "src/sage/combinat/posets/lattices.py", line 1844, in sage.combinat.posets.lattices.FiniteLatticePoset.sublattices_lattice
Failed example:
    sll = L.sublattices_lattice()
Exception raised:
    Traceback (most recent call last):
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 499, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 862, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.combinat.posets.lattices.FiniteLatticePoset.sublattices_lattice[4]>", line 1, in <module>
        sll = L.sublattices_lattice()
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/lattices.py", line 1868, in sublattices_lattice
        G.relabel(lambda x: self.sublattice(x))
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/graphs/generic_graph.py", line 19817, in relabel
        perm = dict( [ i, perm(i) ] for i in self.vertices() )
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/graphs/generic_graph.py", line 19817, in <genexpr>
        perm = dict( [ i, perm(i) ] for i in self.vertices() )
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/lattices.py", line 1868, in <lambda>
        G.relabel(lambda x: self.sublattice(x))
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/lattices.py", line 1680, in sublattice
        return LatticePoset(self.subposet(current_set))
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/posets.py", line 4513, in subposet
        elements = [self(e) for e in elements]
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/posets.py", line 1232, in __call__
        return super(FinitePoset, self).__call__(element)
      File "sage/structure/parent.pyx", line 1107, in sage.structure.parent.Parent.__call__ (/home/buildbot/slave/sage_git/build/src/build/cythonized/sage/structure/parent.c:9904)
        return mor._call_(x)
      File "sage/structure/coerce_maps.pyx", line 110, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (/home/buildbot/slave/sage_git/build/src/build/cythonized/sage/structure/coerce_maps.c:4651)
        raise
      File "sage/structure/coerce_maps.pyx", line 105, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (/home/buildbot/slave/sage_git/build/src/build/cythonized/sage/structure/coerce_maps.c:4539)
        return C._element_constructor(x)
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/combinat/posets/posets.py", line 1208, in _element_constructor_
        % type(element))
    ValueError: <type 'int'> is not an element of this poset
**********************************************************************
File "src/sage/combinat/posets/lattices.py", line 1856, in sage.combinat.posets.lattices.FiniteLatticePoset.sublattices_lattice
Failed example:
    sll.is_isomorphic(Posets.BoolenLattice(3))
Exception raised:
    Traceback (most recent call last):
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 499, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/buildbot/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 862, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.combinat.posets.lattices.FiniteLatticePoset.sublattices_lattice[10]>", line 1, in <module>
        sll.is_isomorphic(Posets.BoolenLattice(Integer(3)))
    AttributeError: type object 'Posets' has no attribute 'BoolenLattice'
**********************************************************************
1 item had failures:
   3 of  24 in sage.combinat.posets.lattices.FiniteLatticePoset.sublattices_lattice
    [310 tests, 3 failures, 0.75 s]
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Changed commit from cf557bb to fe8b4f6

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

fe8b4f6Removed duplicate function.
f29946bc-ee7b-48cd-9abc-3445948c551d commented 8 years ago
comment:20

AARGHS! There was my temporary copy still in the branch. Now it is removed and tests passed.

vbraun commented 8 years ago

Changed branch from u/jmantysalo/latticeposet__add_function_to_get_lattice_of_sublattices to fe8b4f6