coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Guillaume Melquiond <guillaume.melquiond AT inria.fr>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] large numbers in Gallina
- Date: Mon, 21 Dec 2020 08:09:13 +0100
Le 20/12/2020 à 19:10, jonikelee AT gmail.com a écrit :
> What is the best performing way to use large numbers in Gallina? I am
> getting the following warning, which seems to imply I could have done
> something better with this definition:
>
> Definition fuel : nat := 10000.
>
> Warning: To avoid stack overflow, large numbers in nat are interpreted
> as applications of Nat.of_num_uint. [abstract-large-number,numbers]
> fuel is defined
Before trying to represent large numbers (e.g., using Z.to_nat), you
should first reconsider whether you actually need such large numbers.
Indeed, even to ensure termination, this is mightily inefficient.
Consider the following function as an example:
Fixpoint foo (n:nat) x :=
match n with
| S n => foo n (foo n x)
| O => bar x
end.
With n = 64, it will already run past the end of the solar system.
So, if you need more fuel than that, it presumably means that your
function was not properly written.
Best regards,
Guillaume
- [Coq-Club] large numbers in Gallina, jonikelee AT gmail.com, 12/20/2020
- Re: [Coq-Club] large numbers in Gallina, Guillaume Melquiond, 12/21/2020
- Re: [Coq-Club] large numbers in Gallina, Xavier Leroy, 12/21/2020
- Re: [Coq-Club] large numbers in Gallina, Guillaume Melquiond, 12/21/2020
- Re: [Coq-Club] large numbers in Gallina, Xavier Leroy, 12/21/2020
- Re: [Coq-Club] large numbers in Gallina, Guillaume Melquiond, 12/21/2020
Archive powered by MHonArc 2.6.19+.