coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] wasting natural fuel is costly
- Date: Wed, 16 Dec 2020 21:22:11 -0500
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-io1-f45.google.com
- Ironport-phdr: 9a23:pdNAkRXFrOL00EvZ8rfEnv5/e/LV8LGtZVwlr6E/grcLSJyIuqrYbBSBt8tkgFKBZ4jH8fUM07OQ7/m/HzVRut3Y7zgrS99lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUhrwOhBoKevrB4Xck9q41/yo+53Ufg5EmCexbal9IRmrrwjdrNQajI9sJ6o+1xfEoGZDdvhLy29vOV+dhQv36N2q/J5k/SRQuvYh+NBFXK7nYak2TqFWASo/PWwt68LlqRfMTQ2U5nsBSWoWiQZHAxLE7B7hQJj8tDbxu/dn1ymbOc32Sq00WSin4qx2RhLklDsLOjgk+2zRl8d+jr9UoAi5qhNwzY7bYoGbOvR9cK3AY90VWXFMUdxNWyFbGI6wc5cDAugHMO1Fr4f9vVwOrR6mCAeoHuzv0ThIhnnr1qM7yeQhFhrG3Bc9FN8JsnTbts71NKAUUeC61qnIyi7Db+hS1Drm54jIdwouofCIXb5qbcXRzkwvGhrDg16NpoPrIymb2f4Rs2iH8eVgT+SvhnYlpgxzvjWix8ghh4vIi48J1l3I6CV0zYIxKNC7VkN1btypHpVNuiyZM4Z6XMMsTn9otis617ELt4O3cSkWxJkowRPUdv+Jc5CQ7x79SOqcJS10iXFldb6lmhq/8EmtxvfzW8S01ltBszBLncPWtn8X0hze8siHReV5/kemwTuP0hrc6uBAIUwtlKrbLIMtzqc+lpccsUnPBCD2mELxjK+ZckUr5PKk5PjgYrXjvpOcNol0hR/iMqk2hMCzHeA1PhINUmWb4+iwybzu8EzjTLhFjvA6iqzZv4rbJcQfqK65GQhV0oM75ha9FTimy9MYnX8ILFJffxKHlJPpNlXVLfD3CPewmVWskDNxy//aOb3hB43BLmLfn7f5YbZ990lcxRIvwtBY/pJYE60OIPbuWkDqr9HYFR84Mwmsw+n9Etl914UeWXiOAqCDKq/Sv0WItaoTJLyHY5ZQszLgIbBx7Pn3yHQ9hFU1fK+z3JJRZmruTdp8JEDMQ3P3hdFJPn0NpRF2GO7jk1qEXiRUfG3jd6057zA/TomhCNGQFciWnLWd0XLjTdVtbWdcBwXUSCa6R8C/Q/4JLRmqDIpkmz0AW6KmTtZ4hx6rvQ7+jbFgK7iNo3BKhdfYzNFwotbru1Qy+DhzVZnP1miMSyR1mTpNSWNrmq94pkN5xxGI1q0q26UER+wW3OtAV0IBDbCZ1/ZzUomgVQfIf9PPQ1GjEI2r
Does anything change if you don't pass the fuel as a literal, but instead pass it as 10*10? What if you use a "thunked nat" type for recursion where the successor argument is of type "(unit -> tnat) -> tnat", so the fuel isn't computed eagerly, define addition and multiplication for these, and then use 10*10 as thunked nat fuel?
I have a recursive Gallina function that uses a nat-typed fuel arg to
guarantee termination. In cases where the function terminates prior to
running out of fuel, I've found that larger than necessary fuel args
are very costly. For example, with a fuel value of 100, the function
takes 30 times longer than if the fuel value is 10 (neither runs out of
fuel, all other args are the same). In both cases, the computation was
done with vm_cast_no_check. Nothing is done with the fuel arg other
than the usual "match fuel with 0 => done | S n => loop n"
recursion idiom.
I guess this is probably due to the overhead of nats in Gallina. But
it is still surprising to me, considering that if I wrote a function to
traverse the first 8 links in a list, I wouldn't expect it to take 30
times longer with a 100-element list than a 10-element list.
Is there a way around this? I'd like to use a constant fuel value
that is plenty large enough, without having to compute one from the
function's arguments that is just barely large enough.
- [Coq-Club] wasting natural fuel is costly, jonikelee AT gmail.com, 12/17/2020
- Re: [Coq-Club] wasting natural fuel is costly, Jason Gross, 12/17/2020
- Re: [Coq-Club] wasting natural fuel is costly, Clément Pit-Claudel, 12/17/2020
- Re: [Coq-Club] wasting natural fuel is costly, jonikelee AT gmail.com, 12/17/2020
- Re: [Coq-Club] wasting natural fuel is costly, Jason Gross, 12/17/2020
- Re: [Coq-Club] wasting natural fuel is costly, jonikelee AT gmail.com, 12/17/2020
Archive powered by MHonArc 2.6.19+.