Re:Show HN: You can program without loop and recursion and×÷...
by raoof on Tuesday July 16, 2024 @06:29AM
(#40975181)
if you don't want to melt your brain :D you just precompute the value of any functions f(x) for x<n otherwise you need to be very clever I explained my idea in the link
Re:Show HN: You can program without loop and recursion and×÷...
by voidUpdate on Tuesday July 16, 2024 @06:52AM
(#40975312)
That's why I said an arbitrary number, you can't just precompute the primality of every single number... And I'm afraid I don't really understand your proof of being able to do loops without any kind of looping construct in the language itself
Re:Show HN: You can program without loop and recursion and×÷...
by raoof on Tuesday July 16, 2024 @07:19AM
(#40975472)
(it seems like I can't reply to your last comment so I do it here)
it depend how you want to display the result to the user, you can just compute a number that represent an html page showing the numbers from 1 to n
Re:Show HN: You can program without loop and recursion and×÷...
by raoof on Tuesday July 16, 2024 @06:58AM
(#40975341)
the language is obviously (at least to me) turing-complete in the limit of the program length. even if you don't buy my argument that it is also turing-complete without the limit notice that in ordinary programming you never need a function that is valid on all input because actual computers have time and memory limitation
Re:Show HN: You can program without loop and recursion and×÷...
by voidUpdate on Tuesday July 16, 2024 @07:03AM
(#40975380)
I must just be missing something then. How would you write a program that prints out the numbers from 1 to n, for reasonable n? (representable by a computer)
Re:Show HN: You can program without loop and recursion and×÷...
by raoof on Tuesday July 16, 2024 @07:40AM
(#40975598)
(now I can reply here, let me repeat it again)
it depend how you want to display the result to the user, you can just compute a number that represent an html page showing the numbers from 1 to n
Re:Show HN: You can program without loop and recursion and×÷...
by stoltzmann on Tuesday July 16, 2024 @12:13PM
(#40977870)
The question isn't as to how it will be represented, that's the boring part.
When given a number n, and you want to display them, how will you actually compute the numbers from 1 to n? If you precalculate a table - then how will you do n+1? What about n+2?
Re:Show HN: You can program without loop and recursion and×÷...
by raoof on Tuesday July 16, 2024 @12:41PM
(#40978106)
it takes a lot of time and patient to come up with a function that works for all n and also have a short length, let me try if I can solve this problem it may takes a few hours or days or maybe months I'll post the solution here so stay tuned. but if you want to make your life easier you can generate the function in a meta language so you can always be sure that your software does not have a halting problem
Re:Show HN: You can program without loop and recursion and×÷...
by upon_drumhead on Tuesday July 16, 2024 @12:28PM
(#40977985)
I think the issue here is that the language doesn't have any form of user input, so all possible programs are fully static and thus can be represented without any loops or conditionals.
I don't agree that the language is turning complete due to the lack of any runtime dynamic aspect of the language.
It's akin to compiling a simple c program with loops unrolled and fully static variables and claiming the subset of generated assembly is turning complete.
Re:Show HN: You can program without loop and recursion and×÷...
by rented_mule on Tuesday July 16, 2024 @01:09PM
(#40978337)
Agreed.
> It's akin to compiling a simple c program with loops unrolled and fully static variables
Yes, and optimizing compilers take this to an extreme. It turns out that "computing" a factorial only requires my runtime language to have `mov` and `ret` instructions: https://godbolt.org/z/3Y6bGcsba
Re:Show HN: You can program without loop and recursion and×÷...
by raoof on Tuesday July 16, 2024 @01:00PM
(#40978239)
in my model it's the platform job to handle the user input and your program output you just write your function and the platform calls your program for example f(time,input_data,key_a,key_b,key_c,...) . if you are very very patient and don't care about the program length you can just compute every output of your program for every possible input. according to [this](https://web.archive.org/web/20230505022436/http://page.mi.fu...) paper a single loop and four basic arithmetic operation is enough to simulate a turing machine so my idea was that to unroll the loop and my conjecture is that we don't need the loop and only four operations is enough to compute all total computable functions
Re:Show HN: You can program without loop and recursion and×÷...
by out_of_protocol on Wednesday July 17, 2024 @11:33AM
(#40986991)
Don't need a language then, just compile down to "return 4". No instructions needed.
Without user input it's not really useful. How about returning maximum value of user-privided array of int64 values? If array is static, just return final value and that's all. Smart compiler for the win!
P.S. precomputing even a single int64 space is going to be really really hard, 2^64 possible values is a lot
Re:Show HN: You can program without loop and recursion and×÷...
by FooBarBizBazz on Sunday July 21, 2024 @03:50PM
(#41027619)
This doesn't look Turing complete to me.
This should be able to interpret programs written in other Turing-complete languages, including in itself.
I was about to say, "choose an encoding for this language in terms of integers that it understands, and then show me an interpreter that can run any program so encoded". But we have another more basic problem first. As others have noted, there is no notion of program input.
Well, fine, we can solve that easily enough. Suppose that at the start of your program you have a variable called "in" containing a single integer of arbitrary size.
Now choose an encoding of these programs into integers, and show a program that will run one of them.
I assert that it isn't possible.
In fact, I think I even have a sketch at a proof. We know that Turing machines have an "undecideability" property, i.e., you can't know in general whether any given program will terminate. But we can prove that any program in this language terminates.
To do that we will need to be a little more formal about exactly what this language is. I think a reasonable choice would be to say that programs are written in static single assignment (SSA) form using only those functions. It is trivial to show that the program terminates in a number of steps equal to the number of lines of the program.
...
Is this post actually a clever troll to make the point that there's only so much that a feedforward neural net can do?
Re:Show HN: You can program without loop and recursion and×÷...
by rstuart4133 on Monday July 22, 2024 @06:45AM
(#41032926)
Why over complicate it? FRACTRAN is a Turning complete language based on only one operation: multiplication. It's Wikipedia entry gives a short FRACTRAN program that finds all primes. https://en.wikipedia.org/wiki/FRACTRAN
In the words of it's inventor, John Conway:
Makes workday really easy! FRACTRAN needs no complicate programming manual. It's entire syntax can be learned in 10 seconds, and programs for quite complex and interesting functions can be written almost at once. The entire configuration of a FRACTRAN computer at any instant is a single integer - no messy "tapes" or other foreign concepts to be understood by the fledging programmer.
When given a number n, and you want to display them, how will you actually compute the numbers from 1 to n? If you precalculate a table - then how will you do n+1? What about n+2?
I don't agree that the language is turning complete due to the lack of any runtime dynamic aspect of the language.
It's akin to compiling a simple c program with loops unrolled and fully static variables and claiming the subset of generated assembly is turning complete.
> It's akin to compiling a simple c program with loops unrolled and fully static variables
Yes, and optimizing compilers take this to an extreme. It turns out that "computing" a factorial only requires my runtime language to have `mov` and `ret` instructions: https://godbolt.org/z/3Y6bGcsba
That isn't a thing.
This language can represent any function between finite sets of integers, I will believe that (proof left as exercise). But so can a lookup table.
P.S. precomputing even a single int64 space is going to be really really hard, 2^64 possible values is a lot
This should be able to interpret programs written in other Turing-complete languages, including in itself.
I was about to say, "choose an encoding for this language in terms of integers that it understands, and then show me an interpreter that can run any program so encoded". But we have another more basic problem first. As others have noted, there is no notion of program input.
Well, fine, we can solve that easily enough. Suppose that at the start of your program you have a variable called "in" containing a single integer of arbitrary size.
Now choose an encoding of these programs into integers, and show a program that will run one of them.
I assert that it isn't possible.
In fact, I think I even have a sketch at a proof. We know that Turing machines have an "undecideability" property, i.e., you can't know in general whether any given program will terminate. But we can prove that any program in this language terminates.
To do that we will need to be a little more formal about exactly what this language is. I think a reasonable choice would be to say that programs are written in static single assignment (SSA) form using only those functions. It is trivial to show that the program terminates in a number of steps equal to the number of lines of the program.
...
Is this post actually a clever troll to make the point that there's only so much that a feedforward neural net can do?
In the words of it's inventor, John Conway:
What's not to like? This is a good introduction for someone seriously considering doing their next project in FRACTRAN: https://raganwald.com/2020/05/03/fractran.html