fix SmallFp mul overflow on u32 #1126
Heyy 👋
I imagine you found a concrete op / test case that fails for this ? Curious what is.
Reason I'm curious is we have (a somewhat diverged) version of this code in the "z" repo. We were surprised when we were able to formalize the z repo against mathlib that there were seemingly no bugs. One theory is that the bugs were silently fixed when porting over the arithmetic (or during the process of formalizing itself).
Your finding would rule out the possibility that there were genuinely no bugs to begin with by counterexample
Interesting, perhaps the port somehow took care of this. I would be curious to know more. One simple example that fails is (p-1)*(p-1).
Interesting, perhaps the port somehow took care of this. I would be curious to know more. One simple example that fails is (p-1)*(p-1).
Ah it also fails because we formally verify instances like BabyBear, KoalaBear, M31... not the generic implementation over all inputs, which makes sense.
Cool!
Adding that example might be helpful for regression tests.
z-tech
benbencik
Motivation
SmallFpmultiplication can overflow onu32prime fields. This can be replicated on native tests forTeddyBearprime.Description
Edited case for primes
2^16 < p < 2^32to handle the overflow. Copied the approach that is used foru64primes. AddedTeddyBeardefinition and tests for this field.