Zulip Chat Archive
Stream: Is there code for X?
Topic: Fast Unital Ring Accumulation
Schrodinger ZHU Yifan (Oct 10 2023 at 03:12):
I wonder if we can find a proper place to do such optimizations (The idea may be stupid :D).
1) Detect if a function f
is an operation on some unital semiring structure . Say f : Nat -> Nat
.
2) f
is proven to be total.
3) The base cases of f
is known. e.g. f(0) = 1, f(1) = 1
.
4) The only non-basic case is in the form (we can set a limit of such dependence window)
Then we can transform such recursion into a loop and thus solve it in or even a transition matrix such that solvable in .
Trebor Huang (Oct 10 2023 at 09:28):
Note that Nat is not a ring. If you meant unital semiring, then I can prove that f is the identity, thus it would be trivial.
Eric Wieser (Oct 10 2023 at 09:30):
I don't understand step 1; how do you tell if is a ring morphism without evaluating it on infinitely many Nat
s?
Schrodinger ZHU Yifan (Oct 10 2023 at 10:07):
Trebor Huang said:
Note that Nat is not a ring. If you meant unital semiring, then I can prove that f is the identity, thus it would be trivial.
sorry updated.
Schrodinger ZHU Yifan (Oct 10 2023 at 10:08):
I am not sure why f is id. fibonacci function should be one of such f. Perhaps I missed something in the above description.
Eric Rodriguez (Oct 10 2023 at 10:11):
Schrodinger ZHU Yifan said:
I am not sure why f is id. fibonacci function should be one of such f. Perhaps I missed something in the above description.
1 = fib(0+0) ≠ fib 0 + fib 0 = 2
Schrodinger ZHU Yifan (Oct 10 2023 at 10:11):
Eric Wieser said:
I don't understand step 1; how do you tell if $f : \N \to \N$ is a ring morphism without evaluating it on infinitely many
Nat
s?
no, the compiler never proves it but knows in advance.
Schrodinger ZHU Yifan (Oct 10 2023 at 10:16):
Eric Rodriguez said:
Schrodinger ZHU Yifan said:
I am not sure why f is id. fibonacci function should be one of such f. Perhaps I missed something in the above description.
1 = fib(0+0) ≠ fib 0 + fib 0 = 2
Ah, I see. Should I just drop endomorphism? f is just a self loop.
Schrodinger ZHU Yifan (Oct 10 2023 at 10:21):
Actually, I tried to generalize it but may have stated it wrongly. There must be some other restrictions like R should be discrete. For now, maybe one should just think about (Nat, +, *, 0, 1).
Schrodinger ZHU Yifan (Oct 10 2023 at 10:22):
Or other integral types.
Eric Rodriguez (Oct 10 2023 at 12:05):
Can you write the explicit conditions you want your functions to obey?
Schrodinger ZHU Yifan (Oct 10 2023 at 16:21):
Sure. I will come up with more details when I am available.
Siddharth Bhat (Oct 10 2023 at 22:08):
There is a general theory of such optimizations, going by the name of “scalar evolution” or “chains of recurrences” in the compilers literature. Here is a repo with some formalization and links to the literature: https://github.com/bollu/scev-coq
Last updated: Dec 20 2023 at 11:08 UTC