On Tue, Mar 13, 2012 at 03:50:49PM +0100, Nicolas Borie wrote something like:
> ...
> About sets that are defined as the subset of all elements of some
> larger set which satisfy a bunch of constraints, like
>
>     Compositions(min_part=3, max_part=2)
>
> and where the constraints may be contradictory as above.
> ...

> It would be good to adopt the same behaviour every times :
>
> (1) - I consider each argument as a mathematical condition thus if two
> arguments make the set empty, it is the problem of the user and I return
> the EmptySet
> (2) - I need to inform the user that he is asking for a absurdity
> because  (3 <= part <= 2) ==> (3 <= 2) is a mathematical absurdity.
> I return a ValueError.

When there are many constraints, simplicity calls for defining what a
valid input is by specifying independently what the admissible values
are for each constraint. E.g.

  - ``min_part`` -- a non negative integer
  - ``max_part`` -- a non negative integer

If the constraints are contradictory, then there is no solution, and
an empty set should be returned (note: we don't have a specific
EmptySet class, but we can use e.g. FiniteEnumeratedSet([])).

Otherwise, it is just impossible for the user (and even more a
program!) to make sure that the input is valid.

Alas, this is usually not yet implemented as such, especially in
IntegerListsLex, but we should gear toward that. I guess it is fine to
throw NotImplementedError's when we don't know how to handle certain
combinations of constraints (but that should as much as possible only
depend on the names of those constraints; e.g. "don't know how to
handle min_part and outer simultaneously").

> Extra question : What should return
> IntegerVectors(inner=[1,1,1], outer=[1,1]) ?
> (1) An error ?
> (2) An infinite set {[1,1,1], [1,1,2], [1,1,3], [1,1,4], ... }

Here a piece of the documentation of Compositions:

    The options inner and outer can be used to set part-by-part
    containment constraints. The list of compositions of 4 bounded
    above by [3,1,2] is given by::

        sage: list(Compositions(4, outer=[3,1,2]))
        [[3, 1], [2, 1, 1], [1, 1, 2]]

    Outer sets max_length to the length of its argument.

This is not specified in IntegerVectors, but I guess it should.
Therefore your example above impose simultaneously max_length = 2 and
min_length=3; so there is no solution, and an empty set should be
returned.

Cheers,
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to