

How Many C Programs Are There? - primodemus
http://blog.regehr.org/archives/689

======
dexen
There'd be a whole lot of programs.

There's a good reading that approaches a related subject, but isn't specific
to _C_ programs: <http://www.scottaaronson.com/writings/bignumbers.html>

In short, `busy beaver number' -- number of steps that a halting Turing
machine with dictionary of size N can have -- grows pretty fast with N; faster
than Ackermann function anyway.

Also, supposedly _a katamari is the only thing which outgrows the busy beaver
sequence ;)_ <http://www.xamuel.com/katamari-damacy-growth/>

~~~
baddox
> _faster than Ackermann function anyway_

Alas, it grows faster than _any_ computable function.

------
bnegreve
> _Anyway, I’d be interested to hear people’s thoughts on this_

I would rather try to evaluate the size of the abstract syntax tree. I think
this is more relevant since int main(){int a;} is obviously similar to int
main(){int b;}

~~~
p4bl0
The author already address this issue:

> How many non-alpha-equivalent C programs are there?

and then goes further:

> How many functionally inequivalent C programs are there?

The "this" you're refering to is itself refering to this last question.

~~~
bnegreve
Yes I have read this, and using the abstract syntax tree is how I would do it.

------
fragsworth
I think it would make more sense to start by looking at research done on
grammars. For instance:

<http://www.cs.toronto.edu/~yuvalf/CFG-LB.pdf>

------
DaveInTucson
_How many functionally inequivalent C programs are there?_

Surely this is undecidable?

~~~
monochromatic
Of course. But we ought to be able to establish _some_ kind of bounds on the
number.

~~~
mistercow
> _some_ kind of bounds

Definitely. I can give a lower bound right off the top of my head: twelve.
There are at least twelve functionally distinct C programs.

~~~
monochromatic
> For every complex problem there is an answer that is clear, simple, and
> wrong.

You probably want your bound to be a function of the length of the program.
Because for programs of length 1, there are not 12 distinct C programs.

~~~
loboman
Zero is a good lower bound for all programs. Or minus one.

------
sold
If you have printf, then "printf("long string")" where the string might be
modified should give a good bound, say Omega(200^S). If you don't have it,
what is the program allowed to do? Only return from main, without checking
arguments? Then you have as many extensionally distinct programs as integers.

