Opened 11 years ago

Bug in initialisation of species

Reported by: Owned by: hivert sage-combinat major combinatorics Species, LazyPowerSeries sage-combinat, mantepse N/A

Description

The following specification is valid:

```sage: Set0  = species.SetSpecies()
sage: Set1  = species.SetSpecies(min=1)
sage: Set2  = species.SetSpecies(min=2)
sage: Four = species.CombinatorialSpecies()
sage: Four.define(Set2(Four) + Set1*Set0(Four))
```

However, the following code breaks

```sage: Four.generating_series()[1]
[...]
```

Strangely enough, adding some seemingly unrelated instruction work around it::

```sage: Set0  = species.SetSpecies()
sage: Set1  = species.SetSpecies(min=1)
sage: Set2  = species.SetSpecies(min=2)

sage: Set2(Set1).generating_series()[1]
0

sage: Four = species.CombinatorialSpecies()
sage: Four.define(Set2(Four) + Set1*Set0(Four))
sage: Four.generating_series()[1]
1
sage: Four.generating_series()[4]
52/3
sage: Four.generating_series()
x + 2*x^2 + 16/3*x^3 + 52/3*x^4 + O(x^5)
```

Florent

comment:1 Changed 10 years ago by hivert

Here is a smaller code which triggers the problem:

```Z     = species.SingletonSpecies()
Set2  = species.SetSpecies(min=2)
NMult   = species.CombinatorialSpecies()
NMult.define(Set2(Z+NMult))
NMult.generating_series()[0]
```

comment:2 Changed 9 years ago by jdemeyer

Milestone: sage-5.11 → sage-5.12

Fixed in #15673.

comment:4 Changed 9 years ago by vbraun_spam

Milestone: sage-6.1 → sage-6.2

comment:5 Changed 9 years ago by vbraun_spam

Milestone: sage-6.2 → sage-6.3

comment:6 Changed 8 years ago by vbraun_spam

Milestone: sage-6.3 → sage-6.4

comment:7 Changed 4 months ago by chapoton

will this be fixed by the recent refactoring ?

maybe check also other tickets with "species" keyword ?

comment:8 Changed 4 months ago by mantepse

Yes, this already works. However, you have to be explicit about the valuation of `Four` now, because it cannot determine that it doesn't have valuation 0.

(I admit I don't see right now whether it should be able to determine that the valuation is not 0 - do you?)

```sage: Set0  = species.SetSpecies()
sage: Set1  = species.SetSpecies(min=1)
sage: Set2  = species.SetSpecies(min=2)
sage: Four = species.CombinatorialSpecies(min=1)
sage: Four.define(Set2(Four) + Set1*Set0(Four))

sage: Four.generating_series()
z + 2*z^2 + 16/3*z^3 + 52/3*z^4 + 944/15*z^5 + 11008/45*z^6 + 313664/315*z^7 + O(z^8)

sage: Four.isotype_generating_series()
z + 3*z^2 + 10*z^3 + 40*z^4 + 170*z^5 + 785*z^6 + 3770*z^7 + O(z^8)
sage: Four.cycle_index_series()
p[1] + (2*p[1,1]+p[2]) + (16/3*p[1,1,1]+4*p[2,1]+2/3*p[3]) + (52/3*p[1,1,1,1]+16*p[2,1,1]+3*p[2,2]+8/3*p[3,1]+p[4]) + (944/15*p[1,1,1,1,1]+208/3*p[2,1,1,1]+20*p[2,2,1]+32/3*p[3,1,1]+8/3*p[3,2]+4*p[4,1]+2/5*p[5]) + (11008/45*p[1,1,1,1,1,1]+944/3*p[2,1,1,1,1]+120*p[2,2,1,1]+12*p[2,2,2]+416/9*p[3,1,1,1]+64/3*p[3,2,1]+14/9*p[3,3]+16*p[4,1,1]+6*p[4,2]+8/5*p[5,1]+p[6]) + (313664/315*p[1,1,1,1,1,1,1]+22016/15*p[2,1,1,1,1,1]+2096/3*p[2,2,1,1,1]+112*p[2,2,2,1]+1888/9*p[3,1,1,1,1]+416/3*p[3,2,1,1]+40/3*p[3,2,2]+88/9*p[3,3,1]+208/3*p[4,1,1,1]+40*p[4,2,1]+8/3*p[4,3]+32/5*p[5,1,1]+8/5*p[5,2]+4*p[6,1]+2/7*p[7]) + O^8
```

comment:9 Changed 4 months ago by mantepse

Yes, I am eager to close all the other tickets. However, I want #34552 to be in the develop branch first.

comment:10 Changed 4 months ago by mantepse

Hm, I think it should know that the valuation is greater than 0. The valuation of `Set1 * Set0(Four)` is greater than zero, because the valuation of `Set1` is.

`Set2` is not a polynomial (because it is not 'exact'), so `Set2.__call__` is only defined if its argument has valuation at least 1. Thus we might as well assume that its valuation is at least 1.

I'm not sure yet.

comment:12 Changed 4 months ago by mantepse

We actually thought about this situation (I forgot), and introduced a `check` parameter for `__call__`. Of course, it is not passed by the species code.

I am still not sure what the best solution might be.

comment:13 Changed 3 months ago by mantepse

Milestone: sage-6.4 → sage-9.8 new → needs_info

comment:14 Changed 4 days ago by mkoeppe

Milestone: sage-9.8
Note: See TracTickets for help on using tickets.