I'm currently working with vellvm, developing a transformation on it. I'm a coq newbie.
While programming, I faced the following warning:
Warning: Stack overflow or segmentation fault happens when working with large numbers in nat (observed threshold may vary from 5000 to 70000 depending on your system limits and on the command executed).
My function that generates this warning calculates a signature. The signature is divided in superior and inferior bits. Given two nats n1 and n2 representing the superior bits and the inferior bits, it calculates (n1*65536)+n2 - this is an abstraction for put two binary numbers of 16 bits side-by-side.
I was quite surprised because coq nat definition appears to handle big ints from outside, thanks to the S constructor.
How should I avoid this warning/use big numbers in coq? I'm open to change the implementation from nat to some kind of binary construction.
Thanks!
S
, meaning every number will literally be a sequence ofS
applications: you might work with integers instead, which have similar proof principles but have a sign / magnitude (bit) based representation: coq.inria.fr/library/Coq.ZArith.BinInt.html – Scaleneplus
is defined struturally on two nats. You want to use theplus
for integers, which lives in a different interpretation scope than fornat
(namely,Int_scope
). Read about interpretation scopes and how to open them and use them. – Scalene