Given a fixed positive integer $n \geq 3$, I want to generate a list of lists in gap with the following properties: each list has $n$ entries $a_0,a_1,\ldots,a_{n-1}$. We have:
- $\min(a_0,a_1,\ldots,a_{n-1})=a_0 \geq2$
- $a_0 \leq n+1$
- $a_{n-1}=a_0+1$ and $a_i -1 \leq a_{i+1}$ for $i=0,\ldots,n-2$. What is the easiest way to do this in gap?
edit: I modified the above conditions a little because its enough to look at a little smaller class of such lists.(in fact $a_0 \leq n+1$ implies that the maximum of all $a_i$ has a good bound)
here is an example for n=6 :
L:=Cartesian([2,3,4,5,6,7],[2,3,4,5,6,7,8,9,10,11,12],
[2,3,4,5,6,7,8,9,10,11,12],[2,3,4,5,6,7,8,9,10,11,12],
[2,3,4,5,6,7,8,9,10,11,12],[3,4,5,6,7,8]);
LL:=Filtered(L, x->Minimum(x)>=2 and
x[6]=x[1]+1 and
Minimum(x)=x[1] and
x[2]-1 <=x[3] and
x[3]-1<=x[4] and
x[4]-1<=x[5] and
x[5]-1<=x[6]);
Using Cartesian, gap in combination with my computer isn't able to do this even for n=8.
By the way the motivation behind this is that those lists parametrise nonselfinjective Nakayama algebras with certain Kupisch series of theoretical interest. here is the number of such lists: https://oeis.org/A007946
it doesn't grow that much, so how can i avoid generating large lists and then have to filter?
If you try to build all sequences and then only select the ones which satisfy your condition you produce a lot of waste and then need to look through all of it. It will be much more effective to build the sequences entry by entry while satisfying your condition. Observe that the $a_0+1=a_{n-1}$ condition gives you the last entry, so one only needs to build of length $n-1$ and then check the condition that $a_{n-2}<=a_0+2$, finally adding the required last entry.
The condition on the last entry, together with the fact that the sequence cannot descend by more than $1$ in each step also means that $a_i\le a_0+n-i$ which substantially reduces on intermediate lists to be thrown away.
Since lists in GAP start indexing at 0 there is a trivial index shift.
The easiest way is clearly having someone else write the code. Thus, since its Christmas, here is a function that does so:
*New version of code based on changed conditions *
It produces some overhead but far less than trying all sequences would do so. It produces counts 8, 35, 139, 539, 2078, 8007, 30887, 119339, 461889 that are consistent (difference 1) with the linked OEIS entry.