OFFSET
0,9
LINKS
K. Grygiel and P. Lescanne, Counting terms in the binary lambda calculus, arXiv preprint arXiv:1401.0379 [cs.LO], 2014.
Katarzyna Grygiel and Pierre Lescanne, Counting and Generating Terms in the Binary Lambda Calculus (Extended version), HAL Id: ensl-01229794, 2015.
John Tromp, Binary Lambda Calculus and Combinatory Logic
John Tromp, More efficient Haskell program
FORMULA
a(n) = N(0,n) with
N(k,0) = N(k,1) = 0
N(k,n+2) = (if k>n then 1 else 0) +
N(k+1,n) +
Sum_{i=0..n} N(k,i) * N(k,n-i)
EXAMPLE
a(8) = 2 because lambda x.lambda y.lambda z.z and lambda x.(x x) are the only two closed lambda terms of size 8.
MAPLE
A114852T := proc(k, n)
option remember;
local a;
if n = 0 or n = 1 then
0;
else
a := procname(k+1, n-2) ;
if k > n-2 then
a := a+1 ;
fi ;
a := a+add(procname(k, i)*procname(k, n-i-2), i=0..n-2) ;
end if;
end proc:
A114852 := proc(n)
A114852T(0, n) ;
end proc: # R. J. Mathar, Feb 28 2015
MATHEMATICA
S[_, 0] = 0; S[_, 1] = 0; S[m_, n_] := S[m, n] = Boole[m >= n-1] + S[m+1, n-2] + Sum[S[m, k] S[m, n-k-2], {k, 0, n-2}];
a[n_] := S[0, n];
Table[a[n], {n, 0, 40}] (* Jean-François Alcover, May 23 2017 *)
PROG
(Haskell)
a114852 = closed 0 where
closed k n = if n<2 then 0 else
(if n-2<k then 1 else 0) +
closed (k+1) (n-2) +
sum [closed k i * closed k (n-2-i) | i <- [0..n-2]]
-- See link for a more efficient version.
CROSSREFS
KEYWORD
nonn
AUTHOR
John Tromp, Feb 20 2006
STATUS
approved