1 | initial version |
The issue is that is_distributive
is not defined for all posets, just for lattices -- that is, on the Sage data type of Lattice, not Poset. So one option would be to find all lattices and then filter those:
sage: n = 6
sage: posets = [p for p in Posets(n) if p.is_connected() and p.is_lattice()]
sage: lattices = [p for p in posets if LatticePoset(p).is_distributive()]
Here LatticePoset(p)
converts the poset p
explicitly into a lattice. You could instead use this at the end
sage: lattices = [LatticePoset(p) for p in posets if LatticePoset(p).is_distributive()]
so that the elements of lattices
are lattices, not just posets. Or do the conversion first:
sage: n = 6
sage: lattices = [LatticePoset(p) for p in Posets(n) if p.is_connected() and p.is_lattice()]
sage: distributive_lattices = [p for p in lattices if p.is_distributive()]