|
EXAMPLE
|
a(n) is a pyramidal power of 2; exponents of 2 in a(n) begin:
[0, 0, 1, 4, 10, 20, 35, 56, 84, 120, 165, ..., n(n-1)(n-2)/6, ...].
|
|
PROGRAM
|
(PARI) a(n)=if(n<1, 0, 2^(n*(n-1)*(n-2)/6)) (PARI) /* As determinant of n X n matrix: */ {a(n)=local(q=2, A=Mat(1), B); for(m=1, n, B=matrix(m, m); for(i=1, m, for(j=1, i, if(j==i|j==1, B[i, j]=1, B[i, j]=(A^q)[i-1, j-1]); )); A=B); return(matdet(matrix(n, n, r, c, (A^c)[r, 1])))}
(Prolog program from Paul Tarau (paul.tarau(AT)gmail.com), Jan 25 2008) This generates all 3SAT problem instances
test:-test(4).
test(Max):-
between(1, Max, N),
nl,
one_in_three_monotone_3sat(N, Pss),
write(N:Pss), nl,
fail
; nl.
% generates all one-in-three monotone 3SAT problems involving N variables
one_in_three_monotone_3sat(N, Pss):-
ints(1, N, Is),
findall(Xs, ksubset(3, Is, Xs), Xss),
subset_of(Xss, Pss).
% subset generator
subset_of([], []).
subset_of([X|Xs], Zs):-
subset_of(Xs, Ys),
add_element(X, Ys, Zs).
add_element(_, Ys, Ys).
add_element(X, Ys, [X|Ys]).
% subsets of K elements
ksubset(0, _, []).
ksubset(K, [X|Xs], [X|Rs]):-K> 0, K1 is K-1, ksubset(K1, Xs, Rs).
ksubset(K, [_|Xs], Rs):-K> 0, ksubset(K, Xs, Rs).
% list of integers in [From..To]
ints(From, To, Is):-findall(I, between(From, To, I), Is).
|